Redeem API Documentation

Programmatic redeem API — no Cloudflare captcha required

Check CDKBack to Home

POST /api/redeem

Authenticate with an API Key from the admin console. Pass Session only; each success consumes 1 quota. No card key needed.

Request Headers

Content-Type: application/json
X-Api-Key: <API Key>
# or Authorization: Bearer <API Key>

Request Body

{
  "session": "{...ChatGPT Session JSON...}"
}

Copy the full JSON from chatgpt.com/api/auth/session

Success Response

HTTP 200
{ "ok": true, "email": "[email protected]" }

Error Response

HTTP 4xx/5xx
{ "ok": false, "error": "card_used" }

cURL Example

curl -X POST https://your-domain.com/api/redeem \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -d '{"session": "<paste session json>"}'

GET /api/redeem/quota

Query API Key quota usage for balance display or renewal checks.

Request Headers

X-Api-Key: <API Key>
# or Authorization: Bearer <API Key>

Success Response

HTTP 200
{
  "ok": true,
  "prefix": "gpt_sk_0rLJZ",
  "note": "demo",
  "quota": 100,
  "used": 23,
  "remaining": 77
}

cURL Example

curl https://your-domain.com/api/redeem/quota \
  -H "X-Api-Key: YOUR_API_KEY"

Quota & Concurrency

API Keys control redeem count; quota is atomically deducted (FOR UPDATE prevents over-deduction)

  • 1. Request arrives → lock Key and reserve 1 quota
  • 2. Join succeeds → keep deduction, log email
  • 3. Join fails → refund quota, retry allowed
  • 4. Create and manage Keys in Console → API Integration

Error Codes

errorHTTPDescription
invalid_card400(Web only) Card key not found
card_used409(Web only) Card key already used
card_processing409(Web only) Card key is processing
card_expired410(Web only) Card key expired
email_not_allowed400Email domain not allowed
missing_token400Session missing accessToken
invalid_session400Invalid session format
no_capacity503Workspace full
join_failed502Failed to join workspace (often expired session)
quota_exceeded403API Key quota exceeded
too_many_requests429Too many requests
unauthorized401Invalid, disabled, or missing API Key
server_error500Internal server error

Web Redeem (Reference)

POST /api/invite — requires Cloudflare captcha, for web users

Generate API Keys in the admin console. Do not share them.