GET /api/v1/credits

Prepaid X credit: balance, the X API price list (X's price × markup, 1 by default) and the latest ledger entries. With X credit on, X calls are debited before they are sent, refunded when X refuses them (4xx), and refused with 402 insufficient_x_credit when the balance does not cover them

GET
/api/v1/credits

Authorization

BearerAuth
headerAuthorizationBearer <token>

API key sk_...

Query Parameters

limit?integer

Maximum items (default 50, max 200)

Range1 <= value <= 200
Default50
before?string

nextBefore of the previous page

Formatdate-time

Response Body

Credits

application/json
  1. response
currency?"USD"
Value in"USD"
balance?number

X credit balance in USD (negative only after a refund of spent credit)

balanceMicros?string

Balance in USD micro-units

lowBalance?boolean
lowBalanceThreshold?number
metered?boolean

X credit applies (X_CREDIT_ENABLED and X live): X calls are paid from this balance

markup?number

Multiplier on X's prices (1 = exactly X's cost)

prices?array<>
ledger?array<>

Newest first

nextBefore?|

Pass as before for the next page

topup?

Top-ups are bought by workspace owners and admins in the dashboard (Stripe Checkout); the processing fee is added on top so the full credit is received

Example Request
curl -X GET 'https://example.com/api/v1/credits'
Example Response
{  "currency": "USD",  "balance": 0,  "balanceMicros": "string",  "lowBalance": true,  "lowBalanceThreshold": 0,  "metered": true,  "markup": 0,  "prices": [    {      "action": "string",      "label": "string",      "xPrice": 0,      "price": 0    }  ],  "ledger": [    {      "id": "string",      "type": "topup",      "amount": 0,      "amountMicros": "string",      "action": "string",      "platform": "string",      "reason": "string",      "createdAt": "2019-08-24T14:15:22Z"    }  ],  "nextBefore": "string",  "topup": {    "enabled": true,    "presets": [      {        "credit": 0,        "fee": 0,        "total": 0      }    ],    "minimum": 0,    "maximum": 0,    "processingFee": {      "fixed": 0,      "percent": 0    }  }}