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

# Create Setup Intent

> Creates a setup intent so a customer can save a payment method without being charged. Confirm it client-side with the returned `client_secret`, then verify the result with `GET /intents/setups/{provider_setup_intent_id}`.



## OpenAPI

````yaml /openapi.json post /intents/setups
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /intents/setups:
    post:
      tags:
        - Intents
      summary: Create Setup Intent
      description: >-
        Creates a setup intent so a customer can save a payment method without
        being charged. Confirm it client-side with the returned `client_secret`,
        then verify the result with `GET
        /intents/setups/{provider_setup_intent_id}`.
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: >-
            Deduplicates retried requests with the same key and parameters
            instead of creating a second resource. Recommended: an opaque,
            randomly-generated value such as a UUID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                provider_customer_id:
                  type: string
                  description: >-
                    Existing provider customer ID the payment method will be
                    saved against. Must belong to your own configuration.
                usage:
                  type: string
                  description: >-
                    One of `"on_session"`, `"off_session"`. Default
                    `"off_session"`.
                metadata:
                  type: object
                  additionalProperties:
                    type: string
                  description: >-
                    Free-form string key/value pairs forwarded to the payment
                    provider.
              required:
                - provider_customer_id
            example:
              provider_customer_id: test_customer_id
              usage: off_session
              metadata:
                test_key: test_value
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      config_id:
                        type: string
                        description: Configuration ID.
                      provider_account_id:
                        type:
                          - string
                          - 'null'
                        description: Provider account ID.
                      payment_provider:
                        type: string
                        description: Provider enum (e.g. `"stripe"`).
                      provider_setup_intent_id:
                        type: string
                        description: Provider setup-intent ID.
                      status:
                        type: string
                        description: >-
                          Setup intent status (e.g. `"requires_payment_method"`,
                          `"succeeded"`).
                      usage:
                        type: string
                        description: >-
                          How the saved payment method may be used
                          (`"off_session"` / `"on_session"`).
                      client_secret:
                        type:
                          - string
                          - 'null'
                        description: >-
                          Client secret used to confirm the setup intent
                          client-side.
                      provider_payment_method_id:
                        type:
                          - string
                          - 'null'
                        description: >-
                          Provider payment-method ID (expanded objects collapsed
                          to ID).
                      payment_method_types:
                        type: array
                        items:
                          type: string
                        description: Allowed payment method types (e.g. `["card"]`).
                      provider_customer_id:
                        type: string
                        description: >-
                          Provider customer ID the payment method is being saved
                          against.
                      last_setup_error:
                        type:
                          - object
                          - 'null'
                        description: >-
                          Curated last setup error, or `null` when the most
                          recent attempt did not error.
                      created:
                        type: integer
                        description: Unix timestamp.
                      livemode:
                        type: boolean
                        description: Whether this is a live-mode object.
                required:
                  - data
              example:
                data:
                  config_id: cfg_123
                  provider_account_id: test_account_id
                  payment_provider: stripe
                  provider_setup_intent_id: test_setup_intent_id
                  status: requires_payment_method
                  usage: off_session
                  client_secret: test_setup_intent_key
                  provider_payment_method_id: null
                  payment_method_types:
                    - card
                  provider_customer_id: test_customer_id
                  last_setup_error: null
                  created: 1000
                  livemode: false
        '400':
          description: >-
            Missing body, missing `provider_customer_id`, invalid `usage`, or
            non-object `metadata`.
        '401':
          description: Missing or invalid bearer token.
        '403':
          description: >-
            No configuration exists for your account, or provider access has
            been disabled for it.
        '404':
          description: Your configuration could not be resolved.
        '500':
          description: An upstream provider error.
      security:
        - serviceToken: []
        - userToken: []
components:
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}
    userToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User access token issued by POST /auth/token via the verification-code
        grant (after Verify a one-time code) or the refresh_token grant.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.