Skip to content

Redeem a Voucher

POST
/v1/credits:redeem
curl --request POST \
--url https://example.com/v1/credits:redeem \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <X-API-Key>' \
--data '{ "code": "example" }'

Redeem a credit voucher for your organization, as the billing page does.

Any member of the organization may redeem; a key needs credits:write. Credits are the organization’s, so a workspace or restricted key is refused. An unknown, used or expired code is a 400 with the reason. Buying credits stays in the dashboard.

Media type application/json
RedeemVoucherRequest

A voucher code, as the billing page takes it.

object
code
required

The voucher code to redeem

string
>= 1 characters <= 256 characters
Example generated
{
"code": "example"
}

The voucher’s credits were added

Media type application/json
VoucherRedemptionResponse

A redeemed voucher.

object
credits_granted
required

Credits the voucher added

integer
account_id
required

The organization they were added to

string
Example generated
{
"credits_granted": 1,
"account_id": "example"
}

An unknown, used or expired code, in the billing page’s words

Media type application/json
ErrorResponse

Standard error response.

object
detail
required

Error message describing what went wrong

string
Example generated
{
"detail": "example"
}

Invalid or missing API key

Media type application/json
ErrorResponse

Standard error response.

object
detail
required

Error message describing what went wrong

string
Example generated
{
"detail": "example"
}

The key lacks credits:write, or is a workspace key

Media type application/json
ErrorResponse

Standard error response.

object
detail
required

Error message describing what went wrong

string
Example generated
{
"detail": "example"
}

Validation Error

Media type application/json
HTTPValidationError
object
detail
Array<object>
ValidationError
object
loc
required
Location
Array<string | integer>
msg
required
Message
string
type
required
Error Type
string
input
ctx
Context
object
Example generated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}