# PostSetupIntents

From **Stripe API**.

`POST /v1/setup_intents`

<p>Creates a SetupIntent object.</p>

<p>After the SetupIntent is created, attach a payment method and <a href="/docs/api/setup_intents/confirm">confirm</a>
to collect any required permissions to charge the payment method later.</p>

## Request body

- Required: false
### `application/x-www-form-urlencoded`

- Type: `object`

```json
{"additionalProperties":false,"properties":{"confirm":{"description":"Set to `true` to attempt to confirm this SetupIntent immediately. This parameter defaults to `false`. If the payment method attached is a card, a return_url may be provided in case additional authentication is required.","type":"boolean"},"customer":{"description":"ID of the Customer this SetupIntent belongs to, if one exists.\n\nIf present, the SetupIntent's payment method will be attached to the Customer on successful setup. Payment methods attached to other Customers cannot be used with this SetupIntent.","maxLength":5000,"type":"string"},"description":{"description":"An arbitrary string attached to the object. Often useful for displaying to users.","maxLength":1000,"type":"string"},"expand":{"description":"Specifies which fields in the response should be expanded.","items":{"maxLength":5000,"type":"string"},"type":"array"},"mandate_data":{"description":"This hash contains details about the Mandate to create. This parameter can only be used with [`confirm=true`](https://stripe.com/docs/api/setup_intents/create#create_setup_intent-confirm).","properties":{"customer_acceptance":{"properties":{"accepted_at":{"format":"unix-time","type":"integer"},"offline":{"title":"offline_param","type":"object"},"online":{"properties":{"ip_address":{"type":"string"},"user_agent":{"maxLength":5000,"type":"string"}},"required":["ip_address","user_agent"],"title":"online_param","type":"object"},"type":{"enum":["offline","online"],"maxLength":5000,"type":"string"}},"required":["type"],"title":"customer_acceptance_param","type":"object"}},"required":["customer_acceptance"],"title":"secret_key_param","type":"object"},"metadata":{"additionalProperties":{"type":"string"},"description":"Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.","type":"object"},"on_behalf_of":{"description":"The Stripe account ID for which this SetupIntent is created.","type":"string"},"payment_method":{"description":"ID of the payment method (a PaymentMethod, Card, or saved Source object) to attach to this SetupIntent.","maxLength":5000,"type":"string"},"payment_method_options":{"description":"Payment-method-specific configuration for this SetupIntent.","properties":{"acss_debit":{"properties":{"currency":{"enum":["cad","usd"],"type":"string"},"mandate_options":{"properties":{"custom_mandate_url":{"anyOf":[{"type":"string"},{"enum":[""],"type":"string"}]},"default_for":{"items":{"enum":["invoice","subscription"],"type":"string"},"type":"array"},"interval_description":{"maxLength":500,"type":"string"},"payment_schedule":{"enum":["combined","interval","sporadic"],"type":"string"},"transaction_type":{"enum":["business","personal"],"type":"string"}},"title":"setup_intent_payment_method_options_mandate_options_param","type":"object"},"verification_method":{"enum":["automatic","instant","microdeposits"],"type":"string","x-stripeBypassValidation":true}},"title":"setup_intent_payment_method_options_param","type":"object"},"card":{"properties":{"request_three_d_secure":{"enum":["any","automatic"],"maxLength":5000,"type":"string","x-stripeBypassValidation":true}},"title":"setup_intent_param","type":"object"},"sepa_debit":{"properties":{"mandate_options":{"title":"payment_method_options_mandate_options_param","type":"object"}},"title":"setup_intent_payment_method_options_param","type":"object"}},"title":"payment_method_options_param","type":"object"},"payment_method_types":{"description":"The list of payment method types (e.g. card) that this SetupIntent is allowed to use. If this is not provided, defaults to [\"card\"].","items":{"maxLength":5000,"type":"string"},"type":"array"},"return_url":{"description":"The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site. If you'd prefer to redirect to a mobile application, you can alternatively supply an application URI scheme. This parameter can only be used with [`confirm=true`](https://stripe.com/docs/api/setup_intents/create#create_setup_intent-confirm).","type":"string"},"single_use":{"description":"If this hash is populated, this SetupIntent will generate a single_use Mandate on success.","properties":{"amount":{"type":"integer"},"currency":{"type":"string"}},"required":["amount","currency"],"title":"setup_intent_single_use_params","type":"object"},"usage":{"description":"Indicates how the payment method is intended to be used in the future. If not provided, this value defaults to `off_session`.","enum":["off_session","on_session"],"type":"string"}},"type":"object"}
```

## Security

### `basicAuth`

- Type: `http`
- Request header: `Authorization`
- Scheme: `basic`
Send credentials in the `Authorization` request header using the `Basic` scheme.

Basic HTTP authentication. Allowed headers-- Authorization: Basic <api_key> | Authorization: Basic <base64 hash of `api_key:`>

### `bearerAuth`

- Type: `http`
- Request header: `Authorization`
- Scheme: `bearer`
- Bearer format: `auth-scheme`
Send the token in the `Authorization` request header using the `Bearer` scheme.

Bearer HTTP authentication. Allowed headers-- Authorization: Bearer <api_key>

## Responses

### `200`

Successful response.

### `application/json`

- Type: `object`

A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments.
For example, you could use a SetupIntent to set up and save your customer's card without immediately collecting a payment.
Later, you can use [PaymentIntents](https://stripe.com/docs/api#payment_intents) to drive the payment flow.

Create a SetupIntent as soon as you're ready to collect your customer's payment credentials.
Do not maintain long-lived, unconfirmed SetupIntents as they may no longer be valid.
The SetupIntent then transitions through multiple [statuses](https://stripe.com/docs/payments/intents#intent-statuses) as it guides
you through the setup process.

Successful SetupIntents result in payment credentials that are optimized for future payments.
For example, cardholders in [certain regions](/guides/strong-customer-authentication) may need to be run through
[Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication) at the time of payment method collection
in order to streamline later [off-session payments](https://stripe.com/docs/payments/setup-intents).
If the SetupIntent is used with a [Customer](https://stripe.com/docs/api#setup_intent_object-customer), upon success,
it will automatically attach the resulting payment method to that Customer.
We recommend using SetupIntents or [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage) on
PaymentIntents to save payment methods in order to prevent saving invalid or unoptimized payment methods.

By using SetupIntents, you ensure that your customers experience the minimum set of required friction,
even as regulations change over time.

Related guide: [Setup Intents API](https://stripe.com/docs/payments/setup-intents).

```json
{"description":"A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments.\nFor example, you could use a SetupIntent to set up and save your customer's card without immediately collecting a payment.\nLater, you can use [PaymentIntents](https://stripe.com/docs/api#payment_intents) to drive the payment flow.\n\nCreate a SetupIntent as soon as you're ready to collect your customer's payment credentials.\nDo not maintain long-lived, unconfirmed SetupIntents as they may no longer be valid.\nThe SetupIntent then transitions through multiple [statuses](https://stripe.com/docs/payments/intents#intent-statuses) as it guides\nyou through the setup process.\n\nSuccessful SetupIntents result in payment credentials that are optimized for future payments.\nFor example, cardholders in [certain regions](/guides/strong-customer-authentication) may need to be run through\n[Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication) at the time of payment method collection\nin order to streamline later [off-session payments](https://stripe.com/docs/payments/setup-intents).\nIf the SetupIntent is used with a [Customer](https://stripe.com/docs/api#setup_intent_object-customer), upon success,\nit will automatically attach the resulting payment method to that Customer.\nWe recommend using SetupIntents or [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage) on\nPaymentIntents to save payment methods in order to prevent saving invalid or unoptimized payment methods.\n\nBy using SetupIntents, you ensure that your customers experience the minimum set of required friction,\neven as regulations change over time.\n\nRelated guide: [Setup Intents API](https://stripe.com/docs/payments/setup-intents).","properties":{"application":{"anyOf":[{"maxLength":5000,"type":"string"},{"$ref":"#/components/schemas/application"}],"description":"ID of the Connect application that created the SetupIntent.","nullable":true,"x-expansionResources":{"oneOf":[{"$ref":"#/components/schemas/application"}]}},"cancellation_reason":{"description":"Reason for cancellation of this SetupIntent, one of `abandoned`, `requested_by_customer`, or `duplicate`.","enum":["abandoned","duplicate","requested_by_customer"],"nullable":true,"type":"string"},"client_secret":{"description":"The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.\n\nThe client secret can be used to complete payment setup from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.","maxLength":5000,"nullable":true,"type":"string"},"created":{"description":"Time at which the object was created. Measured in seconds since the Unix epoch.","format":"unix-time","type":"integer"},"customer":{"anyOf":[{"maxLength":5000,"type":"string"},{"$ref":"#/components/schemas/customer"},{"$ref":"#/components/schemas/deleted_customer"}],"description":"ID of the Customer this SetupIntent belongs to, if one exists.\n\nIf present, the SetupIntent's payment method will be attached to the Customer on successful setup. Payment methods attached to other Customers cannot be used with this SetupIntent.","nullable":true,"x-expansionResources":{"oneOf":[{"$ref":"#/components/schemas/customer"},{"$ref":"#/components/schemas/deleted_customer"}]}},"description":{"description":"An arbitrary string attached to the object. Often useful for displaying to users.","maxLength":5000,"nullable":true,"type":"string"},"id":{"description":"Unique identifier for the object.","maxLength":5000,"type":"string"},"last_setup_error":{"anyOf":[{"$ref":"#/components/schemas/api_errors"}],"description":"The error encountered in the previous SetupIntent confirmation.","nullable":true},"latest_attempt":{"anyOf":[{"maxLength":5000,"type":"string"},{"$ref":"#/components/schemas/setup_attempt"}],"description":"The most recent SetupAttempt for this SetupIntent.","nullable":true,"x-expansionResources":{"oneOf":[{"$ref":"#/components/schemas/setup_attempt"}]}},"livemode":{"description":"Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.","type":"boolean"},"mandate":{"anyOf":[{"maxLength":5000,"type":"string"},{"$ref":"#/components/schemas/mandate"}],"description":"ID of the multi use Mandate generated by the SetupIntent.","nullable":true,"x-expansionResources":{"oneOf":[{"$ref":"#/components/schemas/mandate"}]}},"metadata":{"additionalProperties":{"maxLength":500,"type":"string"},"description":"Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.","nullable":true,"type":"object"},"next_action":{"anyOf":[{"$ref":"#/components/schemas/setup_intent_next_action"}],"description":"If present, this property tells you what actions you need to take in order for your customer to continue payment setup.","nullable":true},"object":{"description":"String representing the object's type. Objects of the same type share the same value.","enum":["setup_intent"],"type":"string"},"on_behalf_of":{"anyOf":[{"maxLength":5000,"type":"string"},{"$ref":"#/components/schemas/account"}],"description":"The account (if any) for which the setup is intended.","nullable":true,"x-expansionResources":{"oneOf":[{"$ref":"#/components/schemas/account"}]}},"payment_method":{"anyOf":[{"maxLength":5000,"type":"string"},{"$ref":"#/components/schemas/payment_method"}],"description":"ID of the payment method used with this SetupIntent.","nullable":true,"x-expansionResources":{"oneOf":[{"$ref":"#/components/schemas/payment_method"}]}},"payment_method_options":{"anyOf":[{"$ref":"#/components/schemas/setup_intent_payment_method_options"}],"description":"Payment-method-specific configuration for this SetupIntent.","nullable":true},"payment_method_types":{"description":"The list of payment method types (e.g. card) that this SetupIntent is allowed to set up.","items":{"maxLength":5000,"type":"string"},"type":"array"},"single_use_mandate":{"anyOf":[{"maxLength":5000,"type":"string"},{"$ref":"#/components/schemas/mandate"}],"description":"ID of the single_use Mandate generated by the SetupIntent.","nullable":true,"x-expansionResources":{"oneOf":[{"$ref":"#/components/schemas/mandate"}]}},"status":{"description":"[Status](https://stripe.com/docs/payments/intents#intent-statuses) of this SetupIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `canceled`, or `succeeded`.","enum":["canceled","processing","requires_action","requires_confirmation","requires_payment_method","succeeded"],"type":"string"},"usage":{"description":"Indicates how the payment method is intended to be used in the future.\n\nUse `on_session` if you intend to only reuse the payment method when the customer is in your checkout flow. Use `off_session` if your customer may or may not be in your checkout flow. If not provided, this value defaults to `off_session`.","maxLength":5000,"type":"string"}},"required":["created","id","livemode","object","payment_method_types","status","usage"],"title":"SetupIntent","type":"object","x-expandableFields":["application","customer","last_setup_error","latest_attempt","mandate","next_action","on_behalf_of","payment_method","payment_method_options","single_use_mandate"],"x-resourceId":"setup_intent"}
```

### `default`

Error response.

### `application/json`

- Type: `object`

An error response from the Stripe API

```json
{"description":"An error response from the Stripe API","properties":{"error":{"$ref":"#/components/schemas/api_errors"}},"required":["error"],"type":"object"}
```

## Request examples

### cURL

```shell
curl --request POST \
  --url https://api.stripe.com/v1/setup_intents \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data '{
  "confirm": true,
  "customer": "string",
  "description": "string",
  "expand": [
    "string"
  ],
  "mandate_data": {
    "customer_acceptance": {
      "accepted_at": 1,
      "offline": {},
      "online": {
        "ip_address": "string",
        "user_agent": "string"
      },
      "type": "string"
    }
  },
  "metadata": {},
  "on_behalf_of": "string",
  "payment_method": "string",
  "payment_method_options": {
    "acss_debit": {
      "currency": "string",
      "mandate_options": {
        "custom_mandate_url": "string",
        "default_for": [
          "string"
        ],
        "interval_description": "string",
        "payment_schedule": "string",
        "transaction_type": "string"
      },
      "verification_method": "string"
    },
    "card": {
      "request_three_d_secure": "string"
    },
    "sepa_debit": {
      "mandate_options": {}
    }
  },
  "payment_method_types": [
    "string"
  ],
  "return_url": "string",
  "single_use": {
    "amount": 1,
    "currency": "string"
  },
  "usage": "string"
}'
```
