Credits

Charge agent credits

Deducts an amount in USD from the balance of the credit account that owns token. The paywall middleware calls this once per paid request. Returns 409 with type insufficient_credit when the balance is too low. Rate limit: 600 per minute per API key.

POST
/api/v1/credits/charge

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
token*string

The agent's credit token.

Match^solverr_credit_[1-9A-HJ-NP-Za-km-z]{32}$
amount*string

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

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

Optional. Any other value is refused, because balances are in USD.

description?string
Lengthlength <= 200

Response Body

The charge, with the balance after it.

application/json
  1. response
id*string

Charge id, starting with cru_; pass it to the refund endpoint to give the charge back.

object*string
amount*string

Amount charged in USD with 6 decimals.

refunded?boolean

Present and true on the refund endpoint's answer.

balance*string

Balance in USD with 6 decimals after this charge or refund.

currency*string
Example Request
curl -X POST 'https://example.com/api/v1/credits/charge' \  -H 'Content-Type: application/json' \  -d '{  "token": "string",  "amount": "string"}'
Example Response
{  "id": "string",  "object": "credit_charge",  "amount": "string",  "refunded": true,  "balance": "string",  "currency": "USD"}