---
title: "Create a payment intent"
description: "Purpose: payment or setup."
canonical_url: "https://twominutebilling.com/help/developers/api-reference/payment-intents/create-a-payment-intent"
---
# Create a payment intent

> Purpose: payment or setup.

<api-operation method="POST" path="/v1/businesses/{biz}/payment_intents">
<template v-slot:docs="">

Creates the intent AND its first attempt; the response carries `attempt`, because the buyer’s challenge (`next_action`) belongs to that attempt.

**purpose: payment** — requires `payment_method` and a positive `amount_minor`. The customer comes from the payment method, so `customer` must be omitted.

**purpose: setup** — requires `customer`, and takes NO `payment_method` (the buyer supplies the instrument during the challenge) and NO amount (`amount_minor` must be omitted or 0). This is the zero-amount vaulting authorization; it was previously impossible to express over this API.

## Path parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        biz
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Business id (biz_…)
    </td>
  </tr>
</tbody>
</table>

## Headers

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        Idempotency-Key
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Safely retry writes — repeats return the original response. If a write FAILED after it had already taken effect, that failure is what repeats: the key is spent, and a new attempt needs a new key.
    </td>
  </tr>
</tbody>
</table>

## Body

The request body is **required**.

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        purpose
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      What the intent is for. <code>
        setup
      </code>
      
       is a zero-amount authorization that vaults an instrument. One of <code>
        payment
      </code>
      
      , <code>
        setup
      </code>
      
      . Defaults to <code>
        "payment"
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        payment_method
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      <code>
        payment
      </code>
      
       only — a setup intent has nothing vaulted yet to authorize.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        customer
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      <code>
        setup
      </code>
      
       only — for a <code>
        payment
      </code>
      
       intent the customer comes from the payment method.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        amount_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Integer minor units, at most 10^12. Positive for <code>
        payment
      </code>
      
      ; omitted or 0 for <code>
        setup
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The business's default currency or one on its currency list, or the currency of the <code>
        invoice
      </code>
      
       or <code>
        subscription
      </code>
      
       named. Any other is a 400.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invoice
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Context link stored on the intent.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        subscription
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Context link stored on the intent.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        return_url
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Where the gateway returns the buyer after a redirect challenge.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cancel_url
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Where to send the customer if they cancel.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        method_types
      </code>
    </td>
    
    <td>
      <code>
        array of string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Instruments the buyer may use, in our canonical vocabulary (<code>
        card
      </code>
      
      , <code>
        us_bank_account
      </code>
      
      , <code>
        upi
      </code>
      
      , …).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        session
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      An off_session buyer cannot complete a challenge. One of <code>
        on_session
      </code>
      
      , <code>
        off_session
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        max_amount_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      <code>
        setup
      </code>
      
       only — the per-debit ceiling of the mandate this intent registers, in minor units of <code>
        currency
      </code>
      
      . Mandate rails (RazorPay e-mandate/UPI/card) demand an upper bound at registration and enforce it at debit time, so omitting it lets the gateway apply its own default cap. It is stored on the intent, so a retry re-registers with the same ceiling. Rejected for <code>
        purpose: payment
      </code>
      
      , which registers no mandate.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        gateway_account
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Pin the intent to this gateway account instead of routing. It must be this business's, active, in its mode, and able to take the currency and method.
    </td>
  </tr>
</tbody>
</table>

## Response

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The object type; always <code>
        payment_intent
      </code>
      
      . One of <code>
        payment_intent
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The payment intent's id (pi_…).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        voided
      </code>
      
       is set by the void route alongside <code>
        voided_at
      </code>
      
      . One of <code>
        inited
      </code>
      
      , <code>
        in_progress
      </code>
      
      , <code>
        authorized
      </code>
      
      , <code>
        consumed
      </code>
      
      , <code>
        expired
      </code>
      
      , <code>
        voided
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        purpose
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Whether the intent takes a payment or saves a payment method. One of <code>
        payment
      </code>
      
      , <code>
        setup
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        amount_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      Always 0 for a <code>
        setup
      </code>
      
       intent.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        max_amount_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The mandate ceiling this <code>
        setup
      </code>
      
       intent registered with, and what a retry re-registers with. Null for <code>
        payment
      </code>
      
       intents.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The payment intent's currency (ISO-4217 code).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        attempt_count
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      Payment attempts — how many times this intent has been tried at the gateway.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        last_attempt_status
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Status of the NEWEST attempt. <code>
        status
      </code>
      
       above cannot express a refusal — there is no <code>
        failed
      </code>
      
       intent status, because a declined authorization leaves the intent OPEN so it can be retried — so this is what distinguishes a declined intent from one the buyer is still working through. <code>
        null
      </code>
      
       means no attempt has been made yet. One of <code>
        inited
      </code>
      
      , <code>
        requires_action
      </code>
      
      , <code>
        authorized
      </code>
      
      , <code>
        consumed
      </code>
      
      , <code>
        failed
      </code>
      
      , <code>
        voided
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        next_action
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      How the buyer completes the challenge, when one is outstanding.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        expires_at
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      When the intent expires (ISO-8601 UTC).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        voided_at
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      When the intent was voided (ISO-8601 UTC), or null.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        created_at
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      When the payment intent was created (ISO-8601 UTC).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        resource_version
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      A number that goes up on every change.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        attempt
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      The most recent attempt.
    </td>
  </tr>
</tbody>
</table>

## Status codes

<table>
<thead>
  <tr>
    <th>
      Status
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        201
      </code>
    </td>
    
    <td>
      Created
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        400
      </code>
    </td>
    
    <td>
      Invalid purpose/amount/payment-method combination, a currency the business does not bill in, a gateway refusal, or no eligible gateway
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        404
      </code>
    </td>
    
    <td>
      No such business
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      Idempotency-Key conflict — the key is already in flight, or was reused with a different request payload.
    </td>
  </tr>
</tbody>
</table>
</template>

<template v-slot:request="">

```bash [Request]
curl -X POST "$TMBILLING_URL/v1/businesses/biz_XXXXXXXXXXXX01/payment_intents" \
  -H "Authorization: Bearer $TMBILLING_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "amount_minor": 2900,
    "currency": "USD"
  }'
```

</template>

<template v-slot:response="">
<code-group>

```json [201 Created]
{
  "object": "payment_intent",
  "id": "pi_XXXXXXXXXXXX01",
  "status": "inited",
  "purpose": "payment",
  "amount_minor": 2900,
  "max_amount_minor": 2900,
  "currency": "USD",
  "attempt_count": 0,
  "last_attempt_status": "inited",
  "next_action": {
    "mode": "redirect",
    "approvalUrl": "ApprovalUrl",
    "clientSecret": "ClientSecret",
    "publishableKey": "PublishableKey",
    "checkout": {},
    "sdk": {
      "provider": "stripe",
      "params": {}
    },
    "formPost": {
      "action": "https://example.com/webhooks/billing",
      "fields": {}
    }
  },
  "expires_at": "2026-04-14T09:30:00Z",
  "voided_at": null,
  "created_at": "2026-03-14T09:30:00Z",
  "resource_version": 1,
  "attempt": {
    "object": "payment_attempt",
    "id": "pia_XXXXXXXXXXXX01",
    "attempt_number": 0,
    "status": "inited",
    "id_at_gateway": "pi_XXXXXXXXXXXX01",
    "error_code": null,
    "error_text": null,
    "trace_id": "3f6c1b9e-8a2d-4c5e-9f10-2b7d4e6a8c01",
    "span_id": "Span id",
    "created_at": "2026-03-14T09:30:00Z",
    "updated_at": "2026-03-14T09:30:00Z",
    "resource_version": 1
  }
}
```

```json [400 Bad Request]
{
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid purpose/amount/payment-method combination, a currency the business does not bill in, a gateway refusal, or no eligible gateway"
  }
}
```

```json [404 Not Found]
{
  "error": {
    "type": "invalid_request_error",
    "message": "No such business"
  }
}
```

```json [409 Conflict]
{
  "error": {
    "type": "idempotency_error",
    "message": "Idempotency-Key conflict — the key is already in flight, or was reused with a different request payload."
  }
}
```

</code-group>
</template>
</api-operation>


## Sitemap

See the full [sitemap](https://twominutebilling.com/sitemap.md) for all pages.
