Save a payment method for auto-topup
POST
/account/auto-topup/setup
bearer_auth
Creates a payment session in **setup** mode so the account can save a card for later automatic top-ups. **No charge happens here** — the payment method (ids + card fingerprint/brand/last4 only) is persisted once the provider confirms the session. Gated to `status: ready` and requires the invoice-grade `company` block to be fully set (same as `POST /account/topup`); an incomplete company block is rejected with a `400` that points to `PATCH /account`. Dormant while auto-topup is disabled for the deployment: the route responds `404` like any unknown route.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Authorization |
header | string | yes | `Bearer <token>` obtained from `POST /login`. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
success_url |
string | no | Optional https URL the browser is returned to after the card is saved. Any https host is accepted. |
cancel_url |
string | no | Optional https URL the browser is returned to when the setup is cancelled. Same rules as `success_url`. |
{
"success_url": "https://console.example/billing?setup=success",
"cancel_url": "https://console.example/billing"
}
Responses
| Status | Description |
|---|---|
200 |
Payment setup session created. |
400 |
Company info not fully set (all `company` fields required before a card can be saved; update them via `PATCH /account`), or an invalid `success_url`/`cancel_url` (must be https with a host, ≤2048 chars). |
401 |
Missing or invalid credentials. |
404 |
Account not found, or auto-topup is disabled for the deployment (route hidden). |
409 |
Account is not ready yet (`status` is not `ready`). |
502 |
Upstream payment call failed; a generic error is returned and no internals are leaked. |
200 example
{
"checkout_url": "https://pay.example.com/c/cs_123",
"session_id": "cs_123"
}