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

# Create a Setup Intent

> Cria um setup intent.

Cria um `setup_intent`, usado para salvar ou anexar um método de pagamento sem
cobrar imediatamente.

<ParamField body="customer" type="string">
  Customer que receberá o método salvo.
</ParamField>

<ParamField body="payment_method" type="string">
  Payment method já salvo (`pm_*`) que será preparado. Quando informado, o
  `setup_intent` nasce com `status: "requires_confirmation"`.
</ParamField>

<ParamField body="confirm" type="boolean">
  Quando `true`, cria e confirma o setup intent na mesma chamada.
</ParamField>

<ParamField body="token_id" type="string">
  Token de cartão de uso único. Só pode ser enviado junto com `confirm: true`.
</ParamField>

<ParamField body="card_id" type="string">
  ID de cartão já salvo que **pertence a este customer**. Só pode ser enviado junto
  com `confirm: true`. A propriedade é validada antes de salvar; um cartão que não
  pertence ao customer é recusado. Prefira `token_id` no fluxo padrão.
</ParamField>

<ParamField body="usage" type="string">
  `off_session` ou `on_session`. Padrão: `off_session`.
</ParamField>

<ParamField body="payment_method_types" type="array">
  Hoje aceita `["credit_card"]`.
</ParamField>

<ParamField body="metadata" type="object">
  Metadata livre.
</ParamField>

<RequestExample>
  ```bash cURL theme={}
  curl -X POST "https://api.chargefy.io/v1/setup-intents" \
    -H "Authorization: Bearer {{API_KEY}}"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={}
  {
    "id": "seti_123",
    "object": "setup_intent",
    "canceled_at": null,
    "cancellation_reason": null,
    "client_secret": "seti_123_secret_abc",
    "created_at": "2026-05-16T18:30:00Z",
    "customer": "cus_123",
    "last_setup_error": null,
    "livemode": true,
    "metadata": {},
    "next_action": null,
    "payment_method": null,
    "payment_method_types": [
      "credit_card"
    ],
    "status": "requires_payment_method",
    "updated_at": null,
    "usage": "off_session"
  }
  ```
</ResponseExample>

<RequestExample>
  ```bash Criar e confirmar theme={}
  curl -X POST "https://api.chargefy.io/v1/setup-intents" \
    -H "Authorization: Bearer {{API_KEY}}" \
    -H "Content-Type: application/json" \
    -d '{
      "confirm": true,
      "customer": "cus_123",
      "token_id": "tok_123"
    }'
  ```
</RequestExample>
