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
| error | HTTP | Description |
|---|---|---|
| invalid_card | 400 | (Web only) Card key not found |
| card_used | 409 | (Web only) Card key already used |
| card_processing | 409 | (Web only) Card key is processing |
| card_expired | 410 | (Web only) Card key expired |
| email_not_allowed | 400 | Email domain not allowed |
| missing_token | 400 | Session missing accessToken |
| invalid_session | 400 | Invalid session format |
| no_capacity | 503 | Workspace full |
| join_failed | 502 | Failed to join workspace (often expired session) |
| quota_exceeded | 403 | API Key quota exceeded |
| too_many_requests | 429 | Too many requests |
| unauthorized | 401 | Invalid, disabled, or missing API Key |
| server_error | 500 | Internal 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.