Referencia de la API

Crédito

Crédito de la organización: saldo, límite y modo.

GET /v1/credit

My organization's credit

API key con credit:read · Rol: viewer o superior

Any signed-in member, or an API key with the scope `credit:read`. The organization's credit account, in signed integer USD micros: `balance`, `credit_limit` (0 when prepaid), `reserved` (held by calls in progress) and `available`, which is `balance + credit_limit - reserved`. `mode` is `off`, `shadow` (what would be denied is recorded, nothing is) or `enforce`; `low_balance` is true when `available` is below the organization's threshold. An organization created after credit control began gets its account the first time it is read. 401 when the token is missing, expired or invalid; 503 when credit is not available.

Respuestas

  • 200 Successful Response · CreditResponse
    NombreTipoRequeridoDescripción
    availableintegersí`balance + credit_limit - reserved`, in signed USD micros.
    balanceintegersíSigned integer USD micros (1 USD = 1,000,000).
    credit_limitintegersíUSD micros the balance may go below zero: 0 when prepaid.
    low_balancebooleansíTrue when `available` is below the low-balance threshold.
    low_balance_thresholdintegersíUSD micros below which `available` counts as low.
    modestringsíHow strictly credit gates calls: `off` never, `shadow` records what it would deny, `enforce` denies. (off, shadow, enforce)
    reservedintegersíUSD micros held by calls in progress.
  • 401 Missing, expired or invalid token. · ErrorResponse
  • 403 Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse
  • 429 The API key went over its requests per minute. · ErrorResponse
  • 503 Credit is not available yet. · ErrorResponse
  • default Default Response · ErrorResponse

GET /v1/credit/ledger

My organization's credit ledger

API key con credit:read · Rol: viewer o superior

Any signed-in member, or an API key with the scope `credit:read`. The append-only ledger of the organization's credit, newest first, `limit` (1 to 100, default 50) per page; pass `next_cursor` as `cursor` for older entries. Each entry has its `kind` (`grant`, `limit_change`, `charge`, `adjustment`, `provisional_charge` or `reconciliation`), `amount_micros` and `balance_after_micros` in signed integer USD micros, an opaque `reference` and, for calls, the `call_id`. 401 when the token is missing, expired or invalid; 403 for an API key without `credit:read`; 422 for an invalid cursor or limit; 503 when credit is not available.

Parámetros

NombreEnTipoRequeridoDescripción
cursorquerystring | null
limitqueryinteger

Respuestas

  • 200 Successful Response · LedgerResponse
    NombreTipoRequeridoDescripción
    itemsLedgerEntryResponse[]sí
    items[].actorstringsíWho or what posted it.
    items[].amount_microsintegersíSigned integer USD micros (1 USD = 1,000,000).
    items[].balance_after_microsintegersíSigned integer USD micros (1 USD = 1,000,000).
    items[].call_idstring (uuid) | nullThe call, for call charges.
    items[].created_atstring (date-time)sí
    items[].idstring (uuid)sí
    items[].kindstringsí (grant, limit_change, charge, adjustment, provisional_charge, reconciliation)
    items[].referencestringsíOpaque idempotency reference.
    next_cursorstring | nullsíPass as `cursor` for older entries.
  • 401 Missing, expired or invalid token. · ErrorResponse
  • 403 Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse
  • 429 The API key went over its requests per minute. · ErrorResponse
  • 503 Credit is not available yet. · ErrorResponse
  • default Default Response · ErrorResponse