# API reference

Every endpoint of the OnCharge merchant API, generated from the [OpenAPI 3.1 spec](https://oncharge.io/openapi.json) (version 1.0.0). The base URL is `https://app.oncharge.io`. Every request is signed as described in [Authentication & signing](https://oncharge.io/docs/authentication): the `X-Oncharge-Key`, `X-Oncharge-Timestamp` and `X-Oncharge-Signature` headers are required on every call and are not repeated below.

- Amounts are integers in minor units; currencies are ISO 4217 codes.
- Errors are JSON `{ "error": "<code>", "message": "<text>" }`. Every endpoint can also return `401` (authentication: `missing_auth`, `invalid_timestamp`, `timestamp_expired`, `invalid_key`, `invalid_signature`), `403` (`store_inactive`: the store is pending or suspended; `domain_mismatch`), `429` (`rate_limited`), `500` (`internal_error`) and `503` (`service_unavailable`); see [Errors](https://oncharge.io/docs/authentication#errors). Endpoint tables below list only the other statuses.
- Every endpoint accepts an optional `X-Store-Domain` header; if a request carries `Origin`, `Referer` or `X-Store-Domain`, one of them must match a registered store domain.
- Send `Idempotency-Key` on session creation, cancellation and refunds.

## Checkout sessions {#checkout-sessions}

Start a payment and show OnCharge's hosted or embedded checkout.

### Create a checkout session {#createcheckoutsession}

```http
POST /api/v1/checkout/sessions
```

Creates a checkout session for one order or cart. Show the shopper the returned
`iframe_url` (a path on `https://app.oncharge.io`), either embedded in an iframe on one of
your registered domains or as a full-page redirect.

`return_url` must be on one of the store's registered domains. Sessions expire 30 minutes
after creation.

Send an `Idempotency-Key` to make retries safe: while a session created with the same key
is still open (`created` or `pending`) and less than 50 minutes old, the same session is
returned with status 200 instead of a new one.

For physical goods, send `shipping`: OnCharge releases the payout after the carrier
confirms delivery to this address, and the address cannot be changed later. When the
session is for an existing order (`order_id` is given) and the order ships by carrier,
`shipping` is required (`422 shipping_address_required`). A session created from a cart,
before the order exists, may attach the address later with
`POST /api/v1/checkout/sessions/{session_id}/order`; such a response carries
`shipping_required: true`, and tracking for the order is refused until the address is on file.

Card payments are accepted in `USD` only for now (`400 currency_not_supported`).

On a store that sells both shipped and unshipped things, set `requires_shipping` on each
line item: an order with a shipped item is paid out after carrier-confirmed delivery, one
without it 7 days after payment.

A store closed to new payments answers `403 store_checkout_closed`; a session that is already open can then no longer be paid (the checkout shows an error).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `amount` | integer (≥ 1) | Yes | Amount in the currency's minor unit (cents for USD). |
| `currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `reference` | string (min 1 chars, max 255 chars) | Yes | Your reference for this payment (order number or cart ID). Returned in webhooks. |
| `return_url` | string (uri) | Yes | Where the shopper is sent after checkout. Must be on a registered store domain. |
| `order_id` | string (max 255 chars) | No | Your order ID, if the order already exists. Otherwise attach it later. |
| `customer_email` | string (email) | No |  |
| `customer_phone` | string | No | E.164 format recommended (`+15551234567`). |
| `metadata` | object | No | Your own key-value data, stored with the session. |
| `shipping` | object | No | Where the order ships. OnCharge matches the carrier's delivery location against `postal_code` (US, first five digits) or `city` + `state`. Send at least `postal_code` or `city`.  |
| `shipping.name` | string (max 200 chars) | No |  |
| `shipping.line1` | string (max 300 chars) | No |  |
| `shipping.line2` | string (max 300 chars) | No |  |
| `shipping.city` | string (max 120 chars) | No |  |
| `shipping.state` | string (max 120 chars) | No |  |
| `shipping.postal_code` | string (max 20 chars) | No |  |
| `shipping.country` | string (max 60 chars) | No | ISO 3166-1 alpha-2 code recommended (`US`). |
| `line_items` | array of object | No |  |
| `line_items[].description` | string | Yes |  |
| `line_items[].quantity` | integer (≥ 1) | Yes |  |
| `line_items[].amount_including_tax` | integer (≥ 0) | Yes | Line amount in minor units, tax included. |
| `line_items[].requires_shipping` | boolean | No | Whether this item is shipped. On a store that sells both shipped and unshipped things, an order with any shipped item is paid out after carrier-confirmed delivery; one whose items all say `false`, 7 days after payment. Without it, the order is decided by whether it has a shipping address. |
| `line_items[].tax_category` | one of `general_goods`, `nontaxable`, `services`, `electronic_services`, `clothing`, `software_download`, `saas`, `books`, `ebooks`, `music_download`, `dietary_supplements`, `otc_drugs`, `cosmetics`, `candy`, `groceries`, `prepared_food`, `pet_food`, `gift_cards` | No | An OnCharge product tax category. |
| `customer_id` | string (uuid) | No | Your OnCharge customer (POST /api/v1/customers): the payment is theirs, and a card they choose to save is saved for them. |
| `save_card` | boolean | No | Offer the shopper to save their card for your store: a box they must tick (card payments on stores with their own card account). Charge the saved card later with POST /api/v1/customers/{customer_id}/charges. Needs `customer_id` or `customer_email`. Default `false`. |
| `tax` | object | No | Sales tax for this payment, when your store has it on (Settings → Sales tax). With `enabled`, `amount` is the order as you list it (before tax, unless your store lists prices with tax included); line items (`amount_including_tax` is then each line's total as listed) and `shipping_amount` must add up to it. Tax is calculated for the shipping address, or `billing_address` when nothing ships. See /docs/sales-tax. |
| `tax.enabled` | boolean | Yes | Calculate sales tax. Store plugins that already add their platform's tax should leave this off. |
| `tax.shipping_amount` | integer (≥ 0) | No | The shipping charge inside `amount`, minor units: taxed as shipping. |
| `tax.billing_address` | object | No |  |
| `tax.billing_address.line1` | string (max 300 chars) | No |  |
| `tax.billing_address.line2` | string (max 300 chars) | No |  |
| `tax.billing_address.city` | string (max 120 chars) | No |  |
| `tax.billing_address.state` | string (max 120 chars) | No | Two-letter US state (or its name). |
| `tax.billing_address.postal_code` | string (max 20 chars) | Yes | Five-digit US ZIP code (ZIP+4 accepted). |
| `tax.billing_address.country` | string (max 60 chars) | No | US only for now. Defaults to US. |

```json title="Request"
{
  "amount": 4900,
  "currency": "USD",
  "reference": "order-1001",
  "return_url": "https://shop.example.com/checkout/complete?order=1001",
  "order_id": "1001",
  "customer_email": "shopper@example.com",
  "shipping": {
    "name": "Alex Rivera",
    "line1": "500 Market St",
    "city": "San Francisco",
    "state": "CA",
    "postal_code": "94105",
    "country": "US"
  },
  "line_items": [
    {
      "description": "Example product",
      "quantity": 1,
      "amount_including_tax": 4900
    }
  ]
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `status` | one of `created`, `pending`, `authorized`, `captured`, `refused`, `cancelled`, `error`, `expired` | Yes | `created` (waiting for the shopper), `pending` (the shopper must complete a step), `authorized` (approved, not yet captured), `captured` (paid), `refused` (declined), `cancelled`, `error`, `expired` (not paid within 30 minutes).  |
| `iframe_url` | string | Yes | Path of the checkout page relative to `https://app.oncharge.io`, including the pay token. Prefix it with the API base URL to get the full checkout URL.  |
| `pay_token` | string | Yes | Short-lived token (30 minutes) that authorizes the checkout page. Already included in `iframe_url`. |
| `created_at` | string (date-time) | Yes |  |
| `expires_at` | string (date-time) | Yes |  |
| `shipping_required` | boolean | No | Present (true) when the order ships by carrier and has no shipping address yet. Attach it with `POST /api/v1/checkout/sessions/{session_id}/order`; tracking is refused until it is on file. |
| `amount` | integer | No | With sales tax: what the shopper pays (the calculated total, once the address is known). |
| `tax` | object or null | No | Sales tax on a payment; null when it is not taxed. |
| `tax.status` | one of `awaiting_address`, `calculated`, `pending`, `failed`, `collected`, `partly_refunded`, `refunded` | Yes | `awaiting_address`: no address yet, the payment waits. `calculated`: not paid yet. `pending`: tax included, charged while the calculation was unavailable; worked out shortly. `failed`: the calculation failed (`error`), the payment waits. `collected`, `partly_refunded`, `refunded`: paid, and how much of the tax was given back. |
| `tax.inclusive` | boolean | Yes | true when the listed prices include the tax. |
| `tax.currency` | string or null | Yes |  |
| `tax.subtotal` | integer or null | Yes | Before tax, minor units. |
| `tax.amount` | integer or null | Yes | The tax, minor units. |
| `tax.total` | integer or null | Yes | What the customer pays, minor units. |
| `tax.shipping` | integer | Yes | The shipping charge inside the total, minor units. |
| `tax.jurisdictions` | array of object | Yes |  |
| `tax.jurisdictions[].state` | string or null | No |  |
| `tax.jurisdictions[].rate` | string | No | Combined percent, e.g. "8.25". |
| `tax.jurisdictions[].amount` | integer | No |  |
| `tax.refunded` | integer | Yes | Tax given back so far with refunds and lost disputes, minor units. |
| `tax.error` | string or null | Yes | `tax_address_invalid` or `tax_unavailable` when `status` is `failed`. |

```json title="Response"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "status": "created",
  "iframe_url": "/checkout/8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11?token=pt_eyJzZXNzaW9uSWQiOi4uLn0.3f9c",
  "pay_token": "pt_eyJzZXNzaW9uSWQiOi4uLn0.3f9c",
  "created_at": "2026-01-01T00:00:00.000Z",
  "expires_at": "2026-01-01T00:30:00.000Z"
}
```

| Status | Meaning |
|---|---|
| `200` | Idempotent replay: an open session created with the same `Idempotency-Key` within the last 50 minutes. A fresh `pay_token` is issued. |
| `201` | Session created. |
| `400` | `validation_error`, `invalid_json`, `invalid_return_url` (the return URL is not on a registered store domain), `no_domains` (the store has no registered domain) or `currency_not_supported` (card payments are accepted in USD only). |
| `403` | `store_inactive` (the store is not active yet, for example while its processing account is being opened, or it is suspended), `store_checkout_closed` (OnCharge has closed the store to new payments, for example while the account is being offboarded; shipments and refunds still work), `domain_mismatch`, or `global_ban` (the shopper's email or phone is blocked across OnCharge; show the `message` to the shopper and do not retry). |
| `422` | `shipping_address_required`: the order ships by carrier and `order_id` was given, but no `shipping` address (postal code or city). The order is paid out only after the carrier confirms delivery to that address. Show the `message` to the shopper. |

### Retrieve a checkout session {#getcheckoutsession}

```http
GET /api/v1/checkout/sessions/{session_id}
```

Returns the session's current status. Use it to confirm a payment server-side (for
example when the shopper lands on your `return_url`) in addition to webhooks.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `session_id` | path | string (uuid) | Yes | The checkout session ID returned when the session was created. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `order_id` | string or null | No |  |
| `amount` | integer (≥ 1) | Yes | Amount in the currency's minor unit (cents for USD). |
| `currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `status` | one of `created`, `pending`, `authorized`, `captured`, `refused`, `cancelled`, `error`, `expired` | Yes | `created` (waiting for the shopper), `pending` (the shopper must complete a step), `authorized` (approved, not yet captured), `captured` (paid), `refused` (declined), `cancelled`, `error`, `expired` (not paid within 30 minutes).  |
| `payment_reference` | string | Yes | OnCharge's reference for the payment: `ocpay_` and the session id in lowercase hex without dashes, for every session. Never a payment processor id. |
| `psp_reference` | string or null | No | Kept with its meaning for existing integrations: for a session created before the reference cutoff (2026-12-01T00:00:00Z by default; see the OnCharge references guide), its original payment reference (null before payment); for a session created at or after it, the same `ocpay_` reference as `payment_reference`. New integrations should read `payment_reference`. **Deprecated.** |
| `payment_method` | one of `card`, `bank_debit`, `cash_app_pay`, `klarna`, `affirm`, `afterpay`, or `null` | No | How the shopper paid: `card`, or a way to pay beyond cards the store turned on (bank debit, Cash App Pay, Klarna, Affirm, Afterpay; see the Payment methods guide). Null for crypto. |
| `settlement` | one of `verify_deposits`, `processing`, `settled`, or `null` | No | A bank debit's collection: `verify_deposits` while the shopper confirms their account with the test deposits, `processing` while the debit is collected (up to 4 business days), `settled` once it cleared. Null for every other method. Ship once `status` is `captured`. |
| `risk_decision` | one of `accept`, `review`, `reject`, or `null` | No | Outcome of the checkout risk check. |
| `risk_score` | number or null | No | Risk score 0–100. |
| `created_at` | string (date-time) | Yes |  |
| `updated_at` | string (date-time) | Yes |  |
| `expires_at` | string (date-time) | Yes |  |
| `tax` | object or null | No | Sales tax on a payment; null when it is not taxed. |
| `tax.status` | one of `awaiting_address`, `calculated`, `pending`, `failed`, `collected`, `partly_refunded`, `refunded` | Yes | `awaiting_address`: no address yet, the payment waits. `calculated`: not paid yet. `pending`: tax included, charged while the calculation was unavailable; worked out shortly. `failed`: the calculation failed (`error`), the payment waits. `collected`, `partly_refunded`, `refunded`: paid, and how much of the tax was given back. |
| `tax.inclusive` | boolean | Yes | true when the listed prices include the tax. |
| `tax.currency` | string or null | Yes |  |
| `tax.subtotal` | integer or null | Yes | Before tax, minor units. |
| `tax.amount` | integer or null | Yes | The tax, minor units. |
| `tax.total` | integer or null | Yes | What the customer pays, minor units. |
| `tax.shipping` | integer | Yes | The shipping charge inside the total, minor units. |
| `tax.jurisdictions` | array of object | Yes |  |
| `tax.jurisdictions[].state` | string or null | No |  |
| `tax.jurisdictions[].rate` | string | No | Combined percent, e.g. "8.25". |
| `tax.jurisdictions[].amount` | integer | No |  |
| `tax.refunded` | integer | Yes | Tax given back so far with refunds and lost disputes, minor units. |
| `tax.error` | string or null | Yes | `tax_address_invalid` or `tax_unavailable` when `status` is `failed`. |

```json title="Response"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "order_id": "string",
  "amount": 4900,
  "currency": "USD",
  "status": "created",
  "payment_reference": "ocpay_3f2a9c1e0b7d4e6f8a1b2c3d4e5f6a7b",
  "psp_reference": "string",
  "payment_method": "card",
  "settlement": "verify_deposits",
  "risk_decision": "accept",
  "risk_score": 0,
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z",
  "expires_at": "2026-01-01T00:00:00.000Z",
  "tax": {
    "status": "awaiting_address",
    "inclusive": true,
    "currency": "string",
    "subtotal": 0,
    "amount": 0,
    "total": 0,
    "shipping": 0,
    "jurisdictions": [
      {
        "state": "string",
        "rate": "string",
        "amount": 0
      }
    ],
    "refunded": 0,
    "error": "string"
  }
}
```

| Status | Meaning |
|---|---|
| `200` | The session. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Attach your order to a session {#attachorder}

```http
POST /api/v1/checkout/sessions/{session_id}/order
```

For sessions created from a cart before your order existed: records your `order_id` and
the shipping destination. Each value is set once; later calls do not overwrite it.

The shipping address is recorded only if the session has none yet, no tracking number has
been reported, and the session is less than 24 hours old. Check `shipping_recorded` and
`shipping_on_file` in the response.

An order that ships by carrier is paid out only after delivery to its shipping address. If
it is attached without one and none is on file, the `order_id` is still recorded and the
response is `422 shipping_address_required`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `session_id` | path | string (uuid) | Yes | The checkout session ID returned when the session was created. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `order_id` | string (min 1 chars, max 255 chars) | No |  |
| `shipping` | object | No | Where the order ships. OnCharge matches the carrier's delivery location against `postal_code` (US, first five digits) or `city` + `state`. Send at least `postal_code` or `city`.  |
| `shipping.name` | string (max 200 chars) | No |  |
| `shipping.line1` | string (max 300 chars) | No |  |
| `shipping.line2` | string (max 300 chars) | No |  |
| `shipping.city` | string (max 120 chars) | No |  |
| `shipping.state` | string (max 120 chars) | No |  |
| `shipping.postal_code` | string (max 20 chars) | No |  |
| `shipping.country` | string (max 60 chars) | No | ISO 3166-1 alpha-2 code recommended (`US`). |

```json title="Request"
{
  "order_id": "1001",
  "shipping": {
    "name": "Alex Rivera",
    "line1": "500 Market St",
    "city": "San Francisco",
    "state": "CA",
    "postal_code": "94105",
    "country": "US"
  }
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `order_id` | string or null | Yes |  |
| `shipping_recorded` | boolean | Yes | true if this call recorded the shipping address. |
| `shipping_on_file` | boolean | Yes | true if the session has a shipping destination (from this or an earlier call). |
| `amount` | integer | No | With sales tax: the total now that the address is known. |
| `tax` | object or null | No | Sales tax on a payment; null when it is not taxed. |
| `tax.status` | one of `awaiting_address`, `calculated`, `pending`, `failed`, `collected`, `partly_refunded`, `refunded` | Yes | `awaiting_address`: no address yet, the payment waits. `calculated`: not paid yet. `pending`: tax included, charged while the calculation was unavailable; worked out shortly. `failed`: the calculation failed (`error`), the payment waits. `collected`, `partly_refunded`, `refunded`: paid, and how much of the tax was given back. |
| `tax.inclusive` | boolean | Yes | true when the listed prices include the tax. |
| `tax.currency` | string or null | Yes |  |
| `tax.subtotal` | integer or null | Yes | Before tax, minor units. |
| `tax.amount` | integer or null | Yes | The tax, minor units. |
| `tax.total` | integer or null | Yes | What the customer pays, minor units. |
| `tax.shipping` | integer | Yes | The shipping charge inside the total, minor units. |
| `tax.jurisdictions` | array of object | Yes |  |
| `tax.jurisdictions[].state` | string or null | No |  |
| `tax.jurisdictions[].rate` | string | No | Combined percent, e.g. "8.25". |
| `tax.jurisdictions[].amount` | integer | No |  |
| `tax.refunded` | integer | Yes | Tax given back so far with refunds and lost disputes, minor units. |
| `tax.error` | string or null | Yes | `tax_address_invalid` or `tax_unavailable` when `status` is `failed`. |

```json title="Response"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "order_id": "string",
  "shipping_recorded": true,
  "shipping_on_file": true,
  "amount": 0,
  "tax": {
    "status": "awaiting_address",
    "inclusive": true,
    "currency": "string",
    "subtotal": 0,
    "amount": 0,
    "total": 0,
    "shipping": 0,
    "jurisdictions": [
      {
        "state": "string",
        "rate": "string",
        "amount": 0
      }
    ],
    "refunded": 0,
    "error": "string"
  }
}
```

| Status | Meaning |
|---|---|
| `200` | What is on file for the session now. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `session_not_found`: no such session for this store. |
| `422` | `shipping_address_required`: the order ships by carrier and no shipping address is on file (none was sent, or it can no longer be recorded). |

### Cancel an authorized payment {#cancelcheckoutsession}

```http
POST /api/v1/checkout/sessions/{session_id}/cancel
```

Cancels a payment that is `authorized` but not yet captured. Captured payments must be
refunded instead. Send an empty body (`""`) and sign it as such.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `session_id` | path | string (uuid) | Yes | The checkout session ID returned when the session was created. |
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `status` | `"cancelled"` | Yes |  |
| `psp_reference` | string | No | Opaque reference of the cancellation. |

```json title="Response"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "status": "cancelled",
  "psp_reference": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The payment was cancelled. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invalid_state` (only `authorized` sessions can be cancelled) or `missing_psp_ref`. |
| `502` | `provider_error` or `provider_unavailable`: the payment network did not accept the request. Retry later. |

## Shipments {#shipments}

Report carrier tracking so delivered orders are paid out.

### Report tracking numbers for a paid order {#reportshipments}

```http
POST /api/v1/shipments
```

Reports the carrier and tracking number(s) a paid order shipped with. OnCharge confirms
delivery with the carrier and pays the order out once every package is delivered to the
order's shipping address.

Identify the order by `session_id` or by your `order_id` (the latest captured session with
that order ID). Supported carriers: USPS, UPS, FedEx and DHL Express, by name or by the
codes shipping tools use (e.g. `ups_walleted`, `stamps_com`, `fedex_ground`). `carrier` may be
omitted, or be one OnCharge does not recognise, when the tracking number's format identifies
the carrier (UPS `1Z…`, USPS IMpb/S10; FedEx and DHL Express numbers when no carrier is given). Reporting a number that is already on the order again is harmless. Each
tracking number is accepted or rejected individually.

To replace a tracking number (the package was lost, returned, or the label cancelled, and the
order was shipped again), name it in `replaces`. Without `replaces`, a new number replaces
every package of the order that has a problem. A replaced number stays tied to the order.

An order that is not confirmed delivered is refunded to the shopper automatically: 30 days
after payment with no tracking, 45 days with no confirmed delivery (`delivery.auto_refund_at`).

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `session_id` | string (uuid) | No |  |
| `order_id` | string (min 1 chars, max 255 chars) | No |  |
| `shipments` | array of object (≥ 1 items, ≤ 10 items) | Yes |  |
| `shipments[].carrier` | string or null (max 60 chars) | No | USPS, UPS, FedEx or DHL Express, or a shipping tool's code for one. Optional when the tracking number format identifies the carrier. |
| `shipments[].tracking_number` | string (min 1 chars, max 80 chars) | Yes | Spaces and dashes are ignored; 8–40 letters and digits after normalization. |
| `shipments[].replaces` | string or null (max 80 chars) | No | The tracking number (or shipment id) on this order that this one replaces. |

```json title="Request"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "shipments": [
    {
      "carrier": "ups",
      "tracking_number": "1Z999AA10123456784"
    }
  ]
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `shipments` | array of object | Yes |  |
| `shipments[].tracking_number` | string | Yes |  |
| `shipments[].carrier` | one of `usps`, `ups`, `fedex`, `dhl_express` | No | Normalized carrier. Common spellings are accepted on input (`USPS`, `United States Postal Service`, `UPS`, `FedEx`, `FedEx Ground`, `DHL`, `DHL Express`, …).  |
| `shipments[].status` | one of `accepted`, `rejected` | Yes |  |
| `shipments[].error` | one of `carrier_not_supported`, `tracking_number_invalid`, `carrier_mismatch`, `tracking_number_in_use`, `too_many_shipments`, `replacement_not_found`, `replacement_not_allowed` | No |  |
| `shipments[].message` | string | No |  |
| `shipments[].replaced` | array of string | No | Tracking numbers this one replaced. |
| `delivery` | object | Yes |  |
| `delivery.state` | one of `not_tracked`, `awaiting_shipment`, `in_transit`, `delivered`, `on_hold`, `refunded` | Yes | `not_tracked` (no delivery tracking for this order, e.g. digital goods, or not paid yet), `awaiting_shipment`, `in_transit`, `delivered` (confirmed; payout released on schedule), `on_hold` (see `hold_reason`), `refunded`.  |
| `delivery.hold_reason` | string or null | Yes |  |

```json title="Response"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "shipments": [
    {
      "tracking_number": "1Z999AA10123456784",
      "carrier": "ups",
      "status": "accepted"
    }
  ],
  "delivery": {
    "state": "in_transit",
    "hold_reason": null
  }
}
```

| Status | Meaning |
|---|---|
| `200` | Per-number results and the order's delivery state. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `session_not_found`: no such order for this store. |
| `409` | `order_not_paid`: tracking can be added once the order has been paid. `order_refunded`: the order was refunded in full. |
| `422` | `shipping_address_missing`: the order ships by carrier but has no shipping address, so its delivery cannot be confirmed. |

### Get an order's delivery status {#getdeliverystatus}

```http
GET /api/v1/shipments
```

The order's delivery state and every reported tracking number with the carrier's result.
The query string is not part of the signature: sign the path `/api/v1/shipments`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `session_id` | query | string (uuid) | Yes | The checkout session ID. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `delivery` | object | Yes |  |
| `delivery.state` | one of `not_tracked`, `awaiting_shipment`, `in_transit`, `delivered`, `on_hold`, `refunded` | Yes | `not_tracked` (no delivery tracking for this order, e.g. digital goods, or not paid yet), `awaiting_shipment`, `in_transit`, `delivered` (confirmed; payout released on schedule), `on_hold` (see `hold_reason`), `refunded`.  |
| `delivery.hold_reason` | string or null | Yes | Plain-language reason when `state` is `on_hold`. |
| `delivery.delivered_at` | string (date-time) or null | Yes | When the last package was confirmed delivered. |
| `delivery.shipments` | array of object | Yes |  |
| `delivery.shipments[].id` | string (uuid) | Yes |  |
| `delivery.shipments[].carrier` | one of `usps`, `ups`, `fedex`, `dhl_express` | Yes | Normalized carrier. Common spellings are accepted on input (`USPS`, `United States Postal Service`, `UPS`, `FedEx`, `FedEx Ground`, `DHL`, `DHL Express`, …).  |
| `delivery.shipments[].carrier_label` | string | Yes |  |
| `delivery.shipments[].tracking_number` | string | Yes |  |
| `delivery.shipments[].status` | one of `pending`, `pre_transit`, `in_transit`, `out_for_delivery`, `delivered`, `available_for_pickup`, `return_to_sender`, `failure`, `cancelled`, `unknown` | Yes | Latest carrier status. |
| `delivery.shipments[].result` | one of `checking`, `confirmed`, `problem`, `replaced` | Yes | `confirmed` when delivery to the order address is verified; `problem` lists reasons in `problems` (re-ship and replace the number, or refund); `replaced` when another number took its place. |
| `delivery.shipments[].problems` | array of string | Yes |  |
| `delivery.shipments[].delivered_at` | string (date-time) or null | No |  |
| `delivery.shipments[].delivered_to` | string or null | No | City, state and postal code the carrier reported. |
| `delivery.shipments[].note` | string or null | No |  |
| `delivery.shipments[].removable` | boolean | Yes |  |
| `delivery.shipments[].created_at` | string (date-time) | Yes |  |
| `delivery.shipments[].replaceable` | boolean | No |  |
| `delivery.shipments[].replaced_by` | string (uuid) or null | No |  |
| `delivery.action_required` | string or null | No | What to do now, if anything (add tracking, re-ship or refund). |
| `delivery.auto_refund_at` | string (date-time) or null | No | When the shopper is refunded in full automatically if the order is still not confirmed delivered. |
| `delivery.can_add_tracking` | boolean | No |  |
| `delivery.shipping_address_missing` | boolean | No |  |

```json title="Response"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "delivery": {
    "state": "not_tracked",
    "hold_reason": "string",
    "delivered_at": "2026-01-01T00:00:00.000Z",
    "shipments": [
      {
        "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
        "carrier": "usps",
        "carrier_label": "UPS",
        "tracking_number": "string",
        "status": "pending",
        "result": "checking",
        "problems": [
          null
        ],
        "delivered_at": "2026-01-01T00:00:00.000Z",
        "delivered_to": "string",
        "note": "string",
        "removable": true,
        "created_at": "2026-01-01T00:00:00.000Z",
        "replaceable": true,
        "replaced_by": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11"
      }
    ],
    "action_required": "string",
    "auto_refund_at": "2026-01-01T00:00:00.000Z",
    "can_add_tracking": true,
    "shipping_address_missing": true
  }
}
```

| Status | Meaning |
|---|---|
| `200` | Delivery status. |
| `400` | `invalid_request`: `session_id` is missing or not a UUID. |
| `404` | `session_not_found`: no such order for this store. |

## Refunds {#refunds}

Refund captured payments.

### Refund a captured payment {#createrefund}

```http
POST /api/v1/refunds
```

Refunds all or part of a `captured` payment. Always send an `Idempotency-Key` (for example
your refund ID) so a retried request cannot refund twice: a repeat with the same key
returns the first refund with `idempotent: true`.

The final outcome arrives as a `refund.succeeded` webhook.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `amount` | integer (≥ 1) | Yes | Amount in the currency's minor unit (cents for USD). |
| `currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `reference` | string (max 255 chars) | No | Your reference for the refund. |

```json title="Request"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "amount": 1500,
  "currency": "USD",
  "reference": "refund-1001-1"
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `refund_id` | string | Yes |  |
| `session_id` | string (uuid) | Yes |  |
| `status` | one of `refund_requested`, `refunded` | Yes | `refunded` if already complete, otherwise `refund_requested` until the `refund.succeeded` webhook. |
| `amount` | integer (≥ 1) | Yes | Amount in the currency's minor unit (cents for USD). |
| `currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |

```json title="Response"
{
  "refund_id": "string",
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "status": "refund_requested",
  "amount": 4900,
  "currency": "USD"
}
```

| Status | Meaning |
|---|---|
| `200` | Idempotent replay of an earlier refund with the same `Idempotency-Key`. |
| `201` | Refund requested. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invalid_state`: only `captured` payments can be refunded (cancel `authorized` ones), or `missing_psp_ref`. |
| `502` | `provider_error` or `provider_unavailable`: the payment network did not accept the request. Retry later. |

## Disputes {#disputes}

Read and respond to disputes (chargebacks).

### List disputes {#listdisputes}

```http
GET /api/v1/disputes
```

The store's 50 most recent disputes, newest first.

Newest first, paged by cursor: pass `next_cursor` back as `cursor`. Filters are optional.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `status` | query | one of `open`, `won`, `lost` | No |  |
| `reason` | query | one of `fraudulent`, `product_not_received`, `product_unacceptable`, `duplicate`, `subscription_canceled`, `credit_not_processed`, `unrecognized`, `general` | No |  |
| `due_before` | query | string (date) | No | Evidence due on or before this day (UTC). |
| `from` | query | string (date) | No | Opened on or after this day (UTC). |
| `to` | query | string (date) | No | Opened on or before this day (UTC). |
| `min` | query | string | No | Smallest amount, in major units. |
| `max` | query | string | No | Largest amount, in major units. |
| `q` | query | string | No | A dispute or payment reference, a dispute id, or an order number. |
| `limit` | query | integer | No |  |
| `cursor` | query | string | No | `next_cursor` of the previous page. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `disputes` | array of object | Yes |  |
| `disputes[].id` | string (uuid) | Yes |  |
| `disputes[].reference` | string | No | OnCharge's reference for the dispute (`ocdsp_` and its id in hex). |
| `disputes[].store_id` | string (uuid) | Yes |  |
| `disputes[].session_id` | string (uuid) or null | Yes | The checkout session of the disputed payment. |
| `disputes[].merchant_reference` | string or null | Yes | Your own order reference. |
| `disputes[].payment_reference` | string or null | Yes | Kept with its meaning for existing integrations: for a payment created before the reference cutoff (2026-12-01T00:00:00Z by default; see the OnCharge references guide), the payment reference this field always carried; for a payment created at or after it, the payment's `ocpay_` reference. New integrations should read `oncharge_payment_reference`. |
| `disputes[].oncharge_payment_reference` | string or null | No | The disputed payment's OnCharge reference (`ocpay_…`), for every dispute; the same as the checkout session's `payment_reference`. Null when no payment is linked. |
| `disputes[].original_amount` | integer or null | Yes | Amount of the original payment, minor units. |
| `disputes[].dispute_amount` | integer or null | Yes | Disputed amount, minor units. |
| `disputes[].currency` | string or null | Yes |  |
| `disputes[].reason` | string or null | Yes |  |
| `disputes[].reason_label` | string | No | The reason in plain words. |
| `disputes[].reason_code` | string or null | Yes |  |
| `disputes[].status` | one of `notification_of_chargeback`, `chargeback`, `second_chargeback`, `prearbitration`, `defense_pending`, `defended`, `accepted`, `won`, `lost` | Yes |  |
| `disputes[].status_label` | string | No | The status in plain words. |
| `disputes[].defense_deadline` | string (date-time) or null | Yes | When evidence must be in. |
| `disputes[].evidence_submitted_at` | string (date-time) or null | Yes |  |
| `disputes[].closed_at` | string (date-time) or null | Yes |  |
| `disputes[].responded_by` | one of `oncharge`, `merchant` | Yes | `oncharge`: the OnCharge team submits the response using the evidence you upload; defend, accept and auto-defend return `409 responded_by_oncharge`. `merchant`: you can defend or accept it through the API. |
| `disputes[].created_at` | string (date-time) | Yes |  |
| `disputes[].updated_at` | string (date-time) | Yes |  |
| `next_cursor` | string or null | No | Pass as `cursor` for the next page; null on the last page. |

```json title="Response"
{
  "disputes": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "reference": "string",
      "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "merchant_reference": "string",
      "payment_reference": "string",
      "oncharge_payment_reference": "string",
      "original_amount": 0,
      "dispute_amount": 0,
      "currency": "string",
      "reason": "string",
      "reason_label": "string",
      "reason_code": "string",
      "status": "notification_of_chargeback",
      "status_label": "string",
      "defense_deadline": "2026-01-01T00:00:00.000Z",
      "evidence_submitted_at": "2026-01-01T00:00:00.000Z",
      "closed_at": "2026-01-01T00:00:00.000Z",
      "responded_by": "oncharge",
      "created_at": "2026-01-01T00:00:00.000Z",
      "updated_at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "next_cursor": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | Disputes. |

### Retrieve a dispute {#getdispute}

```http
GET /api/v1/disputes/{dispute_id}
```

A dispute with the evidence files uploaded for it.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `dispute_id` | path | string (uuid) | Yes |  |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `dispute` | object | Yes | A dispute (chargeback) on one of your payments. |
| `dispute.id` | string (uuid) | Yes |  |
| `dispute.reference` | string | No | OnCharge's reference for the dispute (`ocdsp_` and its id in hex). |
| `dispute.store_id` | string (uuid) | Yes |  |
| `dispute.session_id` | string (uuid) or null | Yes | The checkout session of the disputed payment. |
| `dispute.merchant_reference` | string or null | Yes | Your own order reference. |
| `dispute.payment_reference` | string or null | Yes | Kept with its meaning for existing integrations: for a payment created before the reference cutoff (2026-12-01T00:00:00Z by default; see the OnCharge references guide), the payment reference this field always carried; for a payment created at or after it, the payment's `ocpay_` reference. New integrations should read `oncharge_payment_reference`. |
| `dispute.oncharge_payment_reference` | string or null | No | The disputed payment's OnCharge reference (`ocpay_…`), for every dispute; the same as the checkout session's `payment_reference`. Null when no payment is linked. |
| `dispute.original_amount` | integer or null | Yes | Amount of the original payment, minor units. |
| `dispute.dispute_amount` | integer or null | Yes | Disputed amount, minor units. |
| `dispute.currency` | string or null | Yes |  |
| `dispute.reason` | string or null | Yes |  |
| `dispute.reason_label` | string | No | The reason in plain words. |
| `dispute.reason_code` | string or null | Yes |  |
| `dispute.status` | one of `notification_of_chargeback`, `chargeback`, `second_chargeback`, `prearbitration`, `defense_pending`, `defended`, `accepted`, `won`, `lost` | Yes |  |
| `dispute.status_label` | string | No | The status in plain words. |
| `dispute.defense_deadline` | string (date-time) or null | Yes | When evidence must be in. |
| `dispute.evidence_submitted_at` | string (date-time) or null | Yes |  |
| `dispute.closed_at` | string (date-time) or null | Yes |  |
| `dispute.responded_by` | one of `oncharge`, `merchant` | Yes | `oncharge`: the OnCharge team submits the response using the evidence you upload; defend, accept and auto-defend return `409 responded_by_oncharge`. `merchant`: you can defend or accept it through the API. |
| `dispute.created_at` | string (date-time) | Yes |  |
| `dispute.updated_at` | string (date-time) | Yes |  |
| `evidence` | array of object | Yes |  |
| `evidence[].id` | string (uuid) | Yes |  |
| `evidence[].doc_type` | string | Yes |  |
| `evidence[].filename` | string or null | Yes |  |
| `evidence[].uploaded_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "dispute": {
    "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "reference": "string",
    "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "merchant_reference": "string",
    "payment_reference": "string",
    "oncharge_payment_reference": "string",
    "original_amount": 0,
    "dispute_amount": 0,
    "currency": "string",
    "reason": "string",
    "reason_label": "string",
    "reason_code": "string",
    "status": "notification_of_chargeback",
    "status_label": "string",
    "defense_deadline": "2026-01-01T00:00:00.000Z",
    "evidence_submitted_at": "2026-01-01T00:00:00.000Z",
    "closed_at": "2026-01-01T00:00:00.000Z",
    "responded_by": "oncharge",
    "created_at": "2026-01-01T00:00:00.000Z",
    "updated_at": "2026-01-01T00:00:00.000Z"
  },
  "evidence": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "doc_type": "string",
      "filename": "string",
      "uploaded_at": "2026-01-01T00:00:00.000Z"
    }
  ]
}
```

| Status | Meaning |
|---|---|
| `200` | The dispute. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Upload dispute evidence {#uploaddisputeevidence}

```http
POST /api/v1/disputes/{dispute_id}/evidence
```

Uploads one evidence document as `multipart/form-data`. **Sign this request with an empty
body**: the body hash in the signing string is the SHA-256 of the empty string
(`e3b0c442…b855`), not of the multipart payload.

Upload evidence for every dispute, including those the OnCharge team responds to (`responded_by: "oncharge"`): the team uses your uploads.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `dispute_id` | path | string (uuid) | Yes |  |

**Request body** (`multipart/form-data`)

| Field | Type | Required | Description |
|---|---|---|---|
| `file` | string (binary) | Yes | The document (PDF or image). |
| `doc_type` | string | Yes | What the document is. |

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `evidence` | object | Yes |  |
| `evidence.id` | string (uuid) | Yes |  |
| `evidence.doc_type` | string | Yes |  |
| `evidence.filename` | string or null | Yes |  |
| `evidence.uploaded_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "evidence": {
    "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "doc_type": "string",
    "filename": "string",
    "uploaded_at": "2026-01-01T00:00:00.000Z"
  }
}
```

| Status | Meaning |
|---|---|
| `201` | Evidence stored. |
| `400` | `missing_field`: `file` and `doc_type` are required. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Accept a dispute {#acceptdispute}

```http
POST /api/v1/disputes/{dispute_id}/accept
```

Concedes the dispute. The disputed amount is not contested. Send an empty body. Disputes with `responded_by: "oncharge"` are answered by the OnCharge team: this returns `409 responded_by_oncharge`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `dispute_id` | path | string (uuid) | Yes |  |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `dispute_id` | string (uuid) | Yes |  |
| `accepted` | boolean | Yes |  |

```json title="Response"
{
  "dispute_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "accepted": true
}
```

| Status | Meaning |
|---|---|
| `200` | Result. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `responded_by_oncharge`: the OnCharge team responds to this dispute for you; upload your evidence before the deadline instead. `missing_ref`: the dispute cannot be answered yet. |
| `502` | `dispute_action_failed`: the action could not be completed right now. Retry later or contact support. |

### Submit a dispute defense {#defenddispute}

```http
POST /api/v1/disputes/{dispute_id}/defend
```

Submits the defense with the evidence already uploaded. Send an empty body. Disputes with `responded_by: "oncharge"` are answered by the OnCharge team: this returns `409 responded_by_oncharge`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `dispute_id` | path | string (uuid) | Yes |  |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `dispute_id` | string (uuid) | Yes |  |
| `defended` | boolean | Yes |  |

```json title="Response"
{
  "dispute_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "defended": true
}
```

| Status | Meaning |
|---|---|
| `200` | Result. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `responded_by_oncharge`: the OnCharge team responds to this dispute for you; upload your evidence before the deadline instead. `missing_ref`: the dispute cannot be answered yet. |
| `502` | `dispute_action_failed`: the action could not be completed right now. Retry later or contact support. |

### Build and submit a defense automatically {#autodefenddispute}

```http
POST /api/v1/disputes/{dispute_id}/auto-defend
```

Builds an evidence packet from the order's checkout records and uploaded evidence and
submits the defense. Send an empty body. Disputes with `responded_by: "oncharge"` are answered by the OnCharge team: this returns `409 responded_by_oncharge`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `dispute_id` | path | string (uuid) | Yes |  |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `dispute_id` | string (uuid) | Yes |  |
| `success` | boolean | Yes |  |
| `message` | string | No | `Defence submitted.` on success, otherwise a neutral explanation. |
| `evidence_count` | integer | No |  |
| `defense_text_preview` | string | No |  |
| `win_probability` | number or null | No |  |
| `ai_recommendation` | string or null | No |  |

```json title="Response"
{
  "dispute_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "success": true,
  "message": "string",
  "evidence_count": 0,
  "defense_text_preview": "string",
  "win_probability": 0,
  "ai_recommendation": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | Result. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `responded_by_oncharge`: the OnCharge team responds to this dispute for you; upload your evidence before the deadline instead. `missing_ref`: the dispute cannot be answered yet. |
| `500` | `build_failed` (the evidence packet could not be built) or `internal_error`. |

## Customers {#customers}

Your store's customers and the cards they saved with you, and charges to a saved card while the customer is away.

### List customers {#listcustomers}

```http
GET /api/v1/customers
```

Your store's customers, newest first, with their totals.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `q` | query | string | No | An OnCharge customer ID, or part of an email, name, phone or your reference. |
| `email` | query | string (email) | No |  |
| `reference` | query | string | No |  |
| `limit` | query | integer | No |  |
| `cursor` | query | string | No | `next_cursor` of the previous page. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `object` | `"list"` | Yes |  |
| `data` | array of object | Yes |  |
| `data[].id` | string (uuid) | Yes |  |
| `data[].object` | `"customer"` | Yes |  |
| `data[].store_id` | string (uuid) | Yes |  |
| `data[].email` | string or null | Yes |  |
| `data[].name` | string or null | Yes |  |
| `data[].phone` | string or null | Yes |  |
| `data[].reference` | string or null | Yes | Your own ID for this customer. |
| `data[].metadata` | object | Yes |  |
| `data[].source` | string | Yes | How OnCharge first met the customer, in plain words. |
| `data[].created_at` | string (date-time) | Yes |  |
| `data[].totals` | object | Yes |  |
| `data[].totals.payments` | integer | Yes | Paid payments. |
| `data[].totals.lifetime_value` | array of object | Yes | What the customer paid, less refunds, per currency. |
| `data[].totals.refunded` | array of object | Yes |  |
| `data[].totals.disputes` | integer | Yes |  |
| `data[].totals.last_payment_at` | string (date-time) or null | Yes |  |
| `data[].payment_methods` | array of object | No | On a single customer: the saved cards that can be charged. |
| `data[].payment_methods[].id` | string (uuid) | Yes |  |
| `data[].payment_methods[].object` | `"payment_method"` | Yes |  |
| `data[].payment_methods[].type` | `"card"` | Yes |  |
| `data[].payment_methods[].brand` | string | Yes |  |
| `data[].payment_methods[].last4` | string | Yes |  |
| `data[].payment_methods[].exp_month` | integer (≥ 1, ≤ 12) | Yes |  |
| `data[].payment_methods[].exp_year` | integer | Yes |  |
| `data[].payment_methods[].funding` | one of `credit`, `debit`, `prepaid`, `unknown`, or `null` | No |  |
| `data[].payment_methods[].country` | string or null | No |  |
| `data[].payment_methods[].wallet` | string or null | No | Apple Pay or Google Pay when the card was saved from one. |
| `data[].payment_methods[].is_default` | boolean | Yes |  |
| `data[].payment_methods[].status` | one of `active`, `removed` | Yes |  |
| `data[].payment_methods[].expired` | boolean | Yes |  |
| `data[].payment_methods[].saved_via` | one of `checkout`, `save_card_page` | Yes |  |
| `data[].payment_methods[].created_at` | string (date-time) | Yes |  |
| `data[].payment_methods[].last_used_at` | string (date-time) or null | No |  |
| `data[].payment_methods[].updated_by_card_network_at` | string (date-time) or null | No | When the card network last sent new details for this card (a renewed or replaced card). |
| `data[].payment_methods[].removed_at` | string (date-time) or null | No |  |
| `data[].saved_cards` | integer | No | In lists: how many saved cards the customer has. |
| `next_cursor` | string or null | Yes |  |

```json title="Response"
{
  "object": "list",
  "data": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "object": "customer",
      "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "email": "string",
      "name": "string",
      "phone": "string",
      "reference": "string",
      "metadata": {},
      "source": "string",
      "created_at": "2026-01-01T00:00:00.000Z",
      "totals": {
        "payments": 0,
        "lifetime_value": [
          null
        ],
        "refunded": [
          null
        ],
        "disputes": 0,
        "last_payment_at": "2026-01-01T00:00:00.000Z"
      },
      "payment_methods": [
        {
          "id": null,
          "object": null,
          "type": null,
          "brand": null,
          "last4": null,
          "exp_month": null,
          "exp_year": null,
          "funding": null,
          "country": null,
          "wallet": null,
          "is_default": null,
          "status": null,
          "expired": null,
          "saved_via": null,
          "created_at": null,
          "last_used_at": null,
          "updated_by_card_network_at": null,
          "removed_at": null
        }
      ],
      "saved_cards": 0
    }
  ],
  "next_cursor": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | A page of customers. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |

### Add a customer {#createcustomer}

```http
POST /api/v1/customers
```

Adds a customer to your store. One email, and one reference, is one customer of a store: a second
is refused with `409 customer_exists` and the existing customer's ID in `customer_id`.

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `email` | string (email) (max 320 chars) | No |  |
| `name` | string (max 200 chars) | No |  |
| `phone` | string (max 40 chars) | No |  |
| `reference` | string (max 255 chars) | No |  |
| `metadata` | object | No |  |

```json title="Request"
{
  "email": "ann@example.com",
  "name": "Ann Smith",
  "reference": "crm-1042",
  "metadata": {
    "tier": "gold"
  }
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"customer"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `email` | string or null | Yes |  |
| `name` | string or null | Yes |  |
| `phone` | string or null | Yes |  |
| `reference` | string or null | Yes | Your own ID for this customer. |
| `metadata` | object | Yes |  |
| `source` | string | Yes | How OnCharge first met the customer, in plain words. |
| `created_at` | string (date-time) | Yes |  |
| `totals` | object | Yes |  |
| `totals.payments` | integer | Yes | Paid payments. |
| `totals.lifetime_value` | array of object | Yes | What the customer paid, less refunds, per currency. |
| `totals.lifetime_value[].currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `totals.lifetime_value[].amount` | integer | Yes | Minor units. |
| `totals.refunded` | array of object | Yes |  |
| `totals.refunded[].currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `totals.refunded[].amount` | integer | Yes | Minor units. |
| `totals.disputes` | integer | Yes |  |
| `totals.last_payment_at` | string (date-time) or null | Yes |  |
| `payment_methods` | array of object | No | On a single customer: the saved cards that can be charged. |
| `payment_methods[].id` | string (uuid) | Yes |  |
| `payment_methods[].object` | `"payment_method"` | Yes |  |
| `payment_methods[].type` | `"card"` | Yes |  |
| `payment_methods[].brand` | string | Yes |  |
| `payment_methods[].last4` | string | Yes |  |
| `payment_methods[].exp_month` | integer (≥ 1, ≤ 12) | Yes |  |
| `payment_methods[].exp_year` | integer | Yes |  |
| `payment_methods[].funding` | one of `credit`, `debit`, `prepaid`, `unknown`, or `null` | No |  |
| `payment_methods[].country` | string or null | No |  |
| `payment_methods[].wallet` | string or null | No | Apple Pay or Google Pay when the card was saved from one. |
| `payment_methods[].is_default` | boolean | Yes |  |
| `payment_methods[].status` | one of `active`, `removed` | Yes |  |
| `payment_methods[].expired` | boolean | Yes |  |
| `payment_methods[].saved_via` | one of `checkout`, `save_card_page` | Yes |  |
| `payment_methods[].created_at` | string (date-time) | Yes |  |
| `payment_methods[].last_used_at` | string (date-time) or null | No |  |
| `payment_methods[].updated_by_card_network_at` | string (date-time) or null | No | When the card network last sent new details for this card (a renewed or replaced card). |
| `payment_methods[].removed_at` | string (date-time) or null | No |  |
| `saved_cards` | integer | No | In lists: how many saved cards the customer has. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "customer",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "email": "string",
  "name": "string",
  "phone": "string",
  "reference": "string",
  "metadata": {},
  "source": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "totals": {
    "payments": 0,
    "lifetime_value": [
      {
        "currency": "USD",
        "amount": 0
      }
    ],
    "refunded": [
      {
        "currency": "USD",
        "amount": 0
      }
    ],
    "disputes": 0,
    "last_payment_at": "2026-01-01T00:00:00.000Z"
  },
  "payment_methods": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "object": "payment_method",
      "type": "card",
      "brand": "Visa",
      "last4": "string",
      "exp_month": 1,
      "exp_year": 0,
      "funding": "credit",
      "country": "string",
      "wallet": "string",
      "is_default": true,
      "status": "active",
      "expired": true,
      "saved_via": "checkout",
      "created_at": "2026-01-01T00:00:00.000Z",
      "last_used_at": "2026-01-01T00:00:00.000Z",
      "updated_by_card_network_at": "2026-01-01T00:00:00.000Z",
      "removed_at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "saved_cards": 0
}
```

| Status | Meaning |
|---|---|
| `201` | Customer added. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `409` | `customer_exists`: the store already has a customer with that email or reference (`customer_id`). |

### Retrieve a customer {#retrievecustomer}

```http
GET /api/v1/customers/{customer_id}
```

One of your store's customers, with totals and saved cards. Another store's customer answers 404.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `customer_id` | path | string (uuid) | Yes | An OnCharge customer ID of your store. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"customer"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `email` | string or null | Yes |  |
| `name` | string or null | Yes |  |
| `phone` | string or null | Yes |  |
| `reference` | string or null | Yes | Your own ID for this customer. |
| `metadata` | object | Yes |  |
| `source` | string | Yes | How OnCharge first met the customer, in plain words. |
| `created_at` | string (date-time) | Yes |  |
| `totals` | object | Yes |  |
| `totals.payments` | integer | Yes | Paid payments. |
| `totals.lifetime_value` | array of object | Yes | What the customer paid, less refunds, per currency. |
| `totals.lifetime_value[].currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `totals.lifetime_value[].amount` | integer | Yes | Minor units. |
| `totals.refunded` | array of object | Yes |  |
| `totals.refunded[].currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `totals.refunded[].amount` | integer | Yes | Minor units. |
| `totals.disputes` | integer | Yes |  |
| `totals.last_payment_at` | string (date-time) or null | Yes |  |
| `payment_methods` | array of object | No | On a single customer: the saved cards that can be charged. |
| `payment_methods[].id` | string (uuid) | Yes |  |
| `payment_methods[].object` | `"payment_method"` | Yes |  |
| `payment_methods[].type` | `"card"` | Yes |  |
| `payment_methods[].brand` | string | Yes |  |
| `payment_methods[].last4` | string | Yes |  |
| `payment_methods[].exp_month` | integer (≥ 1, ≤ 12) | Yes |  |
| `payment_methods[].exp_year` | integer | Yes |  |
| `payment_methods[].funding` | one of `credit`, `debit`, `prepaid`, `unknown`, or `null` | No |  |
| `payment_methods[].country` | string or null | No |  |
| `payment_methods[].wallet` | string or null | No | Apple Pay or Google Pay when the card was saved from one. |
| `payment_methods[].is_default` | boolean | Yes |  |
| `payment_methods[].status` | one of `active`, `removed` | Yes |  |
| `payment_methods[].expired` | boolean | Yes |  |
| `payment_methods[].saved_via` | one of `checkout`, `save_card_page` | Yes |  |
| `payment_methods[].created_at` | string (date-time) | Yes |  |
| `payment_methods[].last_used_at` | string (date-time) or null | No |  |
| `payment_methods[].updated_by_card_network_at` | string (date-time) or null | No | When the card network last sent new details for this card (a renewed or replaced card). |
| `payment_methods[].removed_at` | string (date-time) or null | No |  |
| `saved_cards` | integer | No | In lists: how many saved cards the customer has. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "customer",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "email": "string",
  "name": "string",
  "phone": "string",
  "reference": "string",
  "metadata": {},
  "source": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "totals": {
    "payments": 0,
    "lifetime_value": [
      {
        "currency": "USD",
        "amount": 0
      }
    ],
    "refunded": [
      {
        "currency": "USD",
        "amount": 0
      }
    ],
    "disputes": 0,
    "last_payment_at": "2026-01-01T00:00:00.000Z"
  },
  "payment_methods": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "object": "payment_method",
      "type": "card",
      "brand": "Visa",
      "last4": "string",
      "exp_month": 1,
      "exp_year": 0,
      "funding": "credit",
      "country": "string",
      "wallet": "string",
      "is_default": true,
      "status": "active",
      "expired": true,
      "saved_via": "checkout",
      "created_at": "2026-01-01T00:00:00.000Z",
      "last_used_at": "2026-01-01T00:00:00.000Z",
      "updated_by_card_network_at": "2026-01-01T00:00:00.000Z",
      "removed_at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "saved_cards": 0
}
```

| Status | Meaning |
|---|---|
| `200` | The customer. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### List saved cards {#listsavedcards}

```http
GET /api/v1/customers/{customer_id}/payment-methods
```

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `customer_id` | path | string (uuid) | Yes | An OnCharge customer ID of your store. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `object` | `"list"` | Yes |  |
| `data` | array of object | Yes |  |
| `data[].id` | string (uuid) | Yes |  |
| `data[].object` | `"payment_method"` | Yes |  |
| `data[].type` | `"card"` | Yes |  |
| `data[].brand` | string | Yes |  |
| `data[].last4` | string | Yes |  |
| `data[].exp_month` | integer (≥ 1, ≤ 12) | Yes |  |
| `data[].exp_year` | integer | Yes |  |
| `data[].funding` | one of `credit`, `debit`, `prepaid`, `unknown`, or `null` | No |  |
| `data[].country` | string or null | No |  |
| `data[].wallet` | string or null | No | Apple Pay or Google Pay when the card was saved from one. |
| `data[].is_default` | boolean | Yes |  |
| `data[].status` | one of `active`, `removed` | Yes |  |
| `data[].expired` | boolean | Yes |  |
| `data[].saved_via` | one of `checkout`, `save_card_page` | Yes |  |
| `data[].created_at` | string (date-time) | Yes |  |
| `data[].last_used_at` | string (date-time) or null | No |  |
| `data[].updated_by_card_network_at` | string (date-time) or null | No | When the card network last sent new details for this card (a renewed or replaced card). |
| `data[].removed_at` | string (date-time) or null | No |  |

```json title="Response"
{
  "object": "list",
  "data": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "object": "payment_method",
      "type": "card",
      "brand": "Visa",
      "last4": "string",
      "exp_month": 1,
      "exp_year": 0,
      "funding": "credit",
      "country": "string",
      "wallet": "string",
      "is_default": true,
      "status": "active",
      "expired": true,
      "saved_via": "checkout",
      "created_at": "2026-01-01T00:00:00.000Z",
      "last_used_at": "2026-01-01T00:00:00.000Z",
      "updated_by_card_network_at": "2026-01-01T00:00:00.000Z",
      "removed_at": "2026-01-01T00:00:00.000Z"
    }
  ]
}
```

| Status | Meaning |
|---|---|
| `200` | The customer's saved cards that can be charged. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Create a save-card page {#createsetupsession}

```http
POST /api/v1/customers/{customer_id}/payment-methods
```

Creates a page where the customer saves a card without paying. Send them to `url`: it shows
the consent text first and the card form only after they agree; the card is saved for your
store only. The same `Idempotency-Key` returns the same page.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |
| `customer_id` | path | string (uuid) | Yes | An OnCharge customer ID of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `return_url` | string (uri) | No | https, on one of your store's domains: where the customer returns once the card is saved. |
| `metadata` | object | No |  |
| `expires_in_hours` | integer (≥ 1, ≤ 72) | No | Default `24`. |

```json title="Request"
{
  "return_url": "https://shop.example.com/account"
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"setup_session"` | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `status` | one of `open`, `succeeded`, `failed`, `expired` | Yes |  |
| `url` | string (uri) | Yes | Send the customer here. |
| `return_url` | string or null | No |  |
| `expires_at` | string (date-time) | Yes |  |
| `payment_method_id` | string (uuid) or null | No | The card saved, once the customer saved one. |
| `metadata` | object | No |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "setup_session",
  "customer_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "status": "open",
  "url": "string",
  "return_url": "string",
  "expires_at": "2026-01-01T00:00:00.000Z",
  "payment_method_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "metadata": {},
  "created_at": "2026-01-01T00:00:00.000Z"
}
```

| Status | Meaning |
|---|---|
| `200` | The page created earlier with this `Idempotency-Key`. |
| `201` | Page created. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `saved_cards_unavailable`: card payments are not set up on this store. |

### Remove a saved card {#removesavedcard}

```http
DELETE /api/v1/customers/{customer_id}/payment-methods/{payment_method_id}
```

Removes a saved card for good: it is detached at the processor and can never be charged again.
Removing a card that is already removed answers the same. If it cannot be removed right now
(`502 try_again`) nothing changed.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `customer_id` | path | string (uuid) | Yes | An OnCharge customer ID of your store. |
| `payment_method_id` | path | string (uuid) | Yes | A saved card's ID. |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"payment_method"` | Yes |  |
| `deleted` | `true` | Yes |  |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "payment_method",
  "deleted": true
}
```

| Status | Meaning |
|---|---|
| `200` | Removed. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `502` | `try_again`: the card could not be removed right now; nothing changed. |

### Charge a saved card {#createcustomercharge}

```http
POST /api/v1/customers/{customer_id}/charges
```

Charges a customer's saved card while they are away. Use it only for what the customer agreed
to when they saved the card. Always send an `Idempotency-Key`: a retry returns the same charge
and never charges twice.

It is a payment like any checkout payment: same fee, same delivery-gated payout (card payments
on these stores are USD; an order that ships by carrier needs `shipping` with `order_id`), same
`payment.*` webhooks, and it appears under Payments.

When the customer's bank asks them to confirm the payment, the status is
`requires_authentication` and OnCharge emails them a link to confirm it.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |
| `customer_id` | path | string (uuid) | Yes | An OnCharge customer ID of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `amount` | integer (≥ 1) | Yes | Amount in the currency's minor unit (cents for USD). |
| `currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `payment_method_id` | string (uuid) | No | A saved card of this customer. The default card when omitted. |
| `reference` | string (max 255 chars) | No |  |
| `order_id` | string (max 255 chars) | No |  |
| `description` | string (max 500 chars) | No |  |
| `shipping` | object | No | Where the order ships. OnCharge matches the carrier's delivery location against `postal_code` (US, first five digits) or `city` + `state`. Send at least `postal_code` or `city`.  |
| `shipping.name` | string (max 200 chars) | No |  |
| `shipping.line1` | string (max 300 chars) | No |  |
| `shipping.line2` | string (max 300 chars) | No |  |
| `shipping.city` | string (max 120 chars) | No |  |
| `shipping.state` | string (max 120 chars) | No |  |
| `shipping.postal_code` | string (max 20 chars) | No |  |
| `shipping.country` | string (max 60 chars) | No | ISO 3166-1 alpha-2 code recommended (`US`). |
| `line_items` | array of object (≤ 500 items) | No |  |
| `line_items[].description` | string | Yes |  |
| `line_items[].quantity` | integer (≥ 1) | Yes |  |
| `line_items[].amount_including_tax` | integer (≥ 0) | Yes | Line amount in minor units, tax included. |
| `line_items[].requires_shipping` | boolean | No | Whether this item is shipped. On a store that sells both shipped and unshipped things, an order with any shipped item is paid out after carrier-confirmed delivery; one whose items all say `false`, 7 days after payment. Without it, the order is decided by whether it has a shipping address. |
| `line_items[].tax_category` | one of `general_goods`, `nontaxable`, `services`, `electronic_services`, `clothing`, `software_download`, `saas`, `books`, `ebooks`, `music_download`, `dietary_supplements`, `otc_drugs`, `cosmetics`, `candy`, `groceries`, `prepared_food`, `pet_food`, `gift_cards` | No | An OnCharge product tax category. |
| `metadata` | object | No |  |
| `tax` | object | No | Sales tax for this payment, when your store has it on (Settings → Sales tax). With `enabled`, `amount` is the order as you list it (before tax, unless your store lists prices with tax included); line items (`amount_including_tax` is then each line's total as listed) and `shipping_amount` must add up to it. Tax is calculated for the shipping address, or `billing_address` when nothing ships. See /docs/sales-tax. |
| `tax.enabled` | boolean | Yes | Calculate sales tax. Store plugins that already add their platform's tax should leave this off. |
| `tax.shipping_amount` | integer (≥ 0) | No | The shipping charge inside `amount`, minor units: taxed as shipping. |
| `tax.billing_address` | object | No |  |
| `tax.billing_address.line1` | string (max 300 chars) | No |  |
| `tax.billing_address.line2` | string (max 300 chars) | No |  |
| `tax.billing_address.city` | string (max 120 chars) | No |  |
| `tax.billing_address.state` | string (max 120 chars) | No | Two-letter US state (or its name). |
| `tax.billing_address.postal_code` | string (max 20 chars) | Yes | Five-digit US ZIP code (ZIP+4 accepted). |
| `tax.billing_address.country` | string (max 60 chars) | No | US only for now. Defaults to US. |

```json title="Request"
{
  "amount": 2900,
  "currency": "USD",
  "reference": "subscription-2026-12"
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"charge"` | Yes |  |
| `session_id` | string (uuid) | Yes | The payment, as for a checkout session: refunds, shipments and webhooks use it. |
| `payment_reference` | string | Yes |  |
| `status` | one of `succeeded`, `processing`, `requires_authentication`, `declined`, `failed` | Yes | `succeeded`: paid. `processing`: the bank has not answered yet; a payment webhook follows. `requires_authentication`: the customer's bank wants them to confirm it; OnCharge emailed them a link to confirm it (`authentication.emailed`). `declined`: see `decline`. |
| `amount` | integer | Yes |  |
| `currency` | string | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `payment_method_id` | string (uuid) | Yes |  |
| `order_id` | string or null | No |  |
| `created_at` | string (date-time) | Yes |  |
| `decline` | object or null | Yes |  |
| `decline.reason` | one of `insufficient_funds`, `expired_card`, `incorrect_details`, `authentication_required`, `card_not_supported`, `try_again_later`, `suspected_fraud`, `card_declined`, `limit_exceeded` | Yes |  |
| `decline.message` | string | Yes | What happened and what to do, in plain words. |
| `authentication` | object or null | Yes |  |
| `authentication.emailed` | boolean | Yes | OnCharge emailed the customer a link to its page where they confirm the payment (valid 7 days). `false` when the customer has no email: ask them to pay through checkout instead. The link goes to the customer only, so the cardholder confirms it. |
| `shipping_required` | `true` | No | The order ships by carrier and has no address yet: attach it with POST /api/v1/checkout/sessions/{session_id}/order. |
| `idempotent` | `true` | No | A retry with the same Idempotency-Key returned the first charge. |
| `tax` | object or null | No | Sales tax on a payment; null when it is not taxed. |
| `tax.status` | one of `awaiting_address`, `calculated`, `pending`, `failed`, `collected`, `partly_refunded`, `refunded` | Yes | `awaiting_address`: no address yet, the payment waits. `calculated`: not paid yet. `pending`: tax included, charged while the calculation was unavailable; worked out shortly. `failed`: the calculation failed (`error`), the payment waits. `collected`, `partly_refunded`, `refunded`: paid, and how much of the tax was given back. |
| `tax.inclusive` | boolean | Yes | true when the listed prices include the tax. |
| `tax.currency` | string or null | Yes |  |
| `tax.subtotal` | integer or null | Yes | Before tax, minor units. |
| `tax.amount` | integer or null | Yes | The tax, minor units. |
| `tax.total` | integer or null | Yes | What the customer pays, minor units. |
| `tax.shipping` | integer | Yes | The shipping charge inside the total, minor units. |
| `tax.jurisdictions` | array of object | Yes |  |
| `tax.jurisdictions[].state` | string or null | No |  |
| `tax.jurisdictions[].rate` | string | No | Combined percent, e.g. "8.25". |
| `tax.jurisdictions[].amount` | integer | No |  |
| `tax.refunded` | integer | Yes | Tax given back so far with refunds and lost disputes, minor units. |
| `tax.error` | string or null | Yes | `tax_address_invalid` or `tax_unavailable` when `status` is `failed`. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "charge",
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "payment_reference": "string",
  "status": "succeeded",
  "amount": 0,
  "currency": "string",
  "customer_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "payment_method_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "order_id": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "decline": {
    "reason": "insufficient_funds",
    "message": "string"
  },
  "authentication": {
    "emailed": true
  },
  "shipping_required": true,
  "idempotent": true,
  "tax": {
    "status": "awaiting_address",
    "inclusive": true,
    "currency": "string",
    "subtotal": 0,
    "amount": 0,
    "total": 0,
    "shipping": 0,
    "jurisdictions": [
      {
        "state": "string",
        "rate": "string",
        "amount": 0
      }
    ],
    "refunded": 0,
    "error": "string"
  }
}
```

| Status | Meaning |
|---|---|
| `200` | The charge made earlier with this `Idempotency-Key` (`idempotent: true`). |
| `201` | Charge made: `succeeded`, `processing` or `requires_authentication`. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `402` | Declined: `decline.reason` and `decline.message` say why in plain words. `limit_exceeded`: the charge would go over a limit OnCharge set for the store (for example a daily volume cap); nothing was sent to the bank. Charge again with a new `Idempotency-Key` once the limit allows it. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `no_saved_card`, `payment_method_unusable` (the card was removed, also when resuming a charge started with it), `charge_not_completed` (an interrupted charge more than 20 hours old), `idempotency_conflict` or `saved_cards_unavailable`. |
| `502` | `try_again`: the outcome is not known yet. Retry with the same `Idempotency-Key` (within 20 hours); the card is never charged twice. After that the charge answers `409 charge_not_completed`: start a new one with a new key. |

## Risk {#risk}

Read risk decisions and manage the store's risk policy.

### List risk decisions {#listriskdecisions}

```http
GET /api/v1/risk/decisions
```

Risk decisions made at checkout for the store, newest first.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `from` | query | string (date-time) | No | Earliest `created_at` (ISO 8601). |
| `to` | query | string (date-time) | No | Latest `created_at` (ISO 8601). |
| `decision` | query | one of `allow`, `deny`, `review`, `step_up` | No |  |
| `limit` | query | integer | No |  |
| `offset` | query | integer | No |  |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `decisions` | array of object | Yes |  |
| `decisions[].id` | string (uuid) | No |  |
| `decisions[].session_id` | string (uuid) | No |  |
| `decisions[].decision` | one of `allow`, `deny`, `review`, `step_up` | No |  |
| `decisions[].score` | integer (≥ 0, ≤ 100) | No |  |
| `decisions[].actions` | array of string | No | Step-up actions, e.g. `require_sms_otp`, `require_terms`, `require_signature`, `force_3ds`. |
| `decisions[].reasons` | array of object | No |  |
| `decisions[].reasons[].code` | string | No |  |
| `decisions[].reasons[].severity` | one of `info`, `warn`, `block` | No |  |
| `decisions[].reasons[].explain` | string | No |  |
| `decisions[].explain_short` | string or null | No |  |
| `decisions[].model_version` | string | No |  |
| `decisions[].created_at` | string (date-time) | No |  |
| `total` | integer | Yes |  |
| `limit` | integer | Yes |  |
| `offset` | integer | Yes |  |

```json title="Response"
{
  "decisions": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "decision": "allow",
      "score": 0,
      "actions": [
        "string"
      ],
      "reasons": [
        {
          "code": null,
          "severity": null,
          "explain": null
        }
      ],
      "explain_short": "string",
      "model_version": "string",
      "created_at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "total": 0,
  "limit": 0,
  "offset": 0
}
```

| Status | Meaning |
|---|---|
| `200` | A page of decisions. |

### Retrieve a risk decision {#getriskdecision}

```http
GET /api/v1/risk/decisions/{decision_id}
```

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `decision_id` | path | string (uuid) | Yes |  |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | No |  |
| `session_id` | string (uuid) | No |  |
| `decision` | one of `allow`, `deny`, `review`, `step_up` | No |  |
| `score` | integer (≥ 0, ≤ 100) | No |  |
| `actions` | array of string | No | Step-up actions, e.g. `require_sms_otp`, `require_terms`, `require_signature`, `force_3ds`. |
| `reasons` | array of object | No |  |
| `reasons[].code` | string | No |  |
| `reasons[].severity` | one of `info`, `warn`, `block` | No |  |
| `reasons[].explain` | string | No |  |
| `explain_short` | string or null | No |  |
| `model_version` | string | No |  |
| `created_at` | string (date-time) | No |  |
| `feature_snapshot` | object | No |  |
| `policy_version` | string or null | No |  |
| `label` | object or null | No |  |
| `label.paid` | boolean or null | No |  |
| `label.refunded` | boolean or null | No |  |
| `label.chargeback` | boolean or null | No |  |
| `label.dispute_opened` | boolean or null | No |  |
| `label.label_source` | string or null | No |  |
| `label.occurred_at` | string (date-time) or null | No |  |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "decision": "allow",
  "score": 0,
  "actions": [
    "string"
  ],
  "reasons": [
    {
      "code": "string",
      "severity": "info",
      "explain": "string"
    }
  ],
  "explain_short": "string",
  "model_version": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "feature_snapshot": {},
  "policy_version": "string",
  "label": {
    "paid": true,
    "refunded": true,
    "chargeback": true,
    "dispute_opened": true,
    "label_source": "string",
    "occurred_at": "2026-01-01T00:00:00.000Z"
  }
}
```

| Status | Meaning |
|---|---|
| `200` | The decision with its feature snapshot and outcome label, if any. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Label the outcome of a risk decision {#sendriskfeedback}

```http
POST /api/v1/risk/feedback
```

Tells OnCharge how an order turned out, to improve future decisions.

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `label` | one of `fraud_confirmed`, `false_positive`, `legitimate`, `chargeback` | Yes |  |
| `notes` | string (max 1000 chars) | No |  |

```json title="Request"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "label": "fraud_confirmed",
  "notes": "string"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `status` | `"ok"` | Yes |  |
| `label` | string | Yes |  |

```json title="Response"
{
  "status": "ok",
  "label": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | Recorded. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Get the store's risk policy {#getriskpolicy}

```http
GET /api/v1/risk/policies
```

The store's policy, or the defaults (`is_default: true`) if none was saved.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `mode` | one of `monitor`, `enforce` | No |  |
| `thresholds` | object | No |  |
| `thresholds.score_allow` | integer (≥ 0, ≤ 100) | Yes |  |
| `thresholds.score_review` | integer (≥ 0, ≤ 100) | Yes |  |
| `thresholds.score_deny` | integer (≥ 0, ≤ 100) | Yes |  |
| `step_up_rules` | object | No |  |
| `step_up_rules.require_otp_on_review` | boolean | Yes |  |
| `step_up_rules.require_signature` | boolean | Yes |  |
| `step_up_rules.require_terms` | boolean | Yes |  |
| `step_up_rules.force_3ds_above` | integer (≥ 0, ≤ 100) | Yes |  |
| `blocks` | object | No |  |
| `blocks.vpn_tor` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.datacenter_asn` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.disposable_email` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.voip_phone` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.high_risk_countries` | array of string | Yes | ISO country codes. |
| `blocks.headless_browser` | one of `allow`, `step_up`, `deny` | Yes |  |
| `velocity_limits` | object | No |  |
| `velocity_limits.ip_5m` | integer (≥ 0) | Yes |  |
| `velocity_limits.ip_1h` | integer (≥ 0) | Yes |  |
| `velocity_limits.ip_24h` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_5m` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_1h` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_24h` | integer (≥ 0) | Yes |  |
| `id` | string (uuid) | No |  |
| `store_id` | string (uuid) | Yes |  |
| `is_default` | boolean | Yes | true when no policy has been saved and these are the defaults. |
| `created_at` | string (date-time) | No |  |
| `updated_at` | string (date-time) | No |  |

```json title="Response"
{
  "mode": "monitor",
  "thresholds": {
    "score_allow": 0,
    "score_review": 0,
    "score_deny": 0
  },
  "step_up_rules": {
    "require_otp_on_review": true,
    "require_signature": true,
    "require_terms": true,
    "force_3ds_above": 0
  },
  "blocks": {
    "vpn_tor": "allow",
    "datacenter_asn": "allow",
    "disposable_email": "allow",
    "voip_phone": "allow",
    "high_risk_countries": [
      "string"
    ],
    "headless_browser": "allow"
  },
  "velocity_limits": {
    "ip_5m": 0,
    "ip_1h": 0,
    "ip_24h": 0,
    "email_5m": 0,
    "email_1h": 0,
    "email_24h": 0
  },
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "is_default": true,
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}
```

| Status | Meaning |
|---|---|
| `200` | The policy. |

### Create or update the store's risk policy {#updateriskpolicy}

```http
PUT /api/v1/risk/policies
```

Each top-level section you send replaces that section; sections you omit are unchanged.
Thresholds must satisfy `score_allow < score_review < score_deny`. In `monitor` mode
decisions are recorded but never block a payment.

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `mode` | one of `monitor`, `enforce` | No |  |
| `thresholds` | object | No |  |
| `thresholds.score_allow` | integer (≥ 0, ≤ 100) | Yes |  |
| `thresholds.score_review` | integer (≥ 0, ≤ 100) | Yes |  |
| `thresholds.score_deny` | integer (≥ 0, ≤ 100) | Yes |  |
| `step_up_rules` | object | No |  |
| `step_up_rules.require_otp_on_review` | boolean | Yes |  |
| `step_up_rules.require_signature` | boolean | Yes |  |
| `step_up_rules.require_terms` | boolean | Yes |  |
| `step_up_rules.force_3ds_above` | integer (≥ 0, ≤ 100) | Yes |  |
| `blocks` | object | No |  |
| `blocks.vpn_tor` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.datacenter_asn` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.disposable_email` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.voip_phone` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.high_risk_countries` | array of string | Yes | ISO country codes. |
| `blocks.headless_browser` | one of `allow`, `step_up`, `deny` | Yes |  |
| `velocity_limits` | object | No |  |
| `velocity_limits.ip_5m` | integer (≥ 0) | Yes |  |
| `velocity_limits.ip_1h` | integer (≥ 0) | Yes |  |
| `velocity_limits.ip_24h` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_5m` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_1h` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_24h` | integer (≥ 0) | Yes |  |

```json title="Request"
{
  "mode": "monitor",
  "thresholds": {
    "score_allow": 0,
    "score_review": 0,
    "score_deny": 0
  },
  "step_up_rules": {
    "require_otp_on_review": true,
    "require_signature": true,
    "require_terms": true,
    "force_3ds_above": 0
  },
  "blocks": {
    "vpn_tor": "allow",
    "datacenter_asn": "allow",
    "disposable_email": "allow",
    "voip_phone": "allow",
    "high_risk_countries": [
      "string"
    ],
    "headless_browser": "allow"
  },
  "velocity_limits": {
    "ip_5m": 0,
    "ip_1h": 0,
    "ip_24h": 0,
    "email_5m": 0,
    "email_1h": 0,
    "email_24h": 0
  }
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `mode` | one of `monitor`, `enforce` | No |  |
| `thresholds` | object | No |  |
| `thresholds.score_allow` | integer (≥ 0, ≤ 100) | Yes |  |
| `thresholds.score_review` | integer (≥ 0, ≤ 100) | Yes |  |
| `thresholds.score_deny` | integer (≥ 0, ≤ 100) | Yes |  |
| `step_up_rules` | object | No |  |
| `step_up_rules.require_otp_on_review` | boolean | Yes |  |
| `step_up_rules.require_signature` | boolean | Yes |  |
| `step_up_rules.require_terms` | boolean | Yes |  |
| `step_up_rules.force_3ds_above` | integer (≥ 0, ≤ 100) | Yes |  |
| `blocks` | object | No |  |
| `blocks.vpn_tor` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.datacenter_asn` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.disposable_email` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.voip_phone` | one of `allow`, `step_up`, `deny` | Yes |  |
| `blocks.high_risk_countries` | array of string | Yes | ISO country codes. |
| `blocks.headless_browser` | one of `allow`, `step_up`, `deny` | Yes |  |
| `velocity_limits` | object | No |  |
| `velocity_limits.ip_5m` | integer (≥ 0) | Yes |  |
| `velocity_limits.ip_1h` | integer (≥ 0) | Yes |  |
| `velocity_limits.ip_24h` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_5m` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_1h` | integer (≥ 0) | Yes |  |
| `velocity_limits.email_24h` | integer (≥ 0) | Yes |  |
| `id` | string (uuid) | No |  |
| `store_id` | string (uuid) | No |  |
| `created_at` | string (date-time) | No |  |
| `updated_at` | string (date-time) | No |  |

```json title="Response"
{
  "mode": "monitor",
  "thresholds": {
    "score_allow": 0,
    "score_review": 0,
    "score_deny": 0
  },
  "step_up_rules": {
    "require_otp_on_review": true,
    "require_signature": true,
    "require_terms": true,
    "force_3ds_above": 0
  },
  "blocks": {
    "vpn_tor": "allow",
    "datacenter_asn": "allow",
    "disposable_email": "allow",
    "voip_phone": "allow",
    "high_risk_countries": [
      "string"
    ],
    "headless_browser": "allow"
  },
  "velocity_limits": {
    "ip_5m": 0,
    "ip_1h": 0,
    "ip_24h": 0,
    "email_5m": 0,
    "email_1h": 0,
    "email_24h": 0
  },
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}
```

| Status | Meaning |
|---|---|
| `200` | Policy updated. |
| `201` | Policy created. |
| `400` | `validation_error`, `invalid_json` or `invalid_thresholds`. |

### Replay a decision under a different policy {#simulateriskpolicy}

```http
POST /api/v1/risk/simulate
```

Shows what a past decision would have been with the policy you send. Nothing is saved.

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `decision_id` | string (uuid) | Yes |  |
| `policy` | object | Yes |  |
| `policy.mode` | one of `monitor`, `enforce` | No |  |
| `policy.thresholds` | object | No |  |
| `policy.thresholds.score_allow` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy.thresholds.score_review` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy.thresholds.score_deny` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy.step_up_rules` | object | No |  |
| `policy.step_up_rules.require_otp_on_review` | boolean | Yes |  |
| `policy.step_up_rules.require_signature` | boolean | Yes |  |
| `policy.step_up_rules.require_terms` | boolean | Yes |  |
| `policy.step_up_rules.force_3ds_above` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy.blocks` | object | No |  |
| `policy.blocks.vpn_tor` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy.blocks.datacenter_asn` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy.blocks.disposable_email` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy.blocks.voip_phone` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy.blocks.high_risk_countries` | array of string | Yes | ISO country codes. |
| `policy.blocks.headless_browser` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy.velocity_limits` | object | No |  |
| `policy.velocity_limits.ip_5m` | integer (≥ 0) | Yes |  |
| `policy.velocity_limits.ip_1h` | integer (≥ 0) | Yes |  |
| `policy.velocity_limits.ip_24h` | integer (≥ 0) | Yes |  |
| `policy.velocity_limits.email_5m` | integer (≥ 0) | Yes |  |
| `policy.velocity_limits.email_1h` | integer (≥ 0) | Yes |  |
| `policy.velocity_limits.email_24h` | integer (≥ 0) | Yes |  |

```json title="Request"
{
  "decision_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "policy": {
    "mode": "monitor",
    "thresholds": {
      "score_allow": 0,
      "score_review": 0,
      "score_deny": 0
    },
    "step_up_rules": {
      "require_otp_on_review": true,
      "require_signature": true,
      "require_terms": true,
      "force_3ds_above": 0
    },
    "blocks": {
      "vpn_tor": "allow",
      "datacenter_asn": "allow",
      "disposable_email": "allow",
      "voip_phone": "allow",
      "high_risk_countries": [
        "string"
      ],
      "headless_browser": "allow"
    },
    "velocity_limits": {
      "ip_5m": 0,
      "ip_1h": 0,
      "ip_24h": 0,
      "email_5m": 0,
      "email_1h": 0,
      "email_24h": 0
    }
  }
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `simulation` | `true` | No |  |
| `original` | object | No |  |
| `original.decision` | one of `allow`, `deny`, `review`, `step_up` | No |  |
| `original.score` | integer | No |  |
| `original.explain_short` | string or null | No |  |
| `simulated` | object | No |  |
| `simulated.decision` | one of `allow`, `deny`, `review`, `step_up` | No |  |
| `simulated.score` | integer | No |  |
| `simulated.actions` | array of string | No |  |
| `simulated.reasons` | array of object | No |  |
| `simulated.reasons[].code` | string | No |  |
| `simulated.reasons[].severity` | one of `info`, `warn`, `block` | No |  |
| `simulated.reasons[].explain` | string | No |  |
| `simulated.explain_short` | string or null | No |  |
| `policy_tested` | object | No |  |
| `policy_tested.mode` | one of `monitor`, `enforce` | No |  |
| `policy_tested.thresholds` | object | No |  |
| `policy_tested.thresholds.score_allow` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy_tested.thresholds.score_review` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy_tested.thresholds.score_deny` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy_tested.step_up_rules` | object | No |  |
| `policy_tested.step_up_rules.require_otp_on_review` | boolean | Yes |  |
| `policy_tested.step_up_rules.require_signature` | boolean | Yes |  |
| `policy_tested.step_up_rules.require_terms` | boolean | Yes |  |
| `policy_tested.step_up_rules.force_3ds_above` | integer (≥ 0, ≤ 100) | Yes |  |
| `policy_tested.blocks` | object | No |  |
| `policy_tested.blocks.vpn_tor` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy_tested.blocks.datacenter_asn` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy_tested.blocks.disposable_email` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy_tested.blocks.voip_phone` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy_tested.blocks.high_risk_countries` | array of string | Yes | ISO country codes. |
| `policy_tested.blocks.headless_browser` | one of `allow`, `step_up`, `deny` | Yes |  |
| `policy_tested.velocity_limits` | object | No |  |
| `policy_tested.velocity_limits.ip_5m` | integer (≥ 0) | Yes |  |
| `policy_tested.velocity_limits.ip_1h` | integer (≥ 0) | Yes |  |
| `policy_tested.velocity_limits.ip_24h` | integer (≥ 0) | Yes |  |
| `policy_tested.velocity_limits.email_5m` | integer (≥ 0) | Yes |  |
| `policy_tested.velocity_limits.email_1h` | integer (≥ 0) | Yes |  |
| `policy_tested.velocity_limits.email_24h` | integer (≥ 0) | Yes |  |

```json title="Response"
{
  "simulation": true,
  "original": {
    "decision": "allow",
    "score": 0,
    "explain_short": "string"
  },
  "simulated": {
    "decision": "allow",
    "score": 0,
    "actions": [
      "string"
    ],
    "reasons": [
      {
        "code": "string",
        "severity": "info",
        "explain": "string"
      }
    ],
    "explain_short": "string"
  },
  "policy_tested": {
    "mode": "monitor",
    "thresholds": {
      "score_allow": 0,
      "score_review": 0,
      "score_deny": 0
    },
    "step_up_rules": {
      "require_otp_on_review": true,
      "require_signature": true,
      "require_terms": true,
      "force_3ds_above": 0
    },
    "blocks": {
      "vpn_tor": "allow",
      "datacenter_asn": "allow",
      "disposable_email": "allow",
      "voip_phone": "allow",
      "high_risk_countries": [
        "string"
      ],
      "headless_browser": "allow"
    },
    "velocity_limits": {
      "ip_5m": 0,
      "ip_1h": 0,
      "ip_24h": 0,
      "email_5m": 0,
      "email_1h": 0,
      "email_24h": 0
    }
  }
}
```

| Status | Meaning |
|---|---|
| `200` | The original and simulated outcomes. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

## Recurring {#recurring}

Merchant-initiated charges on a saved card.

### Charge a saved card {#createrecurringcharge}

```http
POST /api/v1/recurring/charge
```

> **Limited availability.** Ask OnCharge support before relying on this endpoint.

A merchant-initiated charge on a card the shopper saved during an earlier OnCharge checkout
(subscriptions, installments). Availability depends on your account configuration; ask
OnCharge support before relying on it. Uses the shopper's most recent saved card unless
`stored_card_id` is given.

On a store with its own card account the shopper is your customer with that email and
`stored_card_id` one of their saved cards: it charges through
`POST /api/v1/customers/{customer_id}/charges`, which new integrations should use instead.

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `shopper_email` | string (email) | Yes |  |
| `amount` | integer (≥ 1) | Yes | Amount in the currency's minor unit (cents for USD). |
| `currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `reference` | string (min 1 chars, max 255 chars) | Yes |  |
| `recurring_model` | one of `Subscription`, `UnscheduledCardOnFile` | No | Default `"Subscription"`. |
| `stored_card_id` | string (uuid) | No |  |

```json title="Request"
{
  "shopper_email": "string",
  "amount": 4900,
  "currency": "USD",
  "reference": "string",
  "recurring_model": "Subscription",
  "stored_card_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11"
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `session_id` | string (uuid) | Yes |  |
| `status` | one of `authorized`, `refused`, `pending` | Yes |  |
| `result_code` | string | No | Raw authorization result. Use `status` instead. |
| `psp_reference` | string | No | Opaque payment reference. |

```json title="Response"
{
  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "status": "authorized",
  "result_code": "string",
  "psp_reference": "string"
}
```

| Status | Meaning |
|---|---|
| `201` | Charge attempted. Check `status`. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `no_shopper`, `card_not_found` or `no_cards`. |
| `502` | `provider_error` or `provider_unavailable`: the payment network did not accept the request. Retry later. |

## Catalog {#catalog}

Send your products to OnCharge for shopping ads on Google Merchant Center and the Meta catalog. The whole catalog is sent and each ad platform reviews it against its own policies; only products that name a controlled substance, and products you exclude, are stored but not sent.

### Add, update and remove catalog products {#upsertcatalogproducts}

```http
POST /api/v1/catalog/products/batch
```

Sends up to 500 products and deletes to the store's advertising catalog, which OnCharge sends to Google Merchant Center and the Meta catalog. Products are matched by `id`; sending a product again updates it, and an identical product is not rewritten (`unchanged`). Deletes remove the product from ad platforms.

OnCharge sends the whole catalog to the ad platforms, which review each product against their own policies. `ruo: true` is a label only. Products that name a controlled substance, and products with no image, no price, an http link or `excluded: true`, are stored but not sent. Each result says whether the product is `advertisable` and why not. The WooCommerce plugin (1.5.0+) calls this for you.

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `items` | array of object (≤ 500 items) | No | Products to add or update. |
| `items[].id` | string (min 1 chars, max 50 chars) | Yes | Your product ID (WooCommerce: the product or variation ID). Unique per store. |
| `items[].item_group_id` | string or null (max 50 chars) | No | Groups the variants of one product (WooCommerce: the parent product ID). |
| `items[].title` | string (min 1 chars, max 1000 chars) | Yes | Product name. Stored cut to 150 characters. |
| `items[].description` | string or null (max 20000 chars) | No | Plain text or HTML (tags and shortcodes are removed). Stored cut to 5,000 characters. |
| `items[].link` | string (uri) (max 2048 chars) | Yes | Product page. Must be https; a product with an http link is rejected (or, if already stored, excluded). |
| `items[].image_link` | string (uri) or null (max 2048 chars) | No | Main image. Products without one are stored but not advertised. |
| `items[].additional_image_links` | array of string (uri) (≤ 20 items) | No | More images; at most 10 are kept. |
| `items[].price_minor` | integer (≥ 0) | Yes | Regular price in minor units, as shown in your store. |
| `items[].sale_price_minor` | integer or null (≥ 0) | No | Current sale price in minor units. Ignored unless lower than `price_minor`. |
| `items[].currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `items[].availability` | one of `in_stock`, `out_of_stock`, `preorder`, `backorder` | No | Default `"in_stock"`. |
| `items[].condition` | one of `new`, `refurbished`, `used` | No | Default `"new"`. |
| `items[].brand` | string or null (max 200 chars) | No |  |
| `items[].gtin` | string or null (max 50 chars) | No | UPC, EAN, ISBN or ITF-14. Kept only when it is 8–14 digits. |
| `items[].mpn` | string or null (max 100 chars) | No |  |
| `items[].google_product_category` | string or null (max 500 chars) | No | Google's product category ID or path, if you know it. |
| `items[].product_type` | string or null (max 750 chars) | No | Your own category path, e.g. `Apparel > Shirts`. |
| `items[].attributes` | object | No | Variant attributes such as `{"Color": "Blue", "Size": "M"}`. At most 30. |
| `items[].ruo` | boolean | No | `true` for research-use-only (RUO) products. A label only: the product is sent to the ad platforms like any other, and each platform reviews it against its own policies. |
| `items[].excluded` | boolean | No | `true` to keep the product out of advertising. |
| `deletes` | array of string (≤ 500 items) | No | IDs of products to remove. |

```json title="Request"
{
  "items": [
    {
      "id": "205",
      "item_group_id": "200",
      "title": "Linen shirt - Blue, M",
      "description": "Soft linen shirt.",
      "link": "https://shop.example.com/product/linen-shirt/?attribute_pa_color=blue&attribute_pa_size=m",
      "image_link": "https://shop.example.com/wp-content/uploads/linen-shirt-blue.jpg",
      "price_minor": 4900,
      "sale_price_minor": 3900,
      "currency": "USD",
      "availability": "in_stock",
      "brand": "Acme",
      "gtin": "0012345678905",
      "product_type": "Apparel > Shirts",
      "attributes": {
        "Color": "Blue",
        "Size": "M"
      }
    }
  ],
  "deletes": [
    "198"
  ]
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `results` | array of object | Yes | One per product, then one per delete, in request order. |
| `results[].id` | string | Yes |  |
| `results[].status` | one of `created`, `updated`, `unchanged`, `deleted`, `not_found`, `rejected` | Yes | `unchanged`: identical to what OnCharge already has (nothing written). `not_found`: a delete for an ID OnCharge never had. |
| `results[].advertisable` | boolean | No | For stored products: may be sent to ad platforms. |
| `results[].ruo` | boolean | No |  |
| `results[].excluded_reason` | one of `merchant_excluded`, `controlled_substance`, `insecure_link`, `missing_image`, `zero_price`, or `null` | No | Why the product is not advertised, or `null`. `merchant_excluded`: you sent `excluded: true`. `controlled_substance`: the product names a controlled substance (U.S. DEA schedules I to V), which is never sent to an ad platform. `insecure_link`: the link is not https. `missing_image`: no `image_link`. `zero_price`: `price_minor` is 0. |
| `results[].warnings` | array of one of `title_truncated`, `gtin_invalid`, `sale_price_ignored`, `additional_images_truncated`, `link_not_stored` | No |  |
| `results[].error` | string | No | For `rejected`: the error code, e.g. `insecure_link`. |
| `results[].message` | string | No |  |
| `counts` | object | Yes |  |
| `counts.created` | integer | Yes |  |
| `counts.updated` | integer | Yes |  |
| `counts.unchanged` | integer | Yes |  |
| `counts.deleted` | integer | Yes |  |
| `counts.not_found` | integer | Yes |  |
| `counts.rejected` | integer | Yes |  |

```json title="Response"
{
  "results": [
    {
      "id": "205",
      "status": "created",
      "advertisable": true,
      "ruo": false,
      "excluded_reason": null
    },
    {
      "id": "198",
      "status": "deleted"
    }
  ],
  "counts": {
    "created": 1,
    "updated": 0,
    "unchanged": 0,
    "deleted": 1,
    "not_found": 0,
    "rejected": 0
  }
}
```

| Status | Meaning |
|---|---|
| `200` | Per-product results and counts. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `413` | `payload_too_large`: more than 5 MB. Send smaller batches. |

### List catalog products {#listcatalogproducts}

```http
GET /api/v1/catalog/products
```

The store's catalog, oldest first. Use it to find products you no longer sell and remove them. Sign an empty body.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `limit` | query | integer | No |  |
| `offset` | query | integer | No |  |
| `include_deleted` | query | boolean | No | Also list removed products. |
| `updated_since` | query | string (date-time) | No | Only products changed at or after this time (ISO 8601). |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `products` | array of object | Yes |  |
| `products[].id` | string | Yes |  |
| `products[].item_group_id` | string or null | No |  |
| `products[].title` | string | Yes |  |
| `products[].link` | string (uri) | Yes |  |
| `products[].image_link` | string (uri) or null | No |  |
| `products[].price_minor` | integer | Yes |  |
| `products[].sale_price_minor` | integer or null | No |  |
| `products[].currency` | string (min 3 chars, max 3 chars) | Yes | ISO 4217 currency code. |
| `products[].availability` | one of `in_stock`, `out_of_stock`, `preorder`, `backorder` | Yes |  |
| `products[].ruo` | boolean | Yes |  |
| `products[].excluded_reason` | one of `merchant_excluded`, `controlled_substance`, `insecure_link`, `missing_image`, `zero_price`, or `null` | Yes | Why the product is not advertised, or `null`. `merchant_excluded`: you sent `excluded: true`. `controlled_substance`: the product names a controlled substance (U.S. DEA schedules I to V), which is never sent to an ad platform. `insecure_link`: the link is not https. `missing_image`: no `image_link`. `zero_price`: `price_minor` is 0. |
| `products[].advertisable` | boolean | Yes | Not removed and not excluded. |
| `products[].deleted` | boolean | Yes | Removed (only listed with `include_deleted=true`). |
| `products[].content_hash` | string | Yes | Changes whenever anything OnCharge stores for the product changes. |
| `products[].updated_at` | string (date-time) | Yes |  |
| `total` | integer | Yes |  |
| `limit` | integer | Yes |  |
| `offset` | integer | Yes |  |

```json title="Response"
{
  "products": [
    {
      "id": "string",
      "item_group_id": "string",
      "title": "string",
      "link": "string",
      "image_link": "string",
      "price_minor": 0,
      "sale_price_minor": 0,
      "currency": "USD",
      "availability": "in_stock",
      "ruo": true,
      "excluded_reason": "merchant_excluded",
      "advertisable": true,
      "deleted": true,
      "content_hash": "string",
      "updated_at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "total": 0,
  "limit": 0,
  "offset": 0
}
```

| Status | Meaning |
|---|---|
| `200` | A page of products. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |

## Events {#events}

Every webhook event of the last 30 days, and sending one to an endpoint again.

### List events {#listevents}

```http
GET /api/v1/events
```

The store's events from the last 30 days, newest first, each exactly as its webhook endpoints received it (data.rail included). Use it to catch up on events your server missed. Paged by cursor.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `type` | query | string | No | An event type (`payment.captured`) or a group (`payout.*`). |
| `from` | query | string (date) | No | Created on or after this day (UTC). |
| `to` | query | string (date) | No | Created on or before this day (UTC). |
| `limit` | query | integer | No |  |
| `cursor` | query | string | No | `next_cursor` of the previous page, sent with the same filters. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `events` | array of object | Yes |  |
| `events[].id` | string | Yes | Event ID (`evt_…`), the same as the `OnCharge-Event-Id` header. |
| `events[].type` | one of `payment.pending`, `payment.authorized`, `payment.captured`, `payment.under_review`, `payment.refused`, `payment.cancelled`, `payment.expired`, `payment.capture_failed`, `refund.succeeded`, `refund.failed`, `chargeback.opened`, `dispute.evidence_due`, `chargeback.won`, `chargeback.lost`, `fraud_warning.received`, `delivery.confirmed`, `payout.paid`, `payout.failed`, `payout.returned`, `account.updated`, `account.requirements_due`, `account.restricted`, `swap.created`, `swap.completed`, `swap.failed`, `swap.refunded`, `swap.expired`, `subscription.created`, `subscription.updated`, `subscription.trial_will_end`, `subscription.past_due`, `subscription.paused`, `subscription.resumed`, `subscription.canceled`, `subscription.period.paid`, `subscription.period.payment_failed`, `support.conversation.created`, `support.message.received`, `support.conversation.closed` | Yes | Every event type. Payments on every rail use the same payment.* types (data.rail says which). Handle the types you need and acknowledge (2xx) any others; new types may be added. |
| `events[].created` | integer | Yes | Unix time (seconds) the event was created. |
| `events[].livemode` | boolean | Yes | false for events from test payments. |
| `events[].data` | object | Yes | For payment events from a checkout, the fields below. Crypto and Card to Crypto paid to your wallet carry `session_id: null` with `payment_id`, `source`, `method`, `coin`, `coin_amount`, `wallet` and transaction hashes; every other event its own fields. All of them carry `rail`. |
| `events[].data.session_id` | string or null | No | The checkout session; null for a payment paid straight to your wallet. |
| `events[].data.order_id` | string or null | No | Your order ID, if known. |
| `events[].data.reference` | string or null | No | The `reference` you sent when creating the session. |
| `events[].data.amount` | integer or null | No | Minor units. For `refund.succeeded`, the total refunded so far. |
| `events[].data.currency` | string or null | No | ISO 4217 code. |
| `events[].data.status` | string or null | No | The order's payment status after the event (for example `captured`, `refunded`). |
| `events[].data.rail` | one of `card`, `crypto`, `card_to_crypto` | Yes | The rail an event or payment is on: card checkout; crypto (crypto checkout, or a coin paid straight to your wallet through the plugin or the gateway API); or Card to Crypto (card, Cash App or Venmo paid out to your wallet in USDC). |
| `events[].data.payment_reference` | string or null | No | OnCharge's reference for the payment (`ocpay_…`). |
| `events[].data.payment_link_id` | string (uuid) or null | No | The payment link the checkout was made from (`/api/v1/payment-links`), or null. |
| `events[].data.invoice_id` | string (uuid) | No | Only on a payment for an OnCharge invoice: the invoice's id (see Invoices). |
| `events[].data.payment_method` | one of `card`, `bank_debit`, `cash_app_pay`, `klarna`, `affirm`, `afterpay`, or `null` | No | How the shopper paid: `card`, or a way to pay beyond cards the store turned on (bank debit, Cash App Pay, Klarna, Affirm, Afterpay; see the Payment methods guide). Null for crypto. |
| `events[].data.tax` | object or null | No | Sales tax on the payment, on payment, refund and chargeback events of a taxed payment only. |
| `events[].data.reason` | one of `limit_exceeded` | No | Only on `payment.refused` when OnCharge refused the payment itself: `limit_exceeded` (the store reached a limit OnCharge set on its account, such as a daily volume cap). Absent when the bank declined it. |
| `events[].event` | one of `payment.pending`, `payment.authorized`, `payment.captured`, `payment.under_review`, `payment.refused`, `payment.cancelled`, `payment.expired`, `payment.capture_failed`, `refund.succeeded`, `refund.failed`, `chargeback.opened`, `dispute.evidence_due`, `chargeback.won`, `chargeback.lost`, `fraud_warning.received`, `delivery.confirmed`, `payout.paid`, `payout.failed`, `payout.returned`, `account.updated`, `account.requirements_due`, `account.restricted`, `swap.created`, `swap.completed`, `swap.failed`, `swap.refunded`, `swap.expired`, `subscription.created`, `subscription.updated`, `subscription.trial_will_end`, `subscription.past_due`, `subscription.paused`, `subscription.resumed`, `subscription.canceled`, `subscription.period.paid`, `subscription.period.payment_failed`, `support.conversation.created`, `support.message.received`, `support.conversation.closed` | No | Same as `type`. Kept for older plugins; only on payment events from a checkout. **Deprecated.** |
| `events[].status` | string or null | No | Same as `data.status`. Kept for older plugins; only on payment events from a checkout. **Deprecated.** |
| `events[].psp_reference` | string or null | No | Kept for older plugins, which store it as the order's transaction id: a payment made before 2026-12-01 keeps its original value here; from 2026-12-01 on it is the payment's OnCharge reference (`ocpay_…`, the same as `data.payment_reference`). Only on payment events from a checkout. **Deprecated.** |
| `next_cursor` | string or null | Yes | Pass as `cursor` for the next page; null on the last page. |

```json title="Response"
{
  "events": [
    {
      "id": "string",
      "type": "payment.pending",
      "created": 0,
      "livemode": true,
      "data": {
        "session_id": "string",
        "order_id": "string",
        "reference": "string",
        "amount": 0,
        "currency": "string",
        "status": "string",
        "rail": "card",
        "payment_reference": "string",
        "payment_link_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
        "invoice_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
        "payment_method": "card",
        "tax": {
          "status": null,
          "inclusive": null,
          "currency": null,
          "subtotal": null,
          "amount": null,
          "total": null,
          "shipping": null,
          "jurisdictions": null,
          "refunded": null,
          "error": null
        },
        "reason": "limit_exceeded"
      },
      "event": "payment.pending",
      "status": "string",
      "psp_reference": "string"
    }
  ],
  "next_cursor": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | Events. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |

### Retrieve an event {#getevent}

```http
GET /api/v1/events/{event_id}
```

One event from the last 30 days, exactly as your endpoints received it. An older event or another store's answers 404.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `event_id` | path | string | Yes | An event id (`evt_…`). |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string | Yes | Event ID (`evt_…`), the same as the `OnCharge-Event-Id` header. |
| `type` | one of `payment.pending`, `payment.authorized`, `payment.captured`, `payment.under_review`, `payment.refused`, `payment.cancelled`, `payment.expired`, `payment.capture_failed`, `refund.succeeded`, `refund.failed`, `chargeback.opened`, `dispute.evidence_due`, `chargeback.won`, `chargeback.lost`, `fraud_warning.received`, `delivery.confirmed`, `payout.paid`, `payout.failed`, `payout.returned`, `account.updated`, `account.requirements_due`, `account.restricted`, `swap.created`, `swap.completed`, `swap.failed`, `swap.refunded`, `swap.expired`, `subscription.created`, `subscription.updated`, `subscription.trial_will_end`, `subscription.past_due`, `subscription.paused`, `subscription.resumed`, `subscription.canceled`, `subscription.period.paid`, `subscription.period.payment_failed`, `support.conversation.created`, `support.message.received`, `support.conversation.closed` | Yes | Every event type. Payments on every rail use the same payment.* types (data.rail says which). Handle the types you need and acknowledge (2xx) any others; new types may be added. |
| `created` | integer | Yes | Unix time (seconds) the event was created. |
| `livemode` | boolean | Yes | false for events from test payments. |
| `data` | object | Yes | For payment events from a checkout, the fields below. Crypto and Card to Crypto paid to your wallet carry `session_id: null` with `payment_id`, `source`, `method`, `coin`, `coin_amount`, `wallet` and transaction hashes; every other event its own fields. All of them carry `rail`. |
| `data.session_id` | string or null | No | The checkout session; null for a payment paid straight to your wallet. |
| `data.order_id` | string or null | No | Your order ID, if known. |
| `data.reference` | string or null | No | The `reference` you sent when creating the session. |
| `data.amount` | integer or null | No | Minor units. For `refund.succeeded`, the total refunded so far. |
| `data.currency` | string or null | No | ISO 4217 code. |
| `data.status` | string or null | No | The order's payment status after the event (for example `captured`, `refunded`). |
| `data.rail` | one of `card`, `crypto`, `card_to_crypto` | Yes | The rail an event or payment is on: card checkout; crypto (crypto checkout, or a coin paid straight to your wallet through the plugin or the gateway API); or Card to Crypto (card, Cash App or Venmo paid out to your wallet in USDC). |
| `data.payment_reference` | string or null | No | OnCharge's reference for the payment (`ocpay_…`). |
| `data.payment_link_id` | string (uuid) or null | No | The payment link the checkout was made from (`/api/v1/payment-links`), or null. |
| `data.invoice_id` | string (uuid) | No | Only on a payment for an OnCharge invoice: the invoice's id (see Invoices). |
| `data.payment_method` | one of `card`, `bank_debit`, `cash_app_pay`, `klarna`, `affirm`, `afterpay`, or `null` | No | How the shopper paid: `card`, or a way to pay beyond cards the store turned on (bank debit, Cash App Pay, Klarna, Affirm, Afterpay; see the Payment methods guide). Null for crypto. |
| `data.tax` | object or null | No | Sales tax on the payment, on payment, refund and chargeback events of a taxed payment only. |
| `data.tax.status` | one of `awaiting_address`, `calculated`, `pending`, `failed`, `collected`, `partly_refunded`, `refunded` | Yes | `awaiting_address`: no address yet, the payment waits. `calculated`: not paid yet. `pending`: tax included, charged while the calculation was unavailable; worked out shortly. `failed`: the calculation failed (`error`), the payment waits. `collected`, `partly_refunded`, `refunded`: paid, and how much of the tax was given back. |
| `data.tax.inclusive` | boolean | Yes | true when the listed prices include the tax. |
| `data.tax.currency` | string or null | Yes |  |
| `data.tax.subtotal` | integer or null | Yes | Before tax, minor units. |
| `data.tax.amount` | integer or null | Yes | The tax, minor units. |
| `data.tax.total` | integer or null | Yes | What the customer pays, minor units. |
| `data.tax.shipping` | integer | Yes | The shipping charge inside the total, minor units. |
| `data.tax.jurisdictions` | array of object | Yes |  |
| `data.tax.refunded` | integer | Yes | Tax given back so far with refunds and lost disputes, minor units. |
| `data.tax.error` | string or null | Yes | `tax_address_invalid` or `tax_unavailable` when `status` is `failed`. |
| `data.reason` | one of `limit_exceeded` | No | Only on `payment.refused` when OnCharge refused the payment itself: `limit_exceeded` (the store reached a limit OnCharge set on its account, such as a daily volume cap). Absent when the bank declined it. |
| `event` | one of `payment.pending`, `payment.authorized`, `payment.captured`, `payment.under_review`, `payment.refused`, `payment.cancelled`, `payment.expired`, `payment.capture_failed`, `refund.succeeded`, `refund.failed`, `chargeback.opened`, `dispute.evidence_due`, `chargeback.won`, `chargeback.lost`, `fraud_warning.received`, `delivery.confirmed`, `payout.paid`, `payout.failed`, `payout.returned`, `account.updated`, `account.requirements_due`, `account.restricted`, `swap.created`, `swap.completed`, `swap.failed`, `swap.refunded`, `swap.expired`, `subscription.created`, `subscription.updated`, `subscription.trial_will_end`, `subscription.past_due`, `subscription.paused`, `subscription.resumed`, `subscription.canceled`, `subscription.period.paid`, `subscription.period.payment_failed`, `support.conversation.created`, `support.message.received`, `support.conversation.closed` | No | Same as `type`. Kept for older plugins; only on payment events from a checkout. **Deprecated.** |
| `status` | string or null | No | Same as `data.status`. Kept for older plugins; only on payment events from a checkout. **Deprecated.** |
| `psp_reference` | string or null | No | Kept for older plugins, which store it as the order's transaction id: a payment made before 2026-12-01 keeps its original value here; from 2026-12-01 on it is the payment's OnCharge reference (`ocpay_…`, the same as `data.payment_reference`). Only on payment events from a checkout. **Deprecated.** |

```json title="Response"
{
  "id": "string",
  "type": "payment.pending",
  "created": 0,
  "livemode": true,
  "data": {
    "session_id": "string",
    "order_id": "string",
    "reference": "string",
    "amount": 0,
    "currency": "string",
    "status": "string",
    "rail": "card",
    "payment_reference": "string",
    "payment_link_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "invoice_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "payment_method": "card",
    "tax": {
      "status": "awaiting_address",
      "inclusive": true,
      "currency": "string",
      "subtotal": 0,
      "amount": 0,
      "total": 0,
      "shipping": 0,
      "jurisdictions": [
        {
          "state": null,
          "rate": null,
          "amount": null
        }
      ],
      "refunded": 0,
      "error": "string"
    },
    "reason": "limit_exceeded"
  },
  "event": "payment.pending",
  "status": "string",
  "psp_reference": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The event. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Send an event to an endpoint again {#replayevent}

```http
POST /api/v1/events/{event_id}/replay
```

Sends an event from the last 30 days to one of your webhook endpoints again, with the same id and body, signed with that endpoint's secret. It goes even to an endpoint that has not chosen the event's type; a disabled endpoint answers 409. The delivery is retried like any other.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `event_id` | path | string | Yes | An event id (`evt_…`). |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `endpoint_id` | string (uuid) | Yes | One of your webhook endpoints (the Webhooks page shows their ids). |

```json title="Request"
{
  "endpoint_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `event_id` | string | Yes |  |
| `delivery_id` | string (uuid) | Yes |  |
| `status` | one of `pending` | Yes |  |

```json title="Response"
{
  "event_id": "string",
  "delivery_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "status": "pending"
}
```

| Status | Meaning |
|---|---|
| `200` | Queued. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | The endpoint is disabled. |

## Payments and balance {#payments-and-balance}

Payments on every rail, payouts to your bank and your balance, as the portal shows them.

### List payments {#listpayments}

```http
GET /api/v1/payments
```

The store's payments on every rail, newest first, from the activity ledger the portal reads: card checkout, crypto checkout, and crypto and Card to Crypto paid straight to your wallet through the plugin and the gateway API. `kind` lists refunds, disputes or crypto conversions instead, or all of them.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `kind` | query | one of `payment`, `refund`, `dispute`, `swap`, `all` | No | payment (default), refund, dispute, swap or all. |
| `rail` | query | one of `card`, `crypto`, `card_to_crypto` | No |  |
| `status` | query | one of `paid`, `pending`, `refunded`, `failed`, `disputed`, `review`, `waiting`, `uncaptured` | No |  |
| `source` | query | one of `wallet`, `plugin`, `gateway` | No | Paid straight to your wallet (plugin or gateway API), or one of them. |
| `q` | query | string | No | An OnCharge reference or id, a transaction hash, an email or an order number. |
| `from` | query | string (date) | No |  |
| `to` | query | string (date) | No |  |
| `min` | query | string | No | Smallest amount, in major units. |
| `max` | query | string | No | Largest amount, in major units. |
| `method` | query | one of `card`, `crypto`, `cashapp`, `venmo`, `bank` | No |  |
| `signals` | query | string | No | Comma-separated: review, fraud_warning, disputed (every one listed must hold). |
| `limit` | query | integer | No |  |
| `cursor` | query | string | No | `next_cursor` of the previous page, sent with the same filters. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `payments` | array of object | Yes |  |
| `payments[].id` | string (uuid) | Yes | OnCharge's id of the payment, refund, dispute or conversion. |
| `payments[].reference` | string | Yes | OnCharge's reference: `ocpay_…`, `ocrfd_…`, `ocdsp_…`, `ocswp_…`. |
| `payments[].kind` | one of `payment`, `refund`, `dispute`, `swap` | Yes |  |
| `payments[].rail` | one of `card`, `crypto`, `card_to_crypto` | Yes | The rail an event or payment is on: card checkout; crypto (crypto checkout, or a coin paid straight to your wallet through the plugin or the gateway API); or Card to Crypto (card, Cash App or Venmo paid out to your wallet in USDC). |
| `payments[].status` | string | Yes | paid, pending, authorized, review, refunded, partly_refunded, declined, failed, cancelled, expired, disputed, won, lost, completed… |
| `payments[].status_label` | string | No |  |
| `payments[].amount` | integer or null | No | Null when only coin amounts are known. |
| `payments[].currency` | string or null | No |  |
| `payments[].amount_text` | string or null | No | The coin amount as text when the amount in money is not known. |
| `payments[].fee` | integer or null | No |  |
| `payments[].net` | integer or null | No |  |
| `payments[].coin` | string or null | No |  |
| `payments[].coin_amount` | string or null | No |  |
| `payments[].coin_fee` | string or null | No |  |
| `payments[].coin_net` | string or null | No |  |
| `payments[].order_id` | string or null | No |  |
| `payments[].method` | string or null | No | Visa •••• 4242, Cash App, USDT (TRC20)… |
| `payments[].customer_email` | string or null | No |  |
| `payments[].created_at` | string (date-time) | Yes |  |
| `payments[].payment_reference` | string or null | No | The payment a refund or dispute belongs to. |
| `payments[].payout_reference` | string or null | No |  |
| `payments[].payment_tx` | string or null | No | The paying transaction on a public chain. |
| `payments[].payout_tx` | string or null | No | The transaction that paid your wallet. |
| `payments[].refundable` | integer | No | Minor units that can still be refunded (0 when this entry cannot be). |
| `payments[].signals` | array of one of `review`, `fraud_warning`, `disputed` | No |  |
| `payments[].tax` | integer or null | No | Sales tax inside `amount`, minor units, signed like it (a refund's share given back is negative); null when untaxed. |
| `next_cursor` | string or null | Yes | Pass as `cursor` for the next page; null on the last page. |

```json title="Response"
{
  "payments": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "reference": "string",
      "kind": "payment",
      "rail": "card",
      "status": "string",
      "status_label": "string",
      "amount": 0,
      "currency": "string",
      "amount_text": "string",
      "fee": 0,
      "net": 0,
      "coin": "string",
      "coin_amount": "string",
      "coin_fee": "string",
      "coin_net": "string",
      "order_id": "string",
      "method": "string",
      "customer_email": "string",
      "created_at": "2026-01-01T00:00:00.000Z",
      "payment_reference": "string",
      "payout_reference": "string",
      "payment_tx": "string",
      "payout_tx": "string",
      "refundable": 0,
      "signals": [
        "review"
      ],
      "tax": 0
    }
  ],
  "next_cursor": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | Payments. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |

### List payouts {#listpayouts}

```http
GET /api/v1/payouts
```

The store's payouts to its bank, newest first: on their way, paid, not delivered, returned or canceled, and bank debits. Payouts pay orders whose delivery was confirmed; crypto paid to your own wallet is never in a payout.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `status` | query | one of `paid`, `on_its_way`, `failed`, `returned`, `canceled` | No |  |
| `from` | query | string (date) | No |  |
| `to` | query | string (date) | No |  |
| `min` | query | string | No |  |
| `max` | query | string | No |  |
| `q` | query | string | No | An order number, payment id or payout id. |
| `limit` | query | integer | No |  |
| `cursor` | query | string | No | `next_cursor` of the previous page, sent with the same filters. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `payouts` | array of object | Yes |  |
| `payouts[].id` | string (uuid) | Yes | The payout id the payout.paid, payout.failed and payout.returned events carry. |
| `payouts[].type` | one of `payout`, `bank_debit` | Yes |  |
| `payouts[].status` | one of `paid`, `on_its_way`, `failed`, `returned`, `canceled` | Yes |  |
| `payouts[].status_label` | string | No |  |
| `payouts[].amount` | integer | Yes | Minor units; negative for a bank debit. |
| `payouts[].currency` | string | Yes |  |
| `payouts[].created_at` | string (date-time) | Yes |  |
| `payouts[].arrival_date` | string or null | No |  |
| `payouts[].orders` | integer or null | No | Orders it paid, once its statement exists. |
| `payouts[].items` | integer | No |  |
| `payouts[].problem` | string or null | No | Why it did not reach your bank (or, a debit card payout, your card), in plain words. |
| `payouts[].method` | one of `standard`, `instant` | No | `instant`: a debit card payout you asked for; `amount` is what reached the card. |
| `payouts[].fee` | integer | No | OnCharge's fee taken out of a debit card payout, in minor units (0 for a standard payout, and for one that did not arrive). |
| `next_cursor` | string or null | Yes | Pass as `cursor` for the next page; null on the last page. |

```json title="Response"
{
  "payouts": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "type": "payout",
      "status": "paid",
      "status_label": "string",
      "amount": 0,
      "currency": "string",
      "created_at": "2026-01-01T00:00:00.000Z",
      "arrival_date": "string",
      "orders": 0,
      "items": 0,
      "problem": "string",
      "method": "standard",
      "fee": 0
    }
  ],
  "next_cursor": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | Payouts. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |

### Card totals for a period {#getpayoutsummary}

```http
GET /api/v1/payouts/summary
```

Gross volume, refunds, OnCharge's fees and what you keep, per currency, for a period (default the last 30 days, at most a year).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `from` | query | string (date) | No | First day (UTC). |
| `to` | query | string (date) | No | Last day (UTC). |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `period` | object | Yes |  |
| `period.from` | string (date) | No |  |
| `period.to` | string (date) | No |  |
| `totals` | array of object | Yes |  |
| `pricing` | object or null | No |  |
| `fees` | array of object | No |  |

```json title="Response"
{
  "period": {
    "from": "string",
    "to": "string"
  },
  "totals": [
    {}
  ],
  "pricing": {},
  "fees": [
    {}
  ]
}
```

| Status | Meaning |
|---|---|
| `200` | Totals. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |

### Quote a debit card payout {#getinstantpayout}

```http
GET /api/v1/payouts/instant
```

Whether the store can take a debit card payout now: what would reach the card, OnCharge's fee (1.5%, at least 0.50, taken out of the payout), what would leave the balance and when it should arrive; or why it cannot. Only money already released for delivered orders, and only what the next standard payout would pay, is ever payable. Claims nothing. The debit card is added in the dashboard (it needs a one-time code). 404 `not_available` where debit card payouts are not switched on.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `instant_payout` | object | Yes | What could reach your debit card now (money already released for delivered orders only), or why nothing can. |
| `instant_payout.store_id` | string (uuid) | Yes |  |
| `instant_payout.available` | boolean | Yes |  |
| `instant_payout.block` | object or null | Yes |  |
| `instant_payout.amount` | integer | Yes | What would reach the card, in minor units. |
| `instant_payout.fee` | integer | Yes | OnCharge's fee, in minor units: 1.5% of the total, at least 0.50. |
| `instant_payout.total` | integer | Yes | What would leave your balance: amount + fee. |
| `instant_payout.currency` | one of `USD` | Yes |  |
| `instant_payout.arrival` | object | Yes |  |
| `instant_payout.arrival.text` | string | No |  |
| `instant_payout.arrival.minutes` | integer | No |  |
| `instant_payout.arrival.estimate` | string (date-time) or null | No |  |
| `instant_payout.card` | object or null | Yes | The debit card on file, masked. Added in the dashboard only. |
| `instant_payout.card.brand` | string or null | No |  |
| `instant_payout.card.last4` | string or null | No |  |
| `instant_payout.card.exp_month` | integer or null | No |  |
| `instant_payout.card.exp_year` | integer or null | No |  |
| `instant_payout.card.status` | one of `cooling_off`, `ready` | No |  |
| `instant_payout.card.usable_from` | string (date-time) | No |  |
| `instant_payout.card.added_at` | string (date-time) | No |  |
| `instant_payout.fee_rule` | object | Yes |  |
| `instant_payout.fee_rule.percent` | number | No |  |
| `instant_payout.fee_rule.minimum` | integer | No |  |
| `instant_payout.limits` | object | Yes |  |
| `instant_payout.limits.min` | integer | No |  |
| `instant_payout.limits.per_payout_max` | integer | No |  |
| `instant_payout.limits.daily_remaining_amount` | integer | No |  |
| `instant_payout.limits.daily_remaining_count` | integer | No |  |

```json title="Response"
{
  "instant_payout": {
    "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "available": true,
    "block": {
      "code": "not_available",
      "message": "string",
      "until": "2026-01-01T00:00:00.000Z",
      "action": {
        "label": null,
        "href": null
      }
    },
    "amount": 0,
    "fee": 0,
    "total": 0,
    "currency": "USD",
    "arrival": {
      "text": "Usually within 30 minutes",
      "minutes": 0,
      "estimate": "2026-01-01T00:00:00.000Z"
    },
    "card": {
      "brand": "string",
      "last4": "string",
      "exp_month": 0,
      "exp_year": 0,
      "status": "cooling_off",
      "usable_from": "2026-01-01T00:00:00.000Z",
      "added_at": "2026-01-01T00:00:00.000Z"
    },
    "fee_rule": {
      "percent": 0,
      "minimum": 0
    },
    "limits": {
      "min": 0,
      "per_payout_max": 0,
      "daily_remaining_amount": 0,
      "daily_remaining_count": 0
    }
  }
}
```

| Status | Meaning |
|---|---|
| `200` | The quote. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Make a debit card payout {#createinstantpayout}

```http
POST /api/v1/payouts/instant
```

Sends what the quote showed to the store's debit card. An `Idempotency-Key` is required: the same key always answers with the same payout (200, `replay: true`) and never pays twice. Send `expected_amount` (the quote's `amount`): when what is payable changed, nothing is paid and the answer is 409 `quote_changed` with a fresh quote. Refused (409) while payouts are paused (a bank change's cooling-off included), during a new card's cooling-off, over the daily limits, or when nothing released is payable. The result arrives as `payout.paid` or `payout.failed` with `method: "instant"`; a failed debit card payout goes to your bank with your next payout, its fee refunded.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `expected_amount` | integer (≥ 1) | No | What you expect to reach the card, in minor units. |

```json title="Request"
{
  "expected_amount": 1
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `payout` | object | Yes |  |
| `payout.id` | string (uuid) | Yes | The id the payouts list and the payout.paid / payout.failed events carry. |
| `payout.method` | one of `instant` | Yes |  |
| `payout.status` | one of `paid`, `on_its_way`, `failed`, `returned`, `canceled` | Yes |  |
| `payout.amount` | integer | Yes | What reaches the card. |
| `payout.fee` | integer | Yes |  |
| `payout.total` | integer | Yes | What left your balance. |
| `payout.currency` | string | Yes |  |
| `payout.created_at` | string (date-time) | Yes |  |
| `payout.arrival` | object | Yes |  |
| `payout.arrival.text` | string | No |  |
| `payout.arrival.estimate` | string (date-time) or null | No |  |
| `replay` | boolean | Yes | True when this Idempotency-Key was used before: the same payout, not a new one. |

```json title="Response"
{
  "payout": {
    "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
    "method": "instant",
    "status": "paid",
    "amount": 0,
    "fee": 0,
    "total": 0,
    "currency": "string",
    "created_at": "2026-01-01T00:00:00.000Z",
    "arrival": {
      "text": "string",
      "estimate": "2026-01-01T00:00:00.000Z"
    }
  },
  "replay": true
}
```

| Status | Meaning |
|---|---|
| `200` | This key was used before: the same payout. |
| `201` | Made. |
| `400` | Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote. |
| `502` | Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote. |
| `503` | Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote. |

### Retrieve the balance {#getbalance}

```http
GET /api/v1/balance
```

Where your money is, as the Balances page shows it.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `as_of` | string (date-time) | Yes |  |
| `card` | object | Yes |  |
| `next_payouts` | array of object | No |  |
| `on_its_way` | array of object | No |  |
| `delivery` | object | No |  |
| `wallet` | object or null | No |  |

```json title="Response"
{
  "as_of": "2026-01-01T00:00:00.000Z",
  "card": {},
  "next_payouts": [
    {}
  ],
  "on_its_way": [
    {}
  ],
  "delivery": {},
  "wallet": {}
}
```

| Status | Meaning |
|---|---|
| `200` | The balance. |

### List payment methods {#listpaymentmethods}

```http
GET /api/v1/payment-methods
```

The store's ways to pay beyond cards (bank debit, Cash App Pay, Klarna, Affirm, Afterpay), whether each is turned on, and its status in plain words. Read-only: owners and admins turn methods on in the portal.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `store_id` | string (uuid) | Yes |  |
| `methods` | array of object | Yes | Only the methods OnCharge offers today. |
| `methods[].method` | one of `bank_debit`, `cash_app_pay`, `klarna`, `affirm`, `afterpay` | Yes |  |
| `methods[].label` | string | Yes |  |
| `methods[].summary` | string | Yes | What the method does for your store, in one or two sentences. |
| `methods[].enabled` | boolean | Yes | Whether the store turned it on (owners and admins, in the portal under Settings → Payment setup). |
| `methods[].state` | one of `off`, `not_available`, `requesting`, `reviewing`, `needs_information`, `inactive`, `active` | Yes | `active`: shoppers see it at checkout. `not_available`: not offered to this store's business. |
| `methods[].status_text` | string | Yes | The state in plain words. |
| `methods[].needs` | array of string | Yes | What is still needed before it can be approved, in words. |

```json title="Response"
{
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "methods": [
    {
      "method": "bank_debit",
      "label": "Bank debit (ACH)",
      "summary": "string",
      "enabled": true,
      "state": "off",
      "status_text": "string",
      "needs": [
        "string"
      ]
    }
  ]
}
```

| Status | Meaning |
|---|---|
| `200` | The store's payment methods. |

## Payment links {#payment-links}

Shareable OnCharge pages (/l/<code>) that take a payment without a website. Each payment is an ordinary checkout session.

### List payment links {#listpaymentlinks}

```http
GET /api/v1/payment-links
```

The store's payment links, newest first, each with its views, checkouts, payments and revenue. Sign an empty body.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `active` | query | boolean | No | Only links that are on (`true`) or off (`false`). |
| `limit` | query | integer | No |  |
| `before` | query | string (date-time) | No | `next_before` from the previous page. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `object` | `"list"` | Yes |  |
| `data` | array of object | Yes |  |
| `data[].id` | string (uuid) | Yes |  |
| `data[].object` | `"payment_link"` | Yes |  |
| `data[].store_id` | string (uuid) | Yes |  |
| `data[].code` | string | Yes |  |
| `data[].url` | string (uri) | Yes | The link to share: `https://app.oncharge.io/l/<code>`. |
| `data[].title` | string | Yes |  |
| `data[].description` | string or null | No |  |
| `data[].amount_type` | one of `fixed`, `customer_chosen` | Yes |  |
| `data[].amount` | integer or null | No |  |
| `data[].min_amount` | integer or null | No |  |
| `data[].max_amount` | integer or null | No |  |
| `data[].preset_amount` | integer or null | No |  |
| `data[].currency` | string | Yes |  |
| `data[].adjustable_quantity` | boolean | No |  |
| `data[].max_quantity` | integer | No |  |
| `data[].collect_shipping` | boolean | No |  |
| `data[].collect_phone` | boolean | No |  |
| `data[].success_url` | string or null | No |  |
| `data[].rails` | array of one of `card`, `crypto` | No |  |
| `data[].active` | boolean | Yes |  |
| `data[].status` | one of `active`, `inactive`, `expired` | Yes | `active`: takes payments; `inactive`: turned off; `expired`: past `expires_at`. |
| `data[].expires_at` | string (date-time) or null | No |  |
| `data[].deactivated_at` | string (date-time) or null | No |  |
| `data[].created_via` | one of `dashboard`, `api` | No |  |
| `data[].created_at` | string (date-time) | Yes |  |
| `data[].updated_at` | string (date-time) or null | No |  |
| `data[].stats` | object | Yes |  |
| `data[].stats.views` | integer | Yes | Visits of the link page while it was active. |
| `data[].stats.checkouts` | integer | Yes | Checkouts started from the link. |
| `data[].stats.payments` | integer | Yes | Paid checkouts (captured, or refunded afterwards). |
| `data[].stats.revenue` | integer | Yes | What the paid checkouts came to before refunds, minor units of the link's currency. |
| `data[].stats.refunded` | integer | Yes | What was refunded of them. |
| `data[].qr_code` | string or null | No | An SVG QR code of `url` as a data URI (single-link responses). |
| `has_more` | boolean | Yes |  |
| `next_before` | string or null | Yes | Pass as `before` for the next page. |

```json title="Response"
{
  "object": "list",
  "data": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "object": "payment_link",
      "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "code": "string",
      "url": "string",
      "title": "string",
      "description": "string",
      "amount_type": "fixed",
      "amount": 0,
      "min_amount": 0,
      "max_amount": 0,
      "preset_amount": 0,
      "currency": "string",
      "adjustable_quantity": true,
      "max_quantity": 0,
      "collect_shipping": true,
      "collect_phone": true,
      "success_url": "string",
      "rails": [
        "card"
      ],
      "active": true,
      "status": "active",
      "expires_at": "2026-01-01T00:00:00.000Z",
      "deactivated_at": "2026-01-01T00:00:00.000Z",
      "created_via": "dashboard",
      "created_at": "2026-01-01T00:00:00.000Z",
      "updated_at": "2026-01-01T00:00:00.000Z",
      "stats": {
        "views": 0,
        "checkouts": 0,
        "payments": 0,
        "revenue": 0,
        "refunded": 0
      },
      "qr_code": "string"
    }
  ],
  "has_more": true,
  "next_before": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | A page of payment links. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |

### Create a payment link {#createpaymentlink}

```http
POST /api/v1/payment-links
```

Makes a link at `https://app.oncharge.io/l/<code>`. Each visit that pays creates an ordinary checkout session (card or crypto, whichever the store has on), so the `payment.*` webhooks fire for it with `data.reference` = `link_<code>`, and shipped goods are paid out after delivery like any other order.

Limits: a fixed amount of at least 50 cents; `amount` × `max_quantity` (or `max_amount`) at most $10,000; quantity up to 99; expiry at most two years ahead. A store that ships what it sells must set `collect_shipping`. `success_url` must be https on one of the store's registered domains.

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | string (min 1 chars, max 120 chars) | Yes |  |
| `description` | string or null (max 500 chars) | No |  |
| `amount_type` | one of `fixed`, `customer_chosen` | No | `fixed`: the customer pays `amount` per item. `customer_chosen`: they choose between `min_amount` and `max_amount`. Default `"fixed"`. |
| `amount` | integer or null (≥ 1) | No | Per item, for a fixed amount. Minor units (cents), at least 50. |
| `min_amount` | integer or null (≥ 1) | No | Customer-chosen amounts: the least they may pay (default 50). |
| `max_amount` | integer or null (≥ 1) | No | Customer-chosen amounts: the most they may pay (default 1000000, $10,000). |
| `preset_amount` | integer or null (≥ 1) | No | Customer-chosen amounts: where the amount field starts. |
| `currency` | string | No | Card payments are USD only on stores paid out per delivered order. Default `"USD"`. |
| `adjustable_quantity` | boolean | No | Default `false`. |
| `max_quantity` | integer or null (≥ 1, ≤ 99) | No | Default 10 when `adjustable_quantity` is on. |
| `collect_shipping` | boolean | No | Ask for a shipping address (required on stores that ship what they sell). Default `false`. |
| `collect_phone` | boolean | No | Default `false`. |
| `success_url` | string (uri) or null | No | https, on one of the store's registered domains. Default: OnCharge's thank-you page. |
| `rails` | array of one of `card`, `crypto` or null (≥ 1 items) | No | Ways to pay allowed on the link (default both); the store must have them on. |
| `expires_at` | string (date-time) or null | No |  |

```json title="Request"
{
  "title": "Consultation deposit",
  "amount": 5000,
  "currency": "USD",
  "collect_phone": true,
  "success_url": "https://shop.example.com/thank-you"
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"payment_link"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `code` | string | Yes |  |
| `url` | string (uri) | Yes | The link to share: `https://app.oncharge.io/l/<code>`. |
| `title` | string | Yes |  |
| `description` | string or null | No |  |
| `amount_type` | one of `fixed`, `customer_chosen` | Yes |  |
| `amount` | integer or null | No |  |
| `min_amount` | integer or null | No |  |
| `max_amount` | integer or null | No |  |
| `preset_amount` | integer or null | No |  |
| `currency` | string | Yes |  |
| `adjustable_quantity` | boolean | No |  |
| `max_quantity` | integer | No |  |
| `collect_shipping` | boolean | No |  |
| `collect_phone` | boolean | No |  |
| `success_url` | string or null | No |  |
| `rails` | array of one of `card`, `crypto` | No |  |
| `active` | boolean | Yes |  |
| `status` | one of `active`, `inactive`, `expired` | Yes | `active`: takes payments; `inactive`: turned off; `expired`: past `expires_at`. |
| `expires_at` | string (date-time) or null | No |  |
| `deactivated_at` | string (date-time) or null | No |  |
| `created_via` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | Yes |  |
| `updated_at` | string (date-time) or null | No |  |
| `stats` | object | Yes |  |
| `stats.views` | integer | Yes | Visits of the link page while it was active. |
| `stats.checkouts` | integer | Yes | Checkouts started from the link. |
| `stats.payments` | integer | Yes | Paid checkouts (captured, or refunded afterwards). |
| `stats.revenue` | integer | Yes | What the paid checkouts came to before refunds, minor units of the link's currency. |
| `stats.refunded` | integer | Yes | What was refunded of them. |
| `qr_code` | string or null | No | An SVG QR code of `url` as a data URI (single-link responses). |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "payment_link",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "code": "string",
  "url": "string",
  "title": "string",
  "description": "string",
  "amount_type": "fixed",
  "amount": 0,
  "min_amount": 0,
  "max_amount": 0,
  "preset_amount": 0,
  "currency": "string",
  "adjustable_quantity": true,
  "max_quantity": 0,
  "collect_shipping": true,
  "collect_phone": true,
  "success_url": "string",
  "rails": [
    "card"
  ],
  "active": true,
  "status": "active",
  "expires_at": "2026-01-01T00:00:00.000Z",
  "deactivated_at": "2026-01-01T00:00:00.000Z",
  "created_via": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z",
  "stats": {
    "views": 0,
    "checkouts": 0,
    "payments": 0,
    "revenue": 0,
    "refunded": 0
  },
  "qr_code": "string"
}
```

| Status | Meaning |
|---|---|
| `201` | The new link, with its QR code. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `409` | `payment_method_unavailable`: none of the link's ways to pay (`rails`) is on for the store yet. |

### Retrieve a payment link {#getpaymentlink}

```http
GET /api/v1/payment-links/{link_id}
```

One link with its stats and QR code. Another store's link answers `404`. Sign an empty body.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `link_id` | path | string (uuid) | Yes | The payment link's `id`. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"payment_link"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `code` | string | Yes |  |
| `url` | string (uri) | Yes | The link to share: `https://app.oncharge.io/l/<code>`. |
| `title` | string | Yes |  |
| `description` | string or null | No |  |
| `amount_type` | one of `fixed`, `customer_chosen` | Yes |  |
| `amount` | integer or null | No |  |
| `min_amount` | integer or null | No |  |
| `max_amount` | integer or null | No |  |
| `preset_amount` | integer or null | No |  |
| `currency` | string | Yes |  |
| `adjustable_quantity` | boolean | No |  |
| `max_quantity` | integer | No |  |
| `collect_shipping` | boolean | No |  |
| `collect_phone` | boolean | No |  |
| `success_url` | string or null | No |  |
| `rails` | array of one of `card`, `crypto` | No |  |
| `active` | boolean | Yes |  |
| `status` | one of `active`, `inactive`, `expired` | Yes | `active`: takes payments; `inactive`: turned off; `expired`: past `expires_at`. |
| `expires_at` | string (date-time) or null | No |  |
| `deactivated_at` | string (date-time) or null | No |  |
| `created_via` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | Yes |  |
| `updated_at` | string (date-time) or null | No |  |
| `stats` | object | Yes |  |
| `stats.views` | integer | Yes | Visits of the link page while it was active. |
| `stats.checkouts` | integer | Yes | Checkouts started from the link. |
| `stats.payments` | integer | Yes | Paid checkouts (captured, or refunded afterwards). |
| `stats.revenue` | integer | Yes | What the paid checkouts came to before refunds, minor units of the link's currency. |
| `stats.refunded` | integer | Yes | What was refunded of them. |
| `qr_code` | string or null | No | An SVG QR code of `url` as a data URI (single-link responses). |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "payment_link",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "code": "string",
  "url": "string",
  "title": "string",
  "description": "string",
  "amount_type": "fixed",
  "amount": 0,
  "min_amount": 0,
  "max_amount": 0,
  "preset_amount": 0,
  "currency": "string",
  "adjustable_quantity": true,
  "max_quantity": 0,
  "collect_shipping": true,
  "collect_phone": true,
  "success_url": "string",
  "rails": [
    "card"
  ],
  "active": true,
  "status": "active",
  "expires_at": "2026-01-01T00:00:00.000Z",
  "deactivated_at": "2026-01-01T00:00:00.000Z",
  "created_via": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z",
  "stats": {
    "views": 0,
    "checkouts": 0,
    "payments": 0,
    "revenue": 0,
    "refunded": 0
  },
  "qr_code": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The link. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Update a payment link {#updatepaymentlink}

```http
POST /api/v1/payment-links/{link_id}
```

Changes any field of the link, checked as a whole link again, or turns it off (`active: false`) or back on (`active: true`). Switching `amount_type` drops the other kind's amounts.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `link_id` | path | string (uuid) | Yes | The payment link's `id`. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | string (min 1 chars, max 120 chars) | No |  |
| `description` | string or null (max 500 chars) | No |  |
| `amount_type` | one of `fixed`, `customer_chosen` | No | `fixed`: the customer pays `amount` per item. `customer_chosen`: they choose between `min_amount` and `max_amount`. Default `"fixed"`. |
| `amount` | integer or null (≥ 1) | No | Per item, for a fixed amount. Minor units (cents), at least 50. |
| `min_amount` | integer or null (≥ 1) | No | Customer-chosen amounts: the least they may pay (default 50). |
| `max_amount` | integer or null (≥ 1) | No | Customer-chosen amounts: the most they may pay (default 1000000, $10,000). |
| `preset_amount` | integer or null (≥ 1) | No | Customer-chosen amounts: where the amount field starts. |
| `currency` | string | No | Card payments are USD only on stores paid out per delivered order. Default `"USD"`. |
| `adjustable_quantity` | boolean | No | Default `false`. |
| `max_quantity` | integer or null (≥ 1, ≤ 99) | No | Default 10 when `adjustable_quantity` is on. |
| `collect_shipping` | boolean | No | Ask for a shipping address (required on stores that ship what they sell). Default `false`. |
| `collect_phone` | boolean | No | Default `false`. |
| `success_url` | string (uri) or null | No | https, on one of the store's registered domains. Default: OnCharge's thank-you page. |
| `rails` | array of one of `card`, `crypto` or null (≥ 1 items) | No | Ways to pay allowed on the link (default both); the store must have them on. |
| `expires_at` | string (date-time) or null | No |  |
| `active` | boolean | No | Turn the link off (`false`) or back on (`true`). |

```json title="Request"
{
  "title": "Consultation deposit (December)",
  "expires_at": "2026-12-31T23:59:59Z"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"payment_link"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `code` | string | Yes |  |
| `url` | string (uri) | Yes | The link to share: `https://app.oncharge.io/l/<code>`. |
| `title` | string | Yes |  |
| `description` | string or null | No |  |
| `amount_type` | one of `fixed`, `customer_chosen` | Yes |  |
| `amount` | integer or null | No |  |
| `min_amount` | integer or null | No |  |
| `max_amount` | integer or null | No |  |
| `preset_amount` | integer or null | No |  |
| `currency` | string | Yes |  |
| `adjustable_quantity` | boolean | No |  |
| `max_quantity` | integer | No |  |
| `collect_shipping` | boolean | No |  |
| `collect_phone` | boolean | No |  |
| `success_url` | string or null | No |  |
| `rails` | array of one of `card`, `crypto` | No |  |
| `active` | boolean | Yes |  |
| `status` | one of `active`, `inactive`, `expired` | Yes | `active`: takes payments; `inactive`: turned off; `expired`: past `expires_at`. |
| `expires_at` | string (date-time) or null | No |  |
| `deactivated_at` | string (date-time) or null | No |  |
| `created_via` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | Yes |  |
| `updated_at` | string (date-time) or null | No |  |
| `stats` | object | Yes |  |
| `stats.views` | integer | Yes | Visits of the link page while it was active. |
| `stats.checkouts` | integer | Yes | Checkouts started from the link. |
| `stats.payments` | integer | Yes | Paid checkouts (captured, or refunded afterwards). |
| `stats.revenue` | integer | Yes | What the paid checkouts came to before refunds, minor units of the link's currency. |
| `stats.refunded` | integer | Yes | What was refunded of them. |
| `qr_code` | string or null | No | An SVG QR code of `url` as a data URI (single-link responses). |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "payment_link",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "code": "string",
  "url": "string",
  "title": "string",
  "description": "string",
  "amount_type": "fixed",
  "amount": 0,
  "min_amount": 0,
  "max_amount": 0,
  "preset_amount": 0,
  "currency": "string",
  "adjustable_quantity": true,
  "max_quantity": 0,
  "collect_shipping": true,
  "collect_phone": true,
  "success_url": "string",
  "rails": [
    "card"
  ],
  "active": true,
  "status": "active",
  "expires_at": "2026-01-01T00:00:00.000Z",
  "deactivated_at": "2026-01-01T00:00:00.000Z",
  "created_via": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z",
  "stats": {
    "views": 0,
    "checkouts": 0,
    "payments": 0,
    "revenue": 0,
    "refunded": 0
  },
  "qr_code": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The changed link. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `payment_method_unavailable`: none of the link's ways to pay (`rails`) is on for the store yet. |

### Deactivate a payment link {#deactivatepaymentlink}

```http
POST /api/v1/payment-links/{link_id}/deactivate
```

Turns the link off: visits say it is no longer active and no new checkout starts. Its payments stay. Idempotent. Sign an empty body or `{}`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `link_id` | path | string (uuid) | Yes | The payment link's `id`. |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"payment_link"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `code` | string | Yes |  |
| `url` | string (uri) | Yes | The link to share: `https://app.oncharge.io/l/<code>`. |
| `title` | string | Yes |  |
| `description` | string or null | No |  |
| `amount_type` | one of `fixed`, `customer_chosen` | Yes |  |
| `amount` | integer or null | No |  |
| `min_amount` | integer or null | No |  |
| `max_amount` | integer or null | No |  |
| `preset_amount` | integer or null | No |  |
| `currency` | string | Yes |  |
| `adjustable_quantity` | boolean | No |  |
| `max_quantity` | integer | No |  |
| `collect_shipping` | boolean | No |  |
| `collect_phone` | boolean | No |  |
| `success_url` | string or null | No |  |
| `rails` | array of one of `card`, `crypto` | No |  |
| `active` | boolean | Yes |  |
| `status` | one of `active`, `inactive`, `expired` | Yes | `active`: takes payments; `inactive`: turned off; `expired`: past `expires_at`. |
| `expires_at` | string (date-time) or null | No |  |
| `deactivated_at` | string (date-time) or null | No |  |
| `created_via` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | Yes |  |
| `updated_at` | string (date-time) or null | No |  |
| `stats` | object | Yes |  |
| `stats.views` | integer | Yes | Visits of the link page while it was active. |
| `stats.checkouts` | integer | Yes | Checkouts started from the link. |
| `stats.payments` | integer | Yes | Paid checkouts (captured, or refunded afterwards). |
| `stats.revenue` | integer | Yes | What the paid checkouts came to before refunds, minor units of the link's currency. |
| `stats.refunded` | integer | Yes | What was refunded of them. |
| `qr_code` | string or null | No | An SVG QR code of `url` as a data URI (single-link responses). |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "payment_link",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "code": "string",
  "url": "string",
  "title": "string",
  "description": "string",
  "amount_type": "fixed",
  "amount": 0,
  "min_amount": 0,
  "max_amount": 0,
  "preset_amount": 0,
  "currency": "string",
  "adjustable_quantity": true,
  "max_quantity": 0,
  "collect_shipping": true,
  "collect_phone": true,
  "success_url": "string",
  "rails": [
    "card"
  ],
  "active": true,
  "status": "active",
  "expires_at": "2026-01-01T00:00:00.000Z",
  "deactivated_at": "2026-01-01T00:00:00.000Z",
  "created_via": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z",
  "stats": {
    "views": 0,
    "checkouts": 0,
    "payments": 0,
    "revenue": 0,
    "refunded": 0
  },
  "qr_code": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The link, now off. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

## Invoices {#invoices}

Bill a customer: draft, finalize, send and get paid on OnCharge's hosted invoice page through OnCharge checkout, by card or crypto. Reminders, mark paid, void and credit notes.

### List invoices {#listinvoices}

```http
GET /api/v1/invoices
```

The store's invoices, newest first. `kind=credit_note` lists credit notes.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `status` | query | one of `draft`, `open`, `overdue`, `paid`, `void`, `all` | No |  |
| `search` | query | string | No | An invoice number, a customer email, or part of a customer name. |
| `cursor` | query | string | No | `next_cursor` from the previous page. |
| `limit` | query | integer | No |  |
| `kind` | query | one of `invoice`, `credit_note` | No |  |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `invoices` | array of object | Yes |  |
| `invoices[].id` | string (uuid) | Yes |  |
| `invoices[].object` | one of `invoice`, `credit_note` | Yes |  |
| `invoices[].store_id` | string (uuid) | No |  |
| `invoices[].number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `invoices[].status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `invoices[].display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `invoices[].status_label` | string | No |  |
| `invoices[].currency` | string | Yes |  |
| `invoices[].currency_digits` | integer | No |  |
| `invoices[].customer` | object | No |  |
| `invoices[].customer.name` | string or null | No |  |
| `invoices[].customer.email` | string or null | No |  |
| `invoices[].customer.address` | object or null | No |  |
| `invoices[].shipping_address` | object or null | No |  |
| `invoices[].lines` | array of object | Yes |  |
| `invoices[].lines[].description` | string | No |  |
| `invoices[].lines[].quantity` | integer | No |  |
| `invoices[].lines[].unit_amount` | integer | No |  |
| `invoices[].lines[].tax_rate` | number | No |  |
| `invoices[].lines[].amount` | integer | No |  |
| `invoices[].lines[].tax_amount` | integer | No |  |
| `invoices[].lines[].requires_shipping` | boolean | No |  |
| `invoices[].subtotal` | integer | No |  |
| `invoices[].tax` | integer | No |  |
| `invoices[].total` | integer | Yes |  |
| `invoices[].amount_paid` | integer | No |  |
| `invoices[].amount_credited` | integer | No |  |
| `invoices[].amount_remaining` | integer | Yes |  |
| `invoices[].memo` | string or null | No |  |
| `invoices[].footer` | string or null | No |  |
| `invoices[].reply_to` | string or null | No |  |
| `invoices[].days_until_due` | integer | No |  |
| `invoices[].due_at` | string (date-time) or null | No |  |
| `invoices[].send_reminders` | boolean | No |  |
| `invoices[].metadata` | object | No |  |
| `invoices[].hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `invoices[].paid_out_of_band` | boolean | No |  |
| `invoices[].payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `invoices[].credit_note_for` | object or null | No |  |
| `invoices[].credit_note_for.id` | string | No |  |
| `invoices[].credit_note_for.number` | string or null | No |  |
| `invoices[].credit_reason` | string or null | No |  |
| `invoices[].source` | one of `dashboard`, `api` | No |  |
| `invoices[].created_at` | string (date-time) | No |  |
| `invoices[].finalized_at` | string or null | No |  |
| `invoices[].sent_at` | string or null | No |  |
| `invoices[].paid_at` | string or null | No |  |
| `invoices[].voided_at` | string or null | No |  |
| `invoices[].actions` | object | No | What can be done now. |
| `invoices[].events` | array of object | No | History (detail only). |
| `invoices[].payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `invoices[].payments[].payment_reference` | string | No |  |
| `invoices[].payments[].session_id` | string | No |  |
| `invoices[].payments[].amount` | integer | No |  |
| `invoices[].payments[].currency` | string | No |  |
| `invoices[].payments[].status` | string | No |  |
| `invoices[].payments[].rail` | one of `card`, `crypto` | No |  |
| `invoices[].credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `invoices[].payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `invoices[].payment_options[].rail` | string | No |  |
| `invoices[].payment_options[].available` | boolean | No |  |
| `invoices[].payment_options[].reason` | string or null | No |  |
| `invoices[].idempotent` | boolean | No |  |
| `invoices[].email_error` | string | No | Finalized, but the email could not be sent. |
| `next_cursor` | string or null | Yes | Pass back as `cursor`; null on the last page. |

```json title="Response"
{
  "invoices": [
    {
      "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "object": "invoice",
      "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
      "number": "string",
      "status": "draft",
      "display_status": "draft",
      "status_label": "string",
      "currency": "string",
      "currency_digits": 0,
      "customer": {
        "name": "string",
        "email": "string",
        "address": null
      },
      "shipping_address": {
        "line1": null,
        "line2": null,
        "city": null,
        "state": null,
        "postal_code": null,
        "country": null
      },
      "lines": [
        {
          "description": null,
          "quantity": null,
          "unit_amount": null,
          "tax_rate": null,
          "amount": null,
          "tax_amount": null,
          "requires_shipping": null
        }
      ],
      "subtotal": 0,
      "tax": 0,
      "total": 0,
      "amount_paid": 0,
      "amount_credited": 0,
      "amount_remaining": 0,
      "memo": "string",
      "footer": "string",
      "reply_to": "string",
      "days_until_due": 0,
      "due_at": "2026-01-01T00:00:00.000Z",
      "send_reminders": true,
      "metadata": {},
      "hosted_url": "string",
      "paid_out_of_band": true,
      "payment_reference": "string",
      "credit_note_for": {
        "id": "string",
        "number": "string"
      },
      "credit_reason": "string",
      "source": "dashboard",
      "created_at": "2026-01-01T00:00:00.000Z",
      "finalized_at": "string",
      "sent_at": "string",
      "paid_at": "string",
      "voided_at": "string",
      "actions": {},
      "events": [
        {}
      ],
      "payments": [
        {
          "payment_reference": null,
          "session_id": null,
          "amount": null,
          "currency": null,
          "status": null,
          "rail": null
        }
      ],
      "credit_notes": [
        {}
      ],
      "payment_options": [
        {
          "rail": null,
          "available": null,
          "reason": null
        }
      ],
      "idempotent": true,
      "email_error": "string"
    }
  ],
  "next_cursor": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | A page of invoices. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Create an invoice {#createinvoice}

```http
POST /api/v1/invoices
```

A new draft. With `finalize` it is also numbered and opened for payment; with `send` it is also emailed to the customer (PDF attached). The bill-to details live on the invoice. A repeat with the same `Idempotency-Key` returns the first draft with `idempotent: true`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `currency` | one of `USD`, `EUR`, `GBP`, `CAD`, `AUD`, `NZD`, `CHF`, `JPY` | No | Amounts are in this currency's minor units (JPY has none). Card payments on stores paid out per delivered order are USD only. Default `"USD"`. |
| `customer` | object | No |  |
| `customer.name` | string or null (max 200 chars) | No | Required to finalize. |
| `customer.email` | string (email) or null | No | Required to send. |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No | Needed when a line ships and the store's card payments are paid out on delivery. |
| `lines` | array of object (≤ 100 items) | No | On update, replaces every line. |
| `lines[].description` | string (min 1 chars, max 500 chars) | Yes |  |
| `lines[].quantity` | integer (≥ 1, ≤ 100000) | Yes |  |
| `lines[].unit_amount` | integer (≥ -10000000000, ≤ 10000000000) | Yes | Minor units of the invoice currency; negative for a discount line. quantity x unit_amount may be at most 10000000000 either way. |
| `lines[].tax_rate` | number or string | No | A percent from 0 to 100 with up to three decimals, e.g. `8.875`. Tax is rounded half away from zero per line. |
| `lines[].requires_shipping` | boolean | No | A shipped item. Card payments for it are paid out after the carrier confirms delivery to `shipping_address`, as for any order. Default `false`. |
| `memo` | string or null (max 2000 chars) | No |  |
| `footer` | string or null (max 1000 chars) | No |  |
| `reply_to` | string (email) or null | No | Where the customer's replies to invoice emails go. |
| `days_until_due` | integer (≥ 0, ≤ 365) | No | Default `30`. |
| `due_at` | string or null | No | A date (`YYYY-MM-DD`, end of that day UTC) or an ISO 8601 time. Overrides `days_until_due`; must not be in the past when finalizing. |
| `send_reminders` | boolean | No | Email the customer 1, 7 and 14 days after the due date while it is unpaid. Default `true`. |
| `metadata` | object | No |  |
| `finalize` | boolean | No | Finalize it straight away. |
| `send` | boolean | No | Finalize it and email it to the customer. |

```json title="Request"
{
  "customer": {
    "name": "Ada Lovelace",
    "email": "ada@example.com"
  },
  "lines": [
    {
      "description": "Consulting, November",
      "quantity": 10,
      "unit_amount": 15000,
      "tax_rate": 8.875
    }
  ],
  "days_until_due": 14,
  "send": true
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | Idempotent replay. |
| `201` | Created (and finalized or sent when asked). |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `store_inactive`: the store is not taking payments. |
| `422` | `invoice_incomplete`: finalizing needs a line, a total above zero and the customer's name; `invoice_too_large`: the lines would total more than 100000000000 minor units. |

### Retrieve an invoice {#getinvoice}

```http
GET /api/v1/invoices/{invoice_id}
```

The invoice or credit note with its lines, history, payments (OnCharge references), credit notes and how it can be paid now.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The invoice. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Update a draft {#updateinvoice}

```http
POST /api/v1/invoices/{invoice_id}
```

Any draft field; `lines` replaces every line. A finalized invoice cannot be edited: void it and create another, or issue a credit note.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `currency` | one of `USD`, `EUR`, `GBP`, `CAD`, `AUD`, `NZD`, `CHF`, `JPY` | No | Amounts are in this currency's minor units (JPY has none). Card payments on stores paid out per delivered order are USD only. Default `"USD"`. |
| `customer` | object | No |  |
| `customer.name` | string or null (max 200 chars) | No | Required to finalize. |
| `customer.email` | string (email) or null | No | Required to send. |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No | Needed when a line ships and the store's card payments are paid out on delivery. |
| `lines` | array of object (≤ 100 items) | No | On update, replaces every line. |
| `lines[].description` | string (min 1 chars, max 500 chars) | Yes |  |
| `lines[].quantity` | integer (≥ 1, ≤ 100000) | Yes |  |
| `lines[].unit_amount` | integer (≥ -10000000000, ≤ 10000000000) | Yes | Minor units of the invoice currency; negative for a discount line. quantity x unit_amount may be at most 10000000000 either way. |
| `lines[].tax_rate` | number or string | No | A percent from 0 to 100 with up to three decimals, e.g. `8.875`. Tax is rounded half away from zero per line. |
| `lines[].requires_shipping` | boolean | No | A shipped item. Card payments for it are paid out after the carrier confirms delivery to `shipping_address`, as for any order. Default `false`. |
| `memo` | string or null (max 2000 chars) | No |  |
| `footer` | string or null (max 1000 chars) | No |  |
| `reply_to` | string (email) or null | No | Where the customer's replies to invoice emails go. |
| `days_until_due` | integer (≥ 0, ≤ 365) | No | Default `30`. |
| `due_at` | string or null | No | A date (`YYYY-MM-DD`, end of that day UTC) or an ISO 8601 time. Overrides `days_until_due`; must not be in the past when finalizing. |
| `send_reminders` | boolean | No | Email the customer 1, 7 and 14 days after the due date while it is unpaid. Default `true`. |
| `metadata` | object | No |  |

```json title="Request"
{
  "memo": "Thanks for your business."
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The draft. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments. |

### Delete a draft {#deleteinvoice}

```http
DELETE /api/v1/invoices/{invoice_id}
```

Only a draft can be deleted.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string | No |  |
| `deleted` | boolean | No |  |

```json title="Response"
{
  "id": "string",
  "deleted": true
}
```

| Status | Meaning |
|---|---|
| `200` | Deleted. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments. |

### Finalize a draft {#finalizeinvoice}

```http
POST /api/v1/invoices/{invoice_id}/finalize
```

Gives the draft its store's next number (`INV-0001`), a due date and its hosted invoice page (`hosted_url`). Nothing on it can change afterwards. With `send`, also emails it.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `send` | boolean | No |  |

```json title="Request"
{
  "send": true
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The invoice. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments. |
| `422` | `invoice_incomplete`. |

### Email an open invoice {#sendinvoice}

```http
POST /api/v1/invoices/{invoice_id}/send
```

Emails the invoice (again) to the customer with its PDF attached and the payment link. Needs the customer's email.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The invoice. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments. |
| `422` | `invoice_incomplete`: no customer email. |
| `502` | `email_failed`: try again, or share `hosted_url`. |

### Void an open invoice {#voidinvoice}

```http
POST /api/v1/invoices/{invoice_id}/void
```

Cancels an open invoice nothing was paid on. Checkouts not yet started for it are closed; a payment already under way that completes is recorded on the invoice's history for you to refund.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `reason` | string or null (max 500 chars) | No |  |

```json title="Request"
{
  "reason": "string"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The invoice. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments. |

### Mark an invoice paid outside OnCharge {#markinvoicepaid}

```http
POST /api/v1/invoices/{invoice_id}/mark-paid
```

Records what is left to pay as paid by bank transfer, cash or cheque. The payment link stops working.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `note` | string or null (max 500 chars) | No |  |

```json title="Request"
{
  "note": "string"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The invoice. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments. |

### Issue a credit note {#createcreditnote}

```http
POST /api/v1/invoices/{invoice_id}/credit-notes
```

A numbered credit note (`CN-0001`) against an open or paid invoice. On an open invoice it lowers what is left to pay (a credit for all of it settles the invoice); on a paid one it records a credit, and with `refund` (only for an invoice paid through OnCharge) also refunds it to the customer's payment. The customer is emailed the note.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `amount` | integer (≥ 1) | No | One credit line of this many minor units. |
| `lines` | array of object (≥ 1 items, ≤ 100 items) | No |  |
| `lines[].description` | string | Yes |  |
| `lines[].quantity` | integer | No | Default `1`. |
| `lines[].unit_amount` | integer (≥ 1) | Yes |  |
| `lines[].tax_rate` | number or string | No |  |
| `reason` | one of `duplicate`, `fraudulent`, `order_change`, `product_unsatisfactory`, `other` | No | Default `"other"`. |
| `memo` | string or null (max 2000 chars) | No |  |
| `refund` | boolean | No | On an invoice paid through OnCharge, also refund the credit to the customer's payment. Default `false`. |

```json title="Request"
{
  "amount": 5000,
  "reason": "order_change",
  "memo": "Two hours fewer than quoted."
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |
| `refund` | object | No |  |
| `refund.ok` | boolean | No |  |
| `refund.status` | string | No |  |
| `refund.amount` | integer | No |  |
| `refund.message` | string | No |  |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string",
  "refund": {
    "ok": true,
    "status": "string",
    "amount": 0,
    "message": "string"
  }
}
```

| Status | Meaning |
|---|---|
| `200` | Idempotent replay. |
| `201` | The credit note (with `refund` when one was asked for). |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments. |
| `422` | `credit_too_large`: more than is left to pay (or, once paid, than the invoice). |

### Download an invoice PDF {#getinvoicepdf}

```http
GET /api/v1/invoices/{invoice_id}/pdf
```

The invoice or credit note as a PDF.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

| Status | Meaning |
|---|---|
| `200` | The PDF. |
| `404` | `not_found`: the object does not exist or belongs to another store. |

### Refund an extra payment {#refundextrainvoicepayment}

```http
POST /api/v1/invoices/{invoice_id}/refund-extra
```

Refunds what a payment paid beyond what the invoice took: a payment for an invoice that was already settled, voided or credited, or the part of one over what was left to pay. Such payments show in the invoice's history as `payment_unapplied` and the merchant is told. Refunded at most once per payment.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `invoice_id` | path | string (uuid) | Yes | The invoice (or credit note) id. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `payment_reference` | string | Yes | The payment's OnCharge reference (`ocpay_…`). |

```json title="Request"
{
  "payment_reference": "ocpay_3f2a9c1e0b7d4e6f8a1b2c3d4e5f6a7b"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `invoice`, `credit_note` | Yes |  |
| `store_id` | string (uuid) | No |  |
| `number` | string or null | No | `INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft. |
| `status` | one of `draft`, `open`, `paid`, `void`, `issued` | Yes | `issued` is a credit note's. |
| `display_status` | one of `draft`, `open`, `overdue`, `paid`, `void`, `issued` | No |  |
| `status_label` | string | No |  |
| `currency` | string | Yes |  |
| `currency_digits` | integer | No |  |
| `customer` | object | No |  |
| `customer.name` | string or null | No |  |
| `customer.email` | string or null | No |  |
| `customer.address` | object or null | No |  |
| `shipping_address` | object or null | No |  |
| `lines` | array of object | Yes |  |
| `lines[].description` | string | No |  |
| `lines[].quantity` | integer | No |  |
| `lines[].unit_amount` | integer | No |  |
| `lines[].tax_rate` | number | No |  |
| `lines[].amount` | integer | No |  |
| `lines[].tax_amount` | integer | No |  |
| `lines[].requires_shipping` | boolean | No |  |
| `subtotal` | integer | No |  |
| `tax` | integer | No |  |
| `total` | integer | Yes |  |
| `amount_paid` | integer | No |  |
| `amount_credited` | integer | No |  |
| `amount_remaining` | integer | Yes |  |
| `memo` | string or null | No |  |
| `footer` | string or null | No |  |
| `reply_to` | string or null | No |  |
| `days_until_due` | integer | No |  |
| `due_at` | string (date-time) or null | No |  |
| `send_reminders` | boolean | No |  |
| `metadata` | object | No |  |
| `hosted_url` | string or null | No | The hosted invoice page the customer pays on (once finalized). |
| `paid_out_of_band` | boolean | No |  |
| `payment_reference` | string or null | No | The OnCharge reference (`ocpay_…`) of the payment that paid it. |
| `credit_note_for` | object or null | No |  |
| `credit_note_for.id` | string | No |  |
| `credit_note_for.number` | string or null | No |  |
| `credit_reason` | string or null | No |  |
| `source` | one of `dashboard`, `api` | No |  |
| `created_at` | string (date-time) | No |  |
| `finalized_at` | string or null | No |  |
| `sent_at` | string or null | No |  |
| `paid_at` | string or null | No |  |
| `voided_at` | string or null | No |  |
| `actions` | object | No | What can be done now. |
| `events` | array of object | No | History (detail only). |
| `payments` | array of object | No | Payments made for it, by OnCharge reference (detail only). |
| `payments[].payment_reference` | string | No |  |
| `payments[].session_id` | string | No |  |
| `payments[].amount` | integer | No |  |
| `payments[].currency` | string | No |  |
| `payments[].status` | string | No |  |
| `payments[].rail` | one of `card`, `crypto` | No |  |
| `credit_notes` | array of object | No | Credit notes issued against it (detail only). |
| `payment_options` | array of object | No | How the customer can pay it now, and why a rail is off (detail only). |
| `payment_options[].rail` | string | No |  |
| `payment_options[].available` | boolean | No |  |
| `payment_options[].reason` | string or null | No |  |
| `idempotent` | boolean | No |  |
| `email_error` | string | No | Finalized, but the email could not be sent. |

```json title="Response"
{
  "id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "object": "invoice",
  "store_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
  "number": "string",
  "status": "draft",
  "display_status": "draft",
  "status_label": "string",
  "currency": "string",
  "currency_digits": 0,
  "customer": {
    "name": "string",
    "email": "string",
    "address": {
      "line1": "string",
      "line2": "string",
      "city": "string",
      "state": "string",
      "postal_code": "string",
      "country": "string"
    }
  },
  "shipping_address": {
    "line1": "string",
    "line2": "string",
    "city": "string",
    "state": "string",
    "postal_code": "string",
    "country": "string"
  },
  "lines": [
    {
      "description": "string",
      "quantity": 0,
      "unit_amount": 0,
      "tax_rate": 0,
      "amount": 0,
      "tax_amount": 0,
      "requires_shipping": true
    }
  ],
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "amount_paid": 0,
  "amount_credited": 0,
  "amount_remaining": 0,
  "memo": "string",
  "footer": "string",
  "reply_to": "string",
  "days_until_due": 0,
  "due_at": "2026-01-01T00:00:00.000Z",
  "send_reminders": true,
  "metadata": {},
  "hosted_url": "string",
  "paid_out_of_band": true,
  "payment_reference": "string",
  "credit_note_for": {
    "id": "string",
    "number": "string"
  },
  "credit_reason": "string",
  "source": "dashboard",
  "created_at": "2026-01-01T00:00:00.000Z",
  "finalized_at": "string",
  "sent_at": "string",
  "paid_at": "string",
  "voided_at": "string",
  "actions": {},
  "events": [
    {}
  ],
  "payments": [
    {
      "payment_reference": "string",
      "session_id": "string",
      "amount": 0,
      "currency": "string",
      "status": "string",
      "rail": "card"
    }
  ],
  "credit_notes": [
    {}
  ],
  "payment_options": [
    {
      "rail": "string",
      "available": true,
      "reason": "string"
    }
  ],
  "idempotent": true,
  "email_error": "string"
}
```

| Status | Meaning |
|---|---|
| `200` | The invoice, with `refund`. |
| `400` | `validation_error` (the message lists each invalid field) or `invalid_json`. |
| `404` | `not_found`: the object does not exist or belongs to another store. |
| `409` | `refund_failed`: the refund could not be made. |

## Subscriptions {#subscriptions}

Recurring billing: plans and add-ons, and subscriptions on them. Each period is an OnCharge invoice charged to the customer's card saved at your store; customers sign up and agree to the recurring charges on OnCharge's own pages. Subscriptions are not available yet: until they are turned on, every endpoint here answers 404 `not_found`.

### List plans {#listplans}

```http
GET /api/v1/plans
```

Your store's plans and add-ons, newest first (at most 200). Archived ones only with `include_archived=true`.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `include_archived` | query | boolean | No | Also list archived plans. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `data` | array of object | Yes | Newest first, at most 200. |
| `data[].id` | string (uuid) | Yes |  |
| `data[].object` | one of `plan`, `addon` | Yes |  |
| `data[].store_id` | string (uuid) | Yes |  |
| `data[].name` | string | Yes |  |
| `data[].description` | string or null | Yes |  |
| `data[].amount` | integer | Yes | Per period (per unit), minor units. |
| `data[].currency` | string | Yes |  |
| `data[].interval` | one of `day`, `week`, `month`, `year` or null | Yes | Null for an add-on. |
| `data[].interval_count` | integer or null | Yes |  |
| `data[].interval_text` | string or null | Yes | The period in words: `month`, `3 months`. Null for an add-on. |
| `data[].trial_days` | integer | Yes |  |
| `data[].intro` | object or null | Yes | The intro price per period (`amount`) for the first `periods` periods. |
| `data[].requires_shipping` | boolean | Yes |  |
| `data[].active` | boolean | Yes | False once archived. |
| `data[].metadata` | object | Yes |  |
| `data[].created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "data": [
    {
      "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
      "object": "plan",
      "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
      "name": "Monthly box",
      "description": "A box of our best sellers, every month.",
      "amount": 3000,
      "currency": "USD",
      "interval": "month",
      "interval_count": 1,
      "interval_text": "month",
      "trial_days": 14,
      "intro": {
        "amount": 1500,
        "periods": 2
      },
      "requires_shipping": true,
      "active": true,
      "metadata": {},
      "created_at": "2026-12-01T00:00:00.000Z"
    }
  ]
}
```

| Status | Meaning |
|---|---|
| `200` | The plans. |
| `404` | `not_found`: subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |

### Create a plan or add-on {#createplan}

```http
POST /api/v1/plans
```

A plan: a price every `interval_count` `interval`s (a period is at most a year), with an optional free trial and intro price. Or an add-on (`kind: "addon"`): billed with the plan it is added to, in the same periods. A plan's price and terms never change once created: create another plan and move subscriptions to it with `change`. A repeat with the same `Idempotency-Key` returns the first plan (200).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `kind` | one of `plan`, `addon` | No | `addon`: no interval, trial or intro of its own; it is billed with the plan it is added to. Default `"plan"`. |
| `name` | string (min 1 chars, max 120 chars) | Yes |  |
| `description` | string or null (max 1000 chars) | No |  |
| `amount` | integer (≥ 1, ≤ 99999999) | Yes | Per period (per unit), minor units. |
| `currency` | string | No | ISO 4217. Add-ons must be in their plan's currency. Default `"USD"`. |
| `interval` | one of `day`, `week`, `month`, `year` | No | Required for a plan. |
| `interval_count` | integer (≥ 1, ≤ 365) | No | Intervals per period, up to one year: at most 365 days, 52 weeks, 12 months or 1 year. Default `1`. |
| `trial_days` | integer (≥ 0, ≤ 365) | No | A free trial before the first charge: 0 (none) or at least 7 days, so the customer can be reminded 7 days before it ends. Plans only. Default `0`. |
| `intro` | object or null | No | A lower price for the first periods: `{ "amount": 1500, "periods": 2 }`. Plans only. |
| `requires_shipping` | boolean | No | Each period ships, needs a shipping address and is paid out after carrier-confirmed delivery. On a store that ships physical goods every period ships anyway. Default `false`. |
| `metadata` | object | No | Your own key-value pairs: at most 20 keys of letters, digits, `_`, `.` and `-` (up to 40 characters), each value up to 500 characters. |

```json title="Request"
{
  "name": "Monthly box",
  "description": "A box of our best sellers, every month.",
  "amount": 3000,
  "currency": "USD",
  "interval": "month",
  "trial_days": 14,
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "requires_shipping": true
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `plan`, `addon` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `name` | string | Yes |  |
| `description` | string or null | Yes |  |
| `amount` | integer | Yes | Per period (per unit), minor units. |
| `currency` | string | Yes |  |
| `interval` | one of `day`, `week`, `month`, `year` or null | Yes | Null for an add-on. |
| `interval_count` | integer or null | Yes |  |
| `interval_text` | string or null | Yes | The period in words: `month`, `3 months`. Null for an add-on. |
| `trial_days` | integer | Yes |  |
| `intro` | object or null | Yes | The intro price per period (`amount`) for the first `periods` periods. |
| `requires_shipping` | boolean | Yes |  |
| `active` | boolean | Yes | False once archived. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
  "object": "plan",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "name": "Monthly box",
  "description": "A box of our best sellers, every month.",
  "amount": 3000,
  "currency": "USD",
  "interval": "month",
  "interval_count": 1,
  "interval_text": "month",
  "trial_days": 14,
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "requires_shipping": true,
  "active": true,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z"
}
```

| Status | Meaning |
|---|---|
| `200` | Idempotent replay. |
| `201` | Created. |
| `400` | `invalid_request`: the message names the first invalid field (an intro price must be lower than the plan's price); `invalid_json`: the body is not JSON; `invalid_idempotency_key`: the `Idempotency-Key` is longer than 255 characters or has control characters. |
| `404` | `store_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |

### Retrieve a plan {#getplan}

```http
GET /api/v1/plans/{plan_id}
```

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `plan_id` | path | string (uuid) | Yes | A plan or add-on of your store. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `plan`, `addon` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `name` | string | Yes |  |
| `description` | string or null | Yes |  |
| `amount` | integer | Yes | Per period (per unit), minor units. |
| `currency` | string | Yes |  |
| `interval` | one of `day`, `week`, `month`, `year` or null | Yes | Null for an add-on. |
| `interval_count` | integer or null | Yes |  |
| `interval_text` | string or null | Yes | The period in words: `month`, `3 months`. Null for an add-on. |
| `trial_days` | integer | Yes |  |
| `intro` | object or null | Yes | The intro price per period (`amount`) for the first `periods` periods. |
| `requires_shipping` | boolean | Yes |  |
| `active` | boolean | Yes | False once archived. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
  "object": "plan",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "name": "Monthly box",
  "description": "A box of our best sellers, every month.",
  "amount": 3000,
  "currency": "USD",
  "interval": "month",
  "interval_count": 1,
  "interval_text": "month",
  "trial_days": 14,
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "requires_shipping": true,
  "active": true,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z"
}
```

| Status | Meaning |
|---|---|
| `200` | The plan or add-on. |
| `404` | `plan_not_found`: no such plan in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |

### Update or archive a plan {#updateplan}

```http
PATCH /api/v1/plans/{plan_id}
```

Its name, description or metadata, or archive it with `active: false` (subscriptions already on it go on; it takes no new ones). The price and terms cannot change. Signed like any request, with `PATCH` as the method.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `plan_id` | path | string (uuid) | Yes | A plan or add-on of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | string (min 1 chars, max 120 chars) | No |  |
| `description` | string or null (max 1000 chars) | No |  |
| `active` | boolean | No | `false` archives the plan: it takes no new subscriptions, and those already on it go on. `true` brings it back. |
| `metadata` | object | No | Your own key-value pairs: at most 20 keys of letters, digits, `_`, `.` and `-` (up to 40 characters), each value up to 500 characters. |

```json title="Request"
{
  "active": false
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | one of `plan`, `addon` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `name` | string | Yes |  |
| `description` | string or null | Yes |  |
| `amount` | integer | Yes | Per period (per unit), minor units. |
| `currency` | string | Yes |  |
| `interval` | one of `day`, `week`, `month`, `year` or null | Yes | Null for an add-on. |
| `interval_count` | integer or null | Yes |  |
| `interval_text` | string or null | Yes | The period in words: `month`, `3 months`. Null for an add-on. |
| `trial_days` | integer | Yes |  |
| `intro` | object or null | Yes | The intro price per period (`amount`) for the first `periods` periods. |
| `requires_shipping` | boolean | Yes |  |
| `active` | boolean | Yes | False once archived. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
  "object": "plan",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "name": "Monthly box",
  "description": "A box of our best sellers, every month.",
  "amount": 3000,
  "currency": "USD",
  "interval": "month",
  "interval_count": 1,
  "interval_text": "month",
  "trial_days": 14,
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "requires_shipping": true,
  "active": true,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z"
}
```

| Status | Meaning |
|---|---|
| `200` | The plan. |
| `400` | `invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON. |
| `404` | `plan_not_found`: no such plan in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |

### Create a sign-up link for a plan {#createplanpaymentlink}

```http
POST /api/v1/plans/{plan_id}/payment-link
```

A payment link (https://app.oncharge.io/l/<code>) that signs shoppers up to the plan: they enter their email (and their shipping address if the plan ships), then agree to the recurring terms and enter a card on OnCharge's sign-up page. It is one of your payment links: it appears with them, and you turn it off the same way (`POST /api/v1/payment-links/{link_id}/deactivate`).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `plan_id` | path | string (uuid) | Yes | A plan or add-on of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | string (min 1 chars, max 120 chars) | No | What the link page shows. Default: the plan's name. |

```json title="Request"
{
  "title": "Join the Monthly box"
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `code` | string | Yes |  |
| `url` | string | Yes | The link to share: https://app.oncharge.io/l/<code>. |
| `plan_id` | string (uuid) | Yes |  |

```json title="Response"
{
  "id": "5f0c9d4e-2a1b-4c3d-9e8f-7a6b5c4d3e2f",
  "code": "k7Hq2mNpR4sT",
  "url": "https://app.oncharge.io/l/k7Hq2mNpR4sT",
  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f"
}
```

| Status | Meaning |
|---|---|
| `201` | The link. |
| `400` | `invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON. |
| `404` | `plan_not_found`: no such plan (add-ons have no links); `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `plan_inactive`: the plan is archived. |

### List subscriptions {#listsubscriptions}

```http
GET /api/v1/subscriptions
```

Your store's subscriptions, newest first.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `status` | query | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | No | Only this status. |
| `customer_id` | query | string (uuid) | No | Only this customer's. |
| `limit` | query | integer | No |  |
| `starting_after` | query | string (uuid) | No | The last `id` of the previous page. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `data` | array of object | Yes |  |
| `data[].id` | string (uuid) | Yes |  |
| `data[].object` | `"subscription"` | Yes |  |
| `data[].store_id` | string (uuid) | Yes |  |
| `data[].customer_id` | string (uuid) | Yes |  |
| `data[].customer` | object or null | Yes |  |
| `data[].customer.email` | string or null | No |  |
| `data[].customer.name` | string or null | No |  |
| `data[].status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `data[].status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `data[].plan` | object | Yes |  |
| `data[].plan.id` | string (uuid) | Yes |  |
| `data[].plan.name` | string | No |  |
| `data[].plan.amount` | integer | No |  |
| `data[].plan.currency` | string | No |  |
| `data[].plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `data[].plan.interval_count` | integer or null | No |  |
| `data[].quantity` | integer | Yes |  |
| `data[].addons` | array of object | Yes |  |
| `data[].addons[].plan_id` | string (uuid) | No |  |
| `data[].addons[].name` | string or null | No |  |
| `data[].addons[].amount` | integer or null | No |  |
| `data[].addons[].quantity` | integer | No |  |
| `data[].intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `data[].payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `data[].trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `data[].current_period` | object or null | Yes |  |
| `data[].current_period.index` | integer | No | 0 for the first period. |
| `data[].current_period.start` | string (date-time) or null | No |  |
| `data[].current_period.end` | string (date-time) or null | No |  |
| `data[].current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `data[].next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `data[].credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `data[].pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `data[].pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `data[].pending_change.plan_id` | string (uuid) | No |  |
| `data[].pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `data[].pending_change.quantity` | integer | No |  |
| `data[].pending_change.addons` | array of object | No |  |
| `data[].cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `data[].canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `data[].ended_at` | string (date-time) or null | Yes |  |
| `data[].cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `data[].pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `data[].pause.at_period_end` | boolean | No |  |
| `data[].pause.paused_at` | string (date-time) or null | No |  |
| `data[].pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `data[].pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `data[].shipping` | object or null | Yes |  |
| `data[].shipping.name` | string or null | No |  |
| `data[].shipping.address` | object | No |  |
| `data[].source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `data[].payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `data[].sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `data[].metadata` | object | Yes |  |
| `data[].created_at` | string (date-time) | Yes |  |
| `has_more` | boolean | Yes | More follow: pass the last `id` as `starting_after`. |

```json title="Response"
{
  "data": [
    {
      "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
      "object": "subscription",
      "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
      "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
      "customer": {
        "email": "ada@example.com",
        "name": "Ada Lovelace"
      },
      "plan": {
        "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
        "name": "Monthly box",
        "amount": 3000,
        "currency": "USD",
        "interval": "month",
        "interval_count": 1
      },
      "quantity": 1,
      "addons": [],
      "intro": {
        "amount": 1500,
        "periods": 2
      },
      "credit_balance": 0,
      "pending_change": null,
      "cancel_at_period_end": false,
      "canceled_at": null,
      "ended_at": null,
      "cancel_reason": null,
      "pause": null,
      "shipping": {
        "name": "Ada Lovelace",
        "address": {
          "line1": "1 Main St",
          "line2": null,
          "city": "Austin",
          "state": "TX",
          "postal_code": "78701",
          "country": "US"
        }
      },
      "payment_link_id": null,
      "metadata": {},
      "created_at": "2026-12-01T00:00:00.000Z",
      "status": "active",
      "status_text": "Active",
      "payment_method": {
        "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
        "object": "payment_method",
        "type": "card",
        "brand": "Visa",
        "last4": "4242",
        "exp_month": 12,
        "exp_year": 2029,
        "funding": "credit",
        "country": "US",
        "wallet": null,
        "is_default": true,
        "status": "active",
        "expired": false,
        "saved_via": "save_card_page",
        "created_at": "2026-12-01T00:00:00.000Z",
        "last_used_at": "2026-12-15T00:00:00.000Z",
        "updated_by_card_network_at": null,
        "removed_at": null
      },
      "trial_end": "2026-12-15T00:00:00.000Z",
      "current_period": {
        "index": 0,
        "start": "2026-12-15T00:00:00.000Z",
        "end": "2027-01-15T00:00:00.000Z",
        "amount": 1500
      },
      "next_billing_at": "2027-01-15T00:00:00.000Z",
      "source": "api",
      "sign_up_expires_at": null
    }
  ],
  "has_more": true
}
```

| Status | Meaning |
|---|---|
| `200` | A page of subscriptions. |
| `404` | `not_found`: subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |

### Start a subscription for a customer {#createsubscription}

```http
POST /api/v1/subscriptions
```

For an existing customer of your store. It starts as `incomplete`: OnCharge emails the customer a link to its sign-up page, where they read the terms, agree to the recurring charges and choose one of their saved cards or add one. It starts when they agree (the trial starts, or the first period is charged). The link is never returned to you, and it works for 7 days; after that the subscription is `incomplete_expired`. A repeat with the same `Idempotency-Key` returns the first subscription (200).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `customer_id` | string (uuid) | Yes | An existing customer of your store. They need an email address: OnCharge emails them the link to confirm. |
| `plan_id` | string (uuid) | Yes | An active plan of your store. |
| `quantity` | integer (≥ 1, ≤ 1000) | No | Default `1`. |
| `addons` | array of object (≤ 20 items) | No | Each add-on listed once. |
| `addons[].plan_id` | string (uuid) | Yes | An add-on of your store (`kind: "addon"`), in the plan's currency. |
| `addons[].quantity` | integer (≥ 1, ≤ 1000) | No | Default `1`. |
| `shipping` | object | No | Required when the subscription ships. |
| `shipping.name` | string (min 1 chars, max 200 chars) | Yes |  |
| `shipping.line1` | string (min 1 chars, max 300 chars) | Yes |  |
| `shipping.line2` | string or null (max 300 chars) | No |  |
| `shipping.city` | string (min 1 chars, max 120 chars) | Yes |  |
| `shipping.state` | string or null (max 120 chars) | No |  |
| `shipping.postal_code` | string (min 1 chars, max 20 chars) | Yes |  |
| `shipping.country` | string | Yes | Two-letter code (`US`). |
| `metadata` | object | No | Your own key-value pairs: at most 20 keys of letters, digits, `_`, `.` and `-` (up to 40 characters), each value up to 500 characters. |

```json title="Request"
{
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
  "quantity": 1,
  "addons": [
    {
      "plan_id": "d2e3f4a5-b6c7-4d8e-9f0a-1b2c3d4e5f6a",
      "quantity": 1
    }
  ],
  "shipping": {
    "name": "Ada Lovelace",
    "line1": "1 Main St",
    "city": "Austin",
    "state": "TX",
    "postal_code": "78701",
    "country": "US"
  }
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 1500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null
}
```

| Status | Meaning |
|---|---|
| `200` | Idempotent replay. |
| `201` | Created, waiting for the customer (`incomplete`). |
| `400` | `invalid_request`: the message names the first invalid field (also an add-on listed twice, or in another currency); `invalid_json`: the body is not JSON; `invalid_idempotency_key`: the `Idempotency-Key` is longer than 255 characters or has control characters. |
| `404` | `customer_not_found`, `plan_not_found` or `addon_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `customer_email_required`: the customer has no email address; `plan_inactive`: the plan (or an add-on) is archived; `store_inactive`: the store is not taking payments; `subscriptions_unavailable`: the store has no card payments set up for saved cards; `idempotency_conflict`: the `Idempotency-Key` was used for another customer or plan. |
| `422` | `shipping_address_required`: the subscription ships each period: send `shipping`. |

### Create a hosted sign-up page {#createsubscriptioncheckout}

```http
POST /api/v1/subscriptions/checkout
```

A sign-up page on OnCharge for one customer: the answer is the subscription (`incomplete`) with its `url`. Send the customer there; they read the terms, agree to the recurring charges and enter a card, and the subscription starts (the trial starts, or the first period is charged). The page works for 24 hours and never offers the customer's saved cards. A repeat with the same `Idempotency-Key` returns the first subscription and its page (200).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | No | A unique key (up to 255 characters is safe) that makes retries of this request safe. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `plan_id` | string (uuid) | Yes | An active plan of your store. |
| `quantity` | integer (≥ 1, ≤ 1000) | No | Default `1`. |
| `addons` | array of object (≤ 20 items) | No | Each add-on listed once. |
| `addons[].plan_id` | string (uuid) | Yes | An add-on of your store (`kind: "addon"`), in the plan's currency. |
| `addons[].quantity` | integer (≥ 1, ≤ 1000) | No | Default `1`. |
| `customer_id` | string (uuid) | No | An existing customer of your store. |
| `customer_email` | string (email) (max 254 chars) | No | The customer is found by email, or added to your store. |
| `customer_name` | string (min 1 chars, max 200 chars) | No | Saved on the customer if they have no name yet. |
| `shipping` | object | No | Required when the subscription ships. |
| `shipping.name` | string (min 1 chars, max 200 chars) | Yes |  |
| `shipping.line1` | string (min 1 chars, max 300 chars) | Yes |  |
| `shipping.line2` | string or null (max 300 chars) | No |  |
| `shipping.city` | string (min 1 chars, max 120 chars) | Yes |  |
| `shipping.state` | string or null (max 120 chars) | No |  |
| `shipping.postal_code` | string (min 1 chars, max 20 chars) | Yes |  |
| `shipping.country` | string | Yes | Two-letter code (`US`). |
| `success_url` | string (uri) (max 2048 chars) | No | An `https` page the customer goes to after signing up. Kept in the subscription's `metadata` as `success_url`. |
| `metadata` | object | No | Your own key-value pairs: at most 20 keys of letters, digits, `_`, `.` and `-` (up to 40 characters), each value up to 500 characters. |

```json title="Request"
{
  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
  "customer_email": "ada@example.com",
  "customer_name": "Ada Lovelace",
  "shipping": {
    "name": "Ada Lovelace",
    "line1": "1 Main St",
    "city": "Austin",
    "state": "TX",
    "postal_code": "78701",
    "country": "US"
  },
  "success_url": "https://shop.example.com/welcome"
}
```

**Response** `201`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |
| `url` | string | Yes | The customer's sign-up page on OnCharge. It works until `sign_up_expires_at` (24 hours). It never offers the customer's saved cards. |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "incomplete",
  "status_text": "Waiting for customer",
  "payment_method": null,
  "trial_end": null,
  "current_period": null,
  "next_billing_at": null,
  "source": "checkout",
  "sign_up_expires_at": "2026-12-02T00:00:00.000Z",
  "url": "https://app.oncharge.io/s/subscribe/7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b?token=ocs_…"
}
```

| Status | Meaning |
|---|---|
| `200` | Idempotent replay. |
| `201` | Created: send the customer to `url`. |
| `400` | `invalid_request`: the message names the first invalid field (also neither `customer_id` nor `customer_email`, or an add-on listed twice or in another currency); `invalid_json`: the body is not JSON; `invalid_idempotency_key`: the `Idempotency-Key` is longer than 255 characters or has control characters. |
| `404` | `customer_not_found`, `plan_not_found` or `addon_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `plan_inactive`: the plan (or an add-on) is archived; `store_inactive`: the store is not taking payments; `subscriptions_unavailable`: the store has no card payments set up for saved cards; `idempotency_conflict`: the `Idempotency-Key` was used for another customer or plan. |
| `422` | `shipping_address_required`: the subscription ships each period: send `shipping`. |

### Retrieve a subscription {#getsubscription}

```http
GET /api/v1/subscriptions/{subscription_id}
```

The subscription with every bill (each period and prorated plan change, its invoice, attempts, failure and payment reference) and its history.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `subscription_id` | path | string (uuid) | Yes | A subscription of your store. |

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |
| `billings` | array of object | Yes | Every bill, newest first. |
| `billings[].id` | string (uuid) | Yes |  |
| `billings[].object` | `"subscription_billing"` | Yes |  |
| `billings[].subscription_id` | string (uuid) | Yes |  |
| `billings[].reason` | one of `period`, `proration` | Yes | `proration`: the prorated charge of a plan change applied now. |
| `billings[].period_index` | integer | Yes | 0 for the first period. |
| `billings[].period_start` | string (date-time) | Yes |  |
| `billings[].period_end` | string (date-time) | Yes |  |
| `billings[].lines` | array of object | Yes |  |
| `billings[].lines[].description` | string | No |  |
| `billings[].lines[].quantity` | integer | No |  |
| `billings[].lines[].unit_amount` | integer | No |  |
| `billings[].lines[].requires_shipping` | boolean | No |  |
| `billings[].subtotal` | integer | Yes |  |
| `billings[].credit_applied` | integer | Yes | Credit from earlier downgrades taken off this bill. |
| `billings[].amount_due` | integer | Yes |  |
| `billings[].ships` | boolean | Yes | This period's order ships: it is paid out after carrier-confirmed delivery. |
| `billings[].status` | one of `open`, `paid`, `uncollectible`, `void` | Yes |  |
| `billings[].invoice` | object or null | Yes |  |
| `billings[].invoice.id` | string (uuid) | No |  |
| `billings[].invoice.number` | string or null | No | `INV-0042`. |
| `billings[].attempts` | integer | Yes | Charge attempts so far. |
| `billings[].next_attempt_at` | string (date-time) or null | Yes | While open: when it is charged again; null when it waits for the customer. |
| `billings[].failure` | object or null | Yes | Why the last charge failed, while unpaid. |
| `billings[].failure.reason` | one of `declined`, `authentication_required`, `unusable_card`, `error`, `store_unavailable`, `store_limit` | No |  |
| `billings[].failure.message` | string | No | What happened and what OnCharge does next, in plain words. |
| `billings[].failure.waits_for_customer` | boolean | No | No automatic retry: the customer has to confirm the payment with their bank or add another card. |
| `billings[].paid_at` | string (date-time) or null | Yes |  |
| `billings[].payment_reference` | string or null | Yes | OnCharge's reference for the payment that paid it (`ocpay_…`). |
| `billings[].created_at` | string (date-time) | Yes |  |
| `history` | array of object | Yes | What happened, newest first (at most 100). |
| `history[].kind` | string | No |  |
| `history[].actor` | one of `merchant`, `api`, `customer`, `system` | No |  |
| `history[].data` | object | No |  |
| `history[].created_at` | string (date-time) | No |  |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 1500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null,
  "billings": [
    {
      "id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
      "object": "subscription_billing",
      "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
      "reason": "period",
      "period_index": 0,
      "period_start": "2026-12-15T00:00:00.000Z",
      "period_end": "2027-01-15T00:00:00.000Z",
      "lines": [
        {
          "description": "Monthly box (introductory price)",
          "quantity": 1,
          "unit_amount": 1500,
          "requires_shipping": true
        }
      ],
      "subtotal": 1500,
      "credit_applied": 0,
      "amount_due": 1500,
      "ships": true,
      "status": "paid",
      "invoice": {
        "id": "4d5e6f7a-8b9c-4d0e-8f1a-2b3c4d5e6f7a",
        "number": "INV-0042"
      },
      "attempts": 1,
      "next_attempt_at": null,
      "failure": null,
      "paid_at": "2026-12-15T00:05:00.000Z",
      "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d",
      "created_at": "2026-12-15T00:00:00.000Z"
    }
  ],
  "history": [
    {
      "kind": "billing_paid",
      "actor": "system",
      "data": {
        "amount": 1500,
        "period_index": 0,
        "reason": "period"
      },
      "created_at": "2026-12-15T00:05:00.000Z"
    },
    {
      "kind": "consent_granted",
      "actor": "customer",
      "data": {
        "version": "2026-12-01-draft"
      },
      "created_at": "2026-12-01T00:10:00.000Z"
    },
    {
      "kind": "created",
      "actor": "system",
      "data": {
        "source": "api",
        "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
        "quantity": 1
      },
      "created_at": "2026-12-01T00:00:00.000Z"
    }
  ]
}
```

| Status | Meaning |
|---|---|
| `200` | The subscription. |
| `404` | `not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |

### Update a subscription {#updatesubscription}

```http
PATCH /api/v1/subscriptions/{subscription_id}
```

Change where it ships, replace its metadata, or ask the customer to switch to another of their saved cards at your store. Only the customer changes the card: with `payment_method_id` they are emailed a link to switch to that card on their subscription page (once an hour at most), and the answer is `202` with `card_change`. If that email cannot be sent, nothing in the request is saved. Nothing changes, and nothing is charged to that card, until the customer switches and agrees to the charges on it. Signed like any request, with `PATCH` as the method.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `subscription_id` | path | string (uuid) | Yes | A subscription of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `payment_method_id` | string (uuid) | No | Another active saved card of the same customer at your store. The customer is emailed a link to switch to it themselves (`202`); the subscription keeps its card, and nothing is charged to this one, until they do. Not on an `incomplete` subscription: the customer chooses the card when they sign up. |
| `shipping` | object | No | Where the next periods ship. |
| `shipping.name` | string (min 1 chars, max 200 chars) | Yes |  |
| `shipping.line1` | string (min 1 chars, max 300 chars) | Yes |  |
| `shipping.line2` | string or null (max 300 chars) | No |  |
| `shipping.city` | string (min 1 chars, max 120 chars) | Yes |  |
| `shipping.state` | string or null (max 120 chars) | No |  |
| `shipping.postal_code` | string (min 1 chars, max 20 chars) | Yes |  |
| `shipping.country` | string | Yes | Two-letter code (`US`). |
| `metadata` | object | No | Replaces the metadata. |

```json title="Request"
{
  "payment_method_id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 1500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null
}
```

| Status | Meaning |
|---|---|
| `200` | The subscription. |
| `202` | With `payment_method_id`: the customer was emailed a link to switch to that card (`card_change.status: "customer_asked"`, with the card's brand and last four digits). The subscription keeps its card until they do; any shipping or metadata change in the same request is saved. |
| `400` | `invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON. |
| `404` | `not_found`: no such subscription; `payment_method_not_found`: not an active saved card of this customer; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `subscription_ended`: it has ended; `not_started`: the customer chooses the card when they sign up; `customer_email_required`: the customer has no email address to ask them to switch cards; `conflict`: the subscription changed meanwhile (try again). A `429 too_many_requests` means you asked this customer to switch cards less than an hour ago; a `502 customer_not_emailed` means the email could not be sent and nothing in the request was saved: try again. |

### Cancel a subscription {#cancelsubscription}

```http
POST /api/v1/subscriptions/{subscription_id}/cancel
```

By default an active or trialing subscription ends when its current period (or trial) ends: nothing more is charged, and `subscription.canceled` follows then. With `at_period_end: false`, or for any other status, it ends now: anything unpaid is voided. The customer is emailed. To keep a subscription whose cancellation is waiting, `resume` it (not when the customer cancelled it).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `subscription_id` | path | string (uuid) | Yes | A subscription of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `at_period_end` | boolean | No | `true`: an active or trialing subscription ends when its current period (or trial) ends; any other status ends now. `false`: it ends now and anything unpaid is voided. Default `true`. |

```json title="Request"
{
  "at_period_end": true
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 1500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null
}
```

| Status | Meaning |
|---|---|
| `200` | The subscription: `cancel_at_period_end: true`, or `canceled`. |
| `400` | `invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON. |
| `404` | `not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `subscription_ended`: it has already ended; `payment_in_progress`: a payment for it is being collected (try again in a minute); `conflict`: the subscription changed meanwhile (try again). |

### Pause a subscription {#pausesubscription}

```http
POST /api/v1/subscriptions/{subscription_id}/pause
```

From the end of the current period (nothing already paid is lost), for `periods` periods, until `resume_at`, or until resumed. While paused nothing is charged or shipped. Only an active or trialing subscription can be paused; a past-due one must be paid first.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `subscription_id` | path | string (uuid) | Yes | A subscription of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `periods` | integer (≥ 1, ≤ 12) | No | Pause for this many periods. |
| `resume_at` | string (date-time) | No | Resume then: after the end of the current period. |

```json title="Request"
{
  "periods": 2
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 1500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null
}
```

| Status | Meaning |
|---|---|
| `200` | The subscription, with `pause.at_period_end: true`. |
| `400` | `invalid_request`: the message names the first invalid field (also both `periods` and `resume_at`, or a `resume_at` not after the end of the current period); `invalid_json`: the body is not JSON. |
| `404` | `not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `payment_required`: it is past due; `not_pausable`: it is not active or trialing; `cancel_scheduled`: it ends at the period's end; `conflict`: the subscription changed meanwhile (try again). |

### Resume a subscription {#resumesubscription}

```http
POST /api/v1/subscriptions/{subscription_id}/resume
```

A paused subscription starts again now: a new period begins and is charged at once. On a subscription with a pause or cancellation waiting for the period's end, the pause or cancellation is called off. A cancellation the customer asked for is theirs to undo, by subscribing again.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `subscription_id` | path | string (uuid) | Yes | A subscription of your store. |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 1500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null
}
```

| Status | Meaning |
|---|---|
| `200` | The subscription. |
| `404` | `not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `not_paused`: nothing to resume; `canceled_by_customer`: the customer cancelled it; `conflict`: the subscription changed meanwhile (try again). |

### Change the plan, quantity or add-ons {#changesubscription}

```http
POST /api/v1/subscriptions/{subscription_id}/change
```

A change that **raises the price** the customer pays is never applied at once: it waits in `pending_change` (with `increase`) for the first period that starts at least 7 days after the customer is emailed a notice, which goes 7 to 30 days before the new price is first charged. Asking for `proration: "now"` on an increase is refused (`409 price_increase_needs_notice`); leave `proration` out (or send `"next_period"`) to schedule it. Any other change applies at once by default: the rest of the current period is prorated and the difference for the time left (to the second, rounded half up) is credited to the next bills. With `"next_period"` it applies at the renewal (`pending_change`). A shipped subscription (each period is one order) and a plan with another interval change at the next period only; a paused subscription always does. The customer is emailed the new price.

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `subscription_id` | path | string (uuid) | Yes | A subscription of your store. |

**Request body** (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `plan_id` | string (uuid) | No | Another plan of your store, in the same currency. A new plan drops any intro price left. |
| `quantity` | integer (≥ 1, ≤ 1000) | No |  |
| `addons` | array of object (≤ 20 items) | No | Replaces every add-on (`[]` removes them). |
| `addons[].plan_id` | string (uuid) | Yes | An add-on of your store (`kind: "addon"`), in the plan's currency. |
| `addons[].quantity` | integer (≥ 1, ≤ 1000) | No | Default `1`. |
| `proration` | one of `now`, `next_period` | No | `now`: applied at once; the rest of the period is prorated (a lower price is a credit on the next bills). A change that raises the price is never applied now (`409 price_increase_needs_notice`). `next_period`: applied at the renewal, or for a price increase from the first period at least 7 days after the customer's emailed notice. Left out: `now`, unless the change raises the price (then scheduled with the notice). A shipped subscription, or a plan with another interval, changes at the next period only (`409 change_at_next_period` otherwise); a paused one always does. |

```json title="Request"
{
  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
  "quantity": 2,
  "proration": "next_period"
}
```

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |
| `proration` | object | No | Only for a change applied now. |
| `proration.charge` | integer | No | Charged now for the rest of the period, minor units. Always 0 since a price increase never applies at once (kept for compatibility). |
| `proration.credit` | integer | No | Credited to the next bills (a downgrade), minor units. |
| `proration.outcome` | one of `paid`, `processing`, `failed`, `resume_later`, `not_charged`, or `null` | No | How the charge went; null when nothing was charged. |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 2,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 4500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null,
  "proration": {
    "charge": 1452,
    "credit": 0,
    "outcome": "paid"
  }
}
```

| Status | Meaning |
|---|---|
| `200` | The subscription; for a change applied now, with `proration`. |
| `400` | `invalid_request`: the message names the first invalid field (also nothing to change, or an add-on listed twice or in another currency); `currency_mismatch`: the new plan is in another currency; `invalid_json`: the body is not JSON. |
| `404` | `not_found`, `plan_not_found` or `addon_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `not_changeable`: it is not active, trialing or paused (a past-due subscription must be paid first); `price_increase_needs_notice`: the change raises the price, so it cannot apply now: leave `proration` out or use `"next_period"`; `change_at_next_period`: it ships, or the new plan has another interval: use `proration: "next_period"`; `plan_inactive`: the new plan or an add-on is archived; `store_inactive`; `conflict`: the subscription changed meanwhile (try again). |
| `422` | `shipping_address_required`: the new plan ships and the subscription has no shipping address: set one with PATCH first. |

### Retry a past-due payment now {#retrysubscription}

```http
POST /api/v1/subscriptions/{subscription_id}/retry
```

Charges a past-due subscription's unpaid bills to its card now, instead of waiting for the next scheduled retry (for example after the customer told you they fixed their card).

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `subscription_id` | path | string (uuid) | Yes | A subscription of your store. |

No request body. Sign it as an empty body.

**Response** `200`

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string (uuid) | Yes |  |
| `object` | `"subscription"` | Yes |  |
| `store_id` | string (uuid) | Yes |  |
| `customer_id` | string (uuid) | Yes |  |
| `customer` | object or null | Yes |  |
| `customer.email` | string or null | No |  |
| `customer.name` | string or null | No |  |
| `status` | one of `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `paused`, `canceled` | Yes | `incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended. |
| `status_text` | string | Yes | The status in plain words (`Waiting for customer`, `Past due`, …). |
| `plan` | object | Yes |  |
| `plan.id` | string (uuid) | Yes |  |
| `plan.name` | string | No |  |
| `plan.amount` | integer | No |  |
| `plan.currency` | string | No |  |
| `plan.interval` | one of `day`, `week`, `month`, `year` or null | No |  |
| `plan.interval_count` | integer or null | No |  |
| `quantity` | integer | Yes |  |
| `addons` | array of object | Yes |  |
| `addons[].plan_id` | string (uuid) | No |  |
| `addons[].name` | string or null | No |  |
| `addons[].amount` | integer or null | No |  |
| `addons[].quantity` | integer | No |  |
| `intro` | object or null | Yes | The intro price this subscription has, taken from its plan when it was created. |
| `payment_method` | object or null | Yes | The saved card it is charged to. Null until the customer signs up. |
| `trial_end` | string (date-time) or null | Yes | When the free trial ends (the first charge). |
| `current_period` | object or null | Yes |  |
| `current_period.index` | integer | No | 0 for the first period. |
| `current_period.start` | string (date-time) or null | No |  |
| `current_period.end` | string (date-time) or null | No |  |
| `current_period.amount` | integer or null | No | What this period was billed, minor units. |
| `next_billing_at` | string (date-time) or null | Yes | When it is charged next, or resumes; null once ended. |
| `credit_balance` | integer | Yes | Credit from downgrades, taken off the next bills (minor units). |
| `pending_change` | object or null | Yes | A change that applies at the next period (a price increase: from `increase.effective_at`). |
| `pending_change.change_id` | string (uuid) | No | This change: its notice is for it alone; a newer change is always told again. |
| `pending_change.plan_id` | string (uuid) | No |  |
| `pending_change.increase` | object or null | No | Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again. |
| `pending_change.increase.from` | integer | No | The price per period before, minor units (per `from_every`). |
| `pending_change.increase.to` | integer | No | The price per period after, minor units (per `to_every`). |
| `pending_change.increase.from_every` | string | No | The period before, in words: `every month`. |
| `pending_change.increase.to_every` | string | No | The period after, in words: `every week`. |
| `pending_change.increase.currency` | string | No |  |
| `pending_change.increase.effective_index` | integer or null | No | The period it applies from (0 is the first); null while unknown (paused with no end date). |
| `pending_change.increase.effective_at` | string (date-time) or null | No | When that period starts: the first charge at the new price; null while unknown. |
| `pending_change.increase.notice_sent_at` | string (date-time) or null | No | When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go). |
| `pending_change.increase.version` | integer | No | Which notice: goes up each time the date moves, so a notice for an earlier date never counts again. |
| `pending_change.quantity` | integer | No |  |
| `pending_change.addons` | array of object | No |  |
| `pending_change.addons[].plan_id` | string (uuid) | No |  |
| `pending_change.addons[].quantity` | integer | No |  |
| `cancel_at_period_end` | boolean | Yes | It ends when the current period ends. |
| `canceled_at` | string (date-time) or null | Yes | When it was cancelled (for a cancellation at the period's end, when it was asked for). |
| `ended_at` | string (date-time) or null | Yes |  |
| `cancel_reason` | one of `merchant`, `customer`, `api`, `dunning`, `store_closed`, `reminder_undeliverable`, or `null` | Yes | `dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged. |
| `pause` | object or null | Yes | A pause waiting for the period's end (`at_period_end: true`), or under way. |
| `pause.at_period_end` | boolean | No |  |
| `pause.paused_at` | string (date-time) or null | No |  |
| `pause.resume_at` | string (date-time) or null | No | When it starts again by itself; null: when you (or the customer) resume it. |
| `pause.reason` | one of `merchant`, `customer`, `api`, `dunning`, or `null` | No |  |
| `shipping` | object or null | Yes |  |
| `shipping.name` | string or null | No |  |
| `shipping.address` | object | No |  |
| `shipping.address.line1` | string | No |  |
| `shipping.address.line2` | string or null | No |  |
| `shipping.address.city` | string | No |  |
| `shipping.address.state` | string or null | No |  |
| `shipping.address.postal_code` | string | No |  |
| `shipping.address.country` | string | No |  |
| `source` | one of `dashboard`, `api`, `payment_link`, `checkout` | Yes | How it was started. |
| `payment_link_id` | string (uuid) or null | Yes | The plan payment link the customer signed up through. |
| `sign_up_expires_at` | string (date-time) or null | Yes | While `incomplete`: when the sign-up link stops working. |
| `metadata` | object | Yes |  |
| `created_at` | string (date-time) | Yes |  |
| `retry` | array of one of `paid`, `processing`, `failed`, `resume_later`, `not_charged` | Yes | How each unpaid bill's charge went, oldest first. |

```json title="Response"
{
  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
  "object": "subscription",
  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "customer": {
    "email": "ada@example.com",
    "name": "Ada Lovelace"
  },
  "plan": {
    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "name": "Monthly box",
    "amount": 3000,
    "currency": "USD",
    "interval": "month",
    "interval_count": 1
  },
  "quantity": 1,
  "addons": [],
  "intro": {
    "amount": 1500,
    "periods": 2
  },
  "credit_balance": 0,
  "pending_change": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "ended_at": null,
  "cancel_reason": null,
  "pause": null,
  "shipping": {
    "name": "Ada Lovelace",
    "address": {
      "line1": "1 Main St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postal_code": "78701",
      "country": "US"
    }
  },
  "payment_link_id": null,
  "metadata": {},
  "created_at": "2026-12-01T00:00:00.000Z",
  "status": "active",
  "status_text": "Active",
  "payment_method": {
    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
    "object": "payment_method",
    "type": "card",
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2029,
    "funding": "credit",
    "country": "US",
    "wallet": null,
    "is_default": true,
    "status": "active",
    "expired": false,
    "saved_via": "save_card_page",
    "created_at": "2026-12-01T00:00:00.000Z",
    "last_used_at": "2026-12-15T00:00:00.000Z",
    "updated_by_card_network_at": null,
    "removed_at": null
  },
  "trial_end": "2026-12-15T00:00:00.000Z",
  "current_period": {
    "index": 0,
    "start": "2026-12-15T00:00:00.000Z",
    "end": "2027-01-15T00:00:00.000Z",
    "amount": 1500
  },
  "next_billing_at": "2027-01-15T00:00:00.000Z",
  "source": "api",
  "sign_up_expires_at": null,
  "retry": [
    "paid"
  ]
}
```

| Status | Meaning |
|---|---|
| `200` | The subscription, with how each charge went. |
| `404` | `not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on). |
| `409` | `not_past_due`: only a past-due subscription is retried. |

## Webhooks {#webhooks}

OnCharge sends these events to your webhook endpoint. Verification and handling: [Webhooks](https://oncharge.io/docs/webhooks).

| Event | When |
|---|---|
| `payment.pending` | The shopper started paying but the money has not arrived yet. Do not ship yet. On a gateway wallet, a payment seen on the chain and not confirmed yet. |
| `payment.authorized` | The card was approved and the money is held for you. It is collected next. |
| `payment.captured` | The shopper paid. Mark the order as paid and ship it. For crypto and Card to Crypto paid to your own wallet, the payout is already on its way to it. |
| `payment.under_review` | A payment to your wallet arrived but does not match the order (for example a different amount), so check it before you ship. |
| `payment.refused` | The payment was declined. The order is not paid; the shopper can try again. When OnCharge refused it because the store reached a limit set on its account, `data.reason` is `limit_exceeded` and nothing was sent to the bank. |
| `payment.cancelled` | The payment was cancelled before it was collected. Nothing was charged. |
| `payment.expired` | The shopper did not finish paying in time. Nothing was charged. |
| `payment.capture_failed` | An approved payment could not be collected. The order is not paid. |
| `refund.succeeded` | A refund went through. The amount is the total refunded on this order so far. |
| `refund.failed` | A refund could not be sent. Nothing was taken from your balance. |
| `chargeback.opened` | The shopper asked their bank to reverse this payment. OnCharge helps you answer it. |
| `dispute.evidence_due` | A dispute needs its evidence by the date given. OnCharge answers for you where it can; the dispute page says what is still missing. Sent once per dispute and deadline. |
| `chargeback.won` | The bank decided in your favour. You keep the money. |
| `chargeback.lost` | The bank decided for the shopper. The payment is reversed. |
| `fraud_warning.received` | The cardholder's bank reported this payment as fraud. Do not ship it yet: the payout is on hold, and OnCharge may refund it to stop a dispute. |
| `delivery.confirmed` | Every package of the order was confirmed delivered by the carrier. Sent once per order. |
| `payout.paid` | A payout reached your bank, or (a debit card payout, `method` "instant") your debit card, with `fee` taken out. Payouts pay orders whose delivery was confirmed. |
| `payout.failed` | A payout could not be delivered to your bank. The money is safe and is sent again; the problem says whether your bank details need fixing. A debit card payout that fails goes to your bank instead, its fee refunded. |
| `payout.returned` | Your bank sent a payout back after it arrived. The money is sent again once working bank details are on file. |
| `account.updated` | What your account can do changed: taking payments, receiving payouts, or what it needs from you. |
| `account.requirements_due` | Your account needs more information by the deadline, or it stops taking payments. Provide it under Settings. Sent once per change. |
| `account.restricted` | Your account stopped taking payments or receiving payouts. The reason says what to do. |
| `swap.created` | A conversion was created and waits for the coins to arrive. |
| `swap.completed` | A crypto payment was converted to the coin you are paid in and sent to your wallet. |
| `swap.failed` | A crypto payment could not be converted. The coins go back to the sender, or OnCharge contacts you. |
| `swap.refunded` | A conversion could not finish, and the coins were sent back to the sender. |
| `swap.expired` | No coins arrived before the conversion's quote ran out. Nothing was converted. |
| `support.conversation.created` | A customer started a conversation by email, chat or phone. Not sent yet: the sample shows what will arrive. |
| `support.message.received` | A customer wrote in an open conversation. Not sent yet: the sample shows what will arrive. |
| `support.conversation.closed` | A conversation was marked as done by your team, an OnCharge rep or the AI assistant. Not sent yet: the sample shows what will arrive. |
| `subscription.created` | A customer agreed to a subscription and it started: its trial began, or its first period was paid. |
| `subscription.updated` | The plan, quantity, card, or a waiting cancellation or pause changed. `data.change` says what: `plan_changed` (with `prorated_charge` and `prorated_credit`), `change_scheduled` (with `pending_change`), `price_increase_notice` (the customer was emailed the notice of a price increase, with `price_increase`), `change_applied`, `payment_method`, `cancel_scheduled`, `pause_scheduled`, `kept` (a waiting cancellation or pause was called off), `trial_ended` or `payment_recovered`. |
| `subscription.trial_will_end` | A trial ends soon and the customer was reminded: 7 days ahead for a trial of 14 days or more, 3 days for 7 to 13 days, 1 day for 3 to 6 days. Sent once per trial. |
| `subscription.past_due` | A period's payment failed. OnCharge retries it 1, 3, 7 and 14 days after the first failure (unless it waits for the customer) and asked the customer to check their card. |
| `subscription.paused` | The subscription paused: nothing is charged or shipped until it resumes (`data.resume_at`, or when you resume it). |
| `subscription.resumed` | A paused subscription started again; a new period began and was charged. |
| `subscription.canceled` | The subscription ended: cancelled by you or the customer, or after its payment failed on every retry (`data.cancel_reason`). |
| `subscription.period.paid` | A period (or a plan change) was paid. If it ships, ship it and report its tracking number with `data.session_id`: its payout is released on carrier-confirmed delivery, like any order. |
| `subscription.period.payment_failed` | A charge for a period failed. `data.failure` says why and `data.next_attempt_at` when it is tried again (null: it waits for the customer). |

**Headers**

| Header | Description |
|---|---|
| `OnCharge-Event-Id` | Unique event ID (`evt_…`). Deduplicate on it; the same event may be delivered more than once. |
| `OnCharge-Signature` | `t=<unix seconds>,v1=<hex>` where `v1` = lower-case hex HMAC-SHA256(webhook signing secret, `"<t>.<raw body>"`). The key is your webhook signing secret (`oc_cbsec_…`) as given. Compare in constant time and reject events where `\|now - t\| > 300`. |
| `X-Oncharge-Signature` | **Deprecated.** Legacy body-only signature kept for older plugins. Verify `OnCharge-Signature` instead. |

**Event body**

| Field | Type | Always present | Description |
|---|---|---|---|
| `id` | string | Yes | Event ID (`evt_…`), the same as the `OnCharge-Event-Id` header. |
| `type` | one of `payment.pending`, `payment.authorized`, `payment.captured`, `payment.under_review`, `payment.refused`, `payment.cancelled`, `payment.expired`, `payment.capture_failed`, `refund.succeeded`, `refund.failed`, `chargeback.opened`, `dispute.evidence_due`, `chargeback.won`, `chargeback.lost`, `fraud_warning.received`, `delivery.confirmed`, `payout.paid`, `payout.failed`, `payout.returned`, `account.updated`, `account.requirements_due`, `account.restricted`, `swap.created`, `swap.completed`, `swap.failed`, `swap.refunded`, `swap.expired`, `subscription.created`, `subscription.updated`, `subscription.trial_will_end`, `subscription.past_due`, `subscription.paused`, `subscription.resumed`, `subscription.canceled`, `subscription.period.paid`, `subscription.period.payment_failed`, `support.conversation.created`, `support.message.received`, `support.conversation.closed` | Yes | Every event type. Payments on every rail use the same payment.* types (data.rail says which). Handle the types you need and acknowledge (2xx) any others; new types may be added. |
| `created` | integer | Yes | Unix time (seconds) the event was created. |
| `livemode` | boolean | Yes | false for events from test payments. |
| `data` | object | Yes | For payment events from a checkout, the fields below. Crypto and Card to Crypto paid to your wallet carry `session_id: null` with `payment_id`, `source`, `method`, `coin`, `coin_amount`, `wallet` and transaction hashes; every other event its own fields. All of them carry `rail`. |
| `data.session_id` | string or null | No | The checkout session; null for a payment paid straight to your wallet. |
| `data.order_id` | string or null | No | Your order ID, if known. |
| `data.reference` | string or null | No | The `reference` you sent when creating the session. |
| `data.amount` | integer or null | No | Minor units. For `refund.succeeded`, the total refunded so far. |
| `data.currency` | string or null | No | ISO 4217 code. |
| `data.status` | string or null | No | The order's payment status after the event (for example `captured`, `refunded`). |
| `data.rail` | one of `card`, `crypto`, `card_to_crypto` | Yes | The rail an event or payment is on: card checkout; crypto (crypto checkout, or a coin paid straight to your wallet through the plugin or the gateway API); or Card to Crypto (card, Cash App or Venmo paid out to your wallet in USDC). |
| `data.payment_reference` | string or null | No | OnCharge's reference for the payment (`ocpay_…`). |
| `data.payment_link_id` | string (uuid) or null | No | The payment link the checkout was made from (`/api/v1/payment-links`), or null. |
| `data.invoice_id` | string (uuid) | No | Only on a payment for an OnCharge invoice: the invoice's id (see Invoices). |
| `data.payment_method` | one of `card`, `bank_debit`, `cash_app_pay`, `klarna`, `affirm`, `afterpay`, or `null` | No | How the shopper paid: `card`, or a way to pay beyond cards the store turned on (bank debit, Cash App Pay, Klarna, Affirm, Afterpay; see the Payment methods guide). Null for crypto. |
| `data.tax` | object or null | No | Sales tax on the payment, on payment, refund and chargeback events of a taxed payment only. |
| `data.tax.status` | one of `awaiting_address`, `calculated`, `pending`, `failed`, `collected`, `partly_refunded`, `refunded` | Yes | `awaiting_address`: no address yet, the payment waits. `calculated`: not paid yet. `pending`: tax included, charged while the calculation was unavailable; worked out shortly. `failed`: the calculation failed (`error`), the payment waits. `collected`, `partly_refunded`, `refunded`: paid, and how much of the tax was given back. |
| `data.tax.inclusive` | boolean | Yes | true when the listed prices include the tax. |
| `data.tax.currency` | string or null | Yes |  |
| `data.tax.subtotal` | integer or null | Yes | Before tax, minor units. |
| `data.tax.amount` | integer or null | Yes | The tax, minor units. |
| `data.tax.total` | integer or null | Yes | What the customer pays, minor units. |
| `data.tax.shipping` | integer | Yes | The shipping charge inside the total, minor units. |
| `data.tax.jurisdictions` | array of object | Yes |  |
| `data.tax.refunded` | integer | Yes | Tax given back so far with refunds and lost disputes, minor units. |
| `data.tax.error` | string or null | Yes | `tax_address_invalid` or `tax_unavailable` when `status` is `failed`. |
| `data.reason` | one of `limit_exceeded` | No | Only on `payment.refused` when OnCharge refused the payment itself: `limit_exceeded` (the store reached a limit OnCharge set on its account, such as a daily volume cap). Absent when the bank declined it. |
| `event` | one of `payment.pending`, `payment.authorized`, `payment.captured`, `payment.under_review`, `payment.refused`, `payment.cancelled`, `payment.expired`, `payment.capture_failed`, `refund.succeeded`, `refund.failed`, `chargeback.opened`, `dispute.evidence_due`, `chargeback.won`, `chargeback.lost`, `fraud_warning.received`, `delivery.confirmed`, `payout.paid`, `payout.failed`, `payout.returned`, `account.updated`, `account.requirements_due`, `account.restricted`, `swap.created`, `swap.completed`, `swap.failed`, `swap.refunded`, `swap.expired`, `subscription.created`, `subscription.updated`, `subscription.trial_will_end`, `subscription.past_due`, `subscription.paused`, `subscription.resumed`, `subscription.canceled`, `subscription.period.paid`, `subscription.period.payment_failed`, `support.conversation.created`, `support.message.received`, `support.conversation.closed` | No | Same as `type`. Kept for older plugins; only on payment events from a checkout. **Deprecated.** |
| `status` | string or null | No | Same as `data.status`. Kept for older plugins; only on payment events from a checkout. **Deprecated.** |
| `psp_reference` | string or null | No | Kept for older plugins, which store it as the order's transaction id: a payment made before 2026-12-01 keeps its original value here; from 2026-12-01 on it is the payment's OnCharge reference (`ocpay_…`, the same as `data.payment_reference`). Only on payment events from a checkout. **Deprecated.** |

```json title="payment.captured"

```
