Credits

Top up agent credits

Creates a USD invoice that adds its amount to a credit balance once it is paid. Without credit_account_id, a new credit account is created and its token is returned. The token is shown only in this response, so store it. Send credit_account_id to top up an existing account; the token is then not returned again. Rate limit: 60 per minute per API key, shared with the other endpoints that have this limit.

POST
/api/v1/credits/topup

Authorization

bearerAuth
headerAuthorizationBearer <token>

A live API key, sk_live_ followed by 32 base58 characters.

Header Parameters

Idempotency-Key?string

A unique string of 1 to 255 characters for this operation. A key belongs to the business across every endpoint for 24 hours, so give each operation its own key, for example invoice-order-1042 and refund-order-1042, not the order id alone. A retry with the same key on the same endpoint and with the same body returns the stored response with the header Idempotent-Replayed: true. The same key with a different body or on another endpoint returns 409 idempotency_conflict. Errors are not stored, so a request that failed can be retried with the same key, even with a corrected body. While the first request with a key is still running, a retry gets 409 idempotency_conflict with Retry-After: 1.

Length1 <= length <= 255

Request Body

application/json
  1. body
amount*string

Decimal string with up to 2 decimals, greater than 0.

Match^\d{1,9}(\.\d{1,2})?$
currency*string

Credits are kept in USD.

credit_account_id?string

Top up this existing account instead of creating a new one.

Length1 <= length

Response Body

The credit account and the invoice that funds it.

application/json
  1. response
credit_account*
invoice*
Example Request
curl -X POST 'https://example.com/api/v1/credits/topup' \  -H 'Content-Type: application/json' \  -d '{  "amount": "10.00",  "currency": "USD"}'
Example Response
{  "credit_account": {    "id": "cra_9pL3vN7rB2sT4mW8xQ5k",    "object": "credit_account",    "token": "string",    "balance": "string",    "currency": "USD"  },  "invoice": {    "id": "inv_7h3K9dWq2LmN4pRt6vXy",    "object": "invoice",    "mode": "live",    "status": "created",    "amount": "string",    "currency": "USD",    "order_id": "string",    "description": "string",    "customer_email": "string",    "redirect_url": "string",    "metadata": {      "property1": "string",      "property2": "string"    },    "settlement": {      "asset_id": "string",      "symbol": "string",      "blockchain": "string",      "amount": "string",      "amount_base": "string"    },    "late": true,    "extra_payment": true,    "checkout_url": "http://example.com",    "receipt_url": "http://example.com",    "redeemed_at": "2019-08-24T14:15:22Z",    "expires_at": "2019-08-24T14:15:22Z",    "created_at": "2019-08-24T14:15:22Z"  }}