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

# Charge a customer

> Charge a customer's saved card an amount you set, for a product with Auto top-ups switched on.

Charges the card a customer saved at checkout, plus tax. Creem opens an order for the product, charges the card and answers with the result. See [Card-on-file Charges](https://docs.creem.io/features/card-on-file-charges.md) for how a card gets saved.

> [!NOTE]
>
> **When this works.** Card-on-file charges must be enabled for your store, the product must have
> Auto top-ups switched on, and the customer must have paid for an Auto top-ups product through a
> Creem checkout with a card. Cards saved by a subscription checkout can't be charged yet. Otherwise
> the request is refused and nothing is charged.

```typescript TypeScript theme={null}
const response = await fetch("https://api.creem.io/v1/customers/cust_123/charge", {
  method: "POST",
  headers: {
    "x-api-key": process.env.CREEM_API_KEY!,
    "Content-Type": "application/json",
    "Idempotency-Key": "topup_cust_123_0001",
  },
  body: JSON.stringify({
    product_id: "prod_topups",
    currency: "USD",
    amount: 2000,
    credits: { amount: "2000" },
  }),
});
const charge = await response.json();
```

```bash API theme={null}
curl -X POST https://api.creem.io/v1/customers/cust_123/charge \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: topup_cust_123_0001" \
  -d '{
    "product_id": "prod_topups",
    "currency": "USD",
    "amount": 2000,
    "credits": { "amount": "2000" }
  }'
```

## Authorization

**x-api-key** `string` *required*

Your store's API key. A key with granular scopes needs `saved-card-charges:write`.

**Idempotency-Key** `string` *required*

A unique key per charge. Sending the same key again returns the same charge and never charges
twice. Reusing a key with a different body returns `409 idempotency_key_reused`.

## Path parameters

**customer\_id** `string` *required*

The Creem customer ID, for example `cust_123`.

## Body

**product\_id** `string` *required*

The product to charge for. It must be a one-time product with a fixed price and Auto top-ups
switched on.

**currency** `string` *required*

Three-letter currency code, for example `USD`. It must be the currency of the product's price.

**amount** `integer` *required*

The amount before tax, in the smallest currency unit. `2000` is \$20.00. Minimum `100`, maximum
`99999999`. Tax is added on top.

**credits** `object`

The credits this charge grants once it is paid, instead of the product's own credit grant.
Required when the product grants credits and `amount` is not the product's price.

**properties**

**amount** `string` *required*

A whole number of credits above zero, as a string. For example `"2000"`.

**account\_id** `string`

The customer's credits account that receives the credits, for example `cca_abc123`. Without it,
the credits go to the wallet of the product's credits delivery.

**consent\_id** `string`

The saved card permission to charge under. Leave it out to use the customer's current saved card.

## Response

```json 201 Charged theme={null}
{
  "id": "7c0f6a52-3d1e-4b8a-9f2c-1e5d8a4b6c30",
  "object": "saved_card_charge",
  "state": "charged",
  "customer_id": "cust_123",
  "consent_id": "2b9e4d17-8a6c-4f3e-b1d2-5c7a9e0f3b48",
  "product_price_id": "pprice_6hJx3VnR8kWcT1yMbQ5uZa",
  "price_amount": 2000,
  "tax_amount": 400,
  "amount": 2400,
  "currency": "USD",
  "credits": { "amount": "2000", "account_id": null },
  "order_id": "ord_4aDwWXjMLpes4Kj4XqNnUA",
  "checkout_id": "ch_1kQ7wR3mZpX9vT2yNbE5uA",
  "decline_category": null,
  "created_at": "2026-12-02T14:30:00.000Z",
  "resolved_at": "2026-12-02T14:30:02.000Z"
}
```

**id** `string`

The charge ID.

**state** `string`

`charged`, `declined`, `expired`, or while processing `reserved`, `charging` or `needs_attention`.

**price\_amount** `integer`

The amount you sent, before tax.

**tax\_amount** `integer`

The tax Creem added.

**amount** `integer`

The total charged to the card, tax included.

**credits** `object | null`

The credits you set on the charge, or `null`.

**order\_id** `string | null`

The order the charge created.

**decline\_category** `string | null`

Why nothing was charged, on a `declined` or `expired` charge: `card_declined`,
`card_do_not_retry`, `risk_declined`, `card_unavailable`, `charge_unavailable`, `consent_revoked`
or `product_not_top_up_enabled`.

### Status codes

| Status | Meaning |
| - | - |
| `201` | Charged. The order is paid. |
| `202` | Still processing. Creem settles it; follow it with the endpoint below or wait for the webhook. |
| `402` | Not charged. The charge is `declined` or `expired`; `decline_category` says why. |
| `400` | Invalid request, a missing `Idempotency-Key` (`idempotency_key_required`), or `currency_mismatch`. |
| `403` | `saved_card_charges_unavailable`: card-on-file charges are not enabled for your store. |
| `404` | The customer or product doesn't exist in your store. |
| `409` | `idempotency_key_reused`: the key was already used with a different body. |
| `422` | Refused before anything was charged. See the codes below. |
| `503` | `saved_card_charge_busy` or `tax_quote_unavailable`. Retry with the same `Idempotency-Key`. |

### Refusal codes

A `422` writes nothing and never touches the card. The response carries one of these codes:

| Code | What to do |
| - | - |
| `consent_revoked` | The customer has no card on file for your store any more. Send them a new checkout. |
| `product_not_top_up_enabled` | Switch on Auto top-ups for the product. |
| `card_unavailable` | The saved card can't be used (replaced, expired, or saved by a subscription). Send a new checkout. |
| `card_do_not_retry` | The bank said never to charge this card again. Send the customer a new checkout. |
| `reattempt_limit` | Too many recent declines on this card. Wait before trying again. |
| `over_per_charge_ceiling`, `over_customer_monthly_ceiling`, `over_store_daily_ceiling` | The charge would pass a Creem limit. Charge less, or wait for the window to reset. |
| `credits_required` | The product grants credits and the amount isn't its price. Pass `credits`. |
| `credits_account_required` | The product has no single credits delivery. Pass `credits.account_id`. |
| `credits_account_not_found`, `credits_account_frozen`, `credits_account_closed` | The credits account can't receive credits. |

## Get a card-on-file charge

`GET https://api.creem.io/v1/saved-card-charges/{id}`

Returns a charge as it is now, with the same fields as above. Use it to follow up a `202`. A key with granular scopes needs `saved-card-charges:read`.

```bash theme={null}
curl https://api.creem.io/v1/saved-card-charges/7c0f6a52-3d1e-4b8a-9f2c-1e5d8a4b6c30 \
  -H "x-api-key: YOUR_API_KEY"
```


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