> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quentli.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create setup session

> Creates a hosted session for enrolling a payment method. Resolves or creates the customer and returns an authenticated setup URL.



## OpenAPI

````yaml /openapi.yaml post /v1/setup-sessions
openapi: 3.0.3
info:
  title: Quentli REST API
  version: 1.0.0
  description: OpenAPI spec for Quentli REST endpoints.
servers:
  - url: https://api.quentli.com
    description: Production API
  - url: https://api.staging.quentli.com
    description: Staging API for production-like validation
  - url: https://api.demo.quentli.com
    description: Demo API hostname served by staging
security:
  - organizationApiKey: []
tags:
  - name: Auth
  - name: Billing
  - name: Catalog
  - name: Customers
  - name: Invoices
  - name: Payment Methods
  - name: Payment Sessions
  - name: Payments
  - name: Subscriptions
  - name: Tax Invoices
  - name: Webhooks
paths:
  /v1/setup-sessions:
    post:
      tags:
        - Payment Sessions
      summary: Create setup session
      description: >-
        Creates a hosted session for enrolling a payment method. Resolves or
        creates the customer and returns an authenticated setup URL.
      operationId: setup_sessions_create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSetupSessionArgs'
      responses:
        '200':
          description: Setup session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSetupSessionPayload'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
        '403':
          description: Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
components:
  schemas:
    CreateSetupSessionArgs:
      type: object
      properties:
        input:
          type: object
          properties:
            returnUrl:
              type: string
              description: URL to redirect to after successful setup.
              example: https://example.com/success
            cancelUrl:
              type: string
              description: URL to redirect to if the customer cancels.
              example: https://example.com/cancel
            displayMode:
              type: string
              enum:
                - CUSTOMER_PORTAL
                - CUSTOM
                - EMBEDDED
              default: CUSTOMER_PORTAL
              description: How the setup UI is presented.
              example: CUSTOMER_PORTAL
            customer:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  description: Customer full name.
                  example: Juan Pérez
                externalId:
                  type: string
                  description: External ID used to match or create the customer.
                  example: A-1029
                phoneNumber:
                  type: string
                  description: Customer phone number in E.164 format.
                  example: '+5215512345678'
                email:
                  type: string
                  format: email
                  description: Customer email address.
                  example: juan@example.com
                forceUpdate:
                  type: boolean
                  description: Whether to overwrite existing customer fields.
                  example: false
                metadata:
                  type: array
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                      value:
                        type: string
                    required:
                      - key
                      - value
                  description: Metadata entries to attach to the customer.
                  example: []
              required:
                - name
              additionalProperties: false
          required:
            - customer
          additionalProperties: false
      required:
        - input
      description: Request body for creating a setup session to enroll a payment method.
    CreateSetupSessionPayload:
      type: object
      properties:
        url:
          type: string
          description: Authenticated setup URL for the customer.
        session:
          type: object
          properties:
            accessToken:
              type: string
              description: JWT access token.
            csrfToken:
              type: string
              description: CSRF token for form submissions.
            refreshToken:
              type: string
              description: Token used to obtain a new access token.
            accessTokenExpiresAt:
              anyOf:
                - type: string
                  description: Date string
                - type: string
                  format: date-time
                  description: Date object
              description: When the access token expires.
            expiresAt:
              anyOf:
                - type: string
                  description: Date string
                - type: string
                  format: date-time
                  description: Date object
              description: When the session expires entirely.
          required:
            - accessToken
            - csrfToken
            - refreshToken
            - accessTokenExpiresAt
            - expiresAt
          description: Customer session tokens.
      required:
        - url
      additionalProperties: false
      description: Created setup session with an authenticated URL.
    UserError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - error
      additionalProperties: false
      description: Standard user-facing error response envelope.
  securitySchemes:
    organizationApiKey:
      type: http
      scheme: bearer
      description: 'Organization API key using `Authorization: Bearer sk_...`.'

````