Standalone sub-user pages & scoped UUID links
Issue short-lived UUID links from your backend so end users can top up their balance, view credited recharge history, or inspect balance and usage charges on standalone pages. Pages require no login, contain no platform navigation, adapt to phones and desktops, and never expose raw API keys in URLs.
1. Issue a scoped UUID link
Call POST /api/v1/org/access-links from your backend using your organization admin key (sk-org-…), specifying the page type and the sub-user's api_key (sk-io-…):
curl -X POST "$PLATFORM_ORIGIN/api/v1/org/access-links" \
-H "Authorization: Bearer $ORG_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "usage",
"api_key": "sk-io-...",
"locale": "en"
}'
Request parameters
| Field | Required | Description |
|---|---|---|
type | Yes | Page type: usage (usage statement), recharges (recharge history), or recharge (standalone recharge page) |
api_key | Yes | Sub-user API key (sk-io-…); resolved by hash and verified to belong to the authenticated organization |
locale | No | Target page locale (e.g. en, zh, zh-hant); defaults to the site default locale |
expires_in | No | TTL in seconds; defaults to 1800 (30 minutes), allowed range 60–86400 |
Response (HTTP 201)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"token": "550e8400-e29b-41d4-a716-446655440000",
"type": "usage",
"url": "<PLATFORM_ORIGIN>/en/statement/550e8400-e29b-41d4-a716-446655440000",
"expires_at": "2026-11-24T09:30:00.000Z"
}
Strict 1-to-1 scope & expiration rules
type | Standalone page URL | Authorized data endpoints |
|---|---|---|
usage | /{locale}/statement/{uuid} | GET /api/v1/me/statement only |
recharges | /{locale}/recharges/{uuid} | GET /api/v1/me/recharges only |
recharge | /{locale}/recharge/{uuid} | /api/v1/me/recharge-portal and /api/v1/me/recharge-portal/{orderId} only |
- Strict 1-to-1 scope: Each UUID grants access only to its issued page and matching endpoints; cross-page requests return 401
UNAUTHORIZED. - 30-minute default TTL: Expired links return 401; issue a fresh link from your backend when needed.
- No direct API-key URLs: Passing
sk-io-…directly to standalone pages or/api/v1/me/*portal endpoints is rejected. - Immediate revocation: Deleting a sub-user or organization immediately invalidates all active UUID links for that user.
The console's sub-user row action buttons (“Recharge”, “View recharge history”, “View user statement”) use the same flow, issuing a 30-minute UUID link and opening the standalone page in a new tab.
2. Usage statement endpoint (type = "usage")
curl "$PLATFORM_ORIGIN/api/v1/me/statement?limit=20" \
-H "Authorization: Bearer $USAGE_LINK_UUID"
HTTP 200 response:
{
"balance": "9.500000",
"currency": "USD",
"expires_at": "2026-11-24T09:30:00.000Z",
"rows": [
{
"id": "<request_uuid>",
"created_at": "2026-11-24T01:00:00Z",
"model": "gpt-4.1-mini",
"model_name": "GPT-4.1 Mini",
"model_icon_key": "openai",
"amount": "0.030000",
"billing_status": "settled"
}
],
"page": 1,
"limit": 20,
"has_next": false,
"next_cursor": null,
"from": "2026-11-23T02:00:00.000Z",
"to": "2026-11-24T02:00:00.000Z"
}
- Filters & pagination:
from(inclusive ISO 8601),to(exclusive; defaults to last 24h, max span 93 days),limit(default 20, max 100),page,cursor. Keep the returnedfrom/toon subsequent pages, passnext_cursor, and incrementpage. - Billing status:
settled(saved retailorg_cost; zero remains0),pending(amount=null),error(amount=null),unavailable(amount=null).
3. Recharge history endpoint (type = "recharges")
Returns only credited recharge records, ordered newest first with cursor pagination.
curl "$PLATFORM_ORIGIN/api/v1/me/recharges?limit=20" \
-H "Authorization: Bearer $RECHARGES_LINK_UUID"
HTTP 200 response:
{
"balance": "30.000000",
"currency": "USD",
"expires_at": "2026-11-24T09:30:00.000Z",
"rows": [
{
"id": "<transaction_uuid>",
"created_at": "2026-11-24T02:00:00Z",
"amount": "20.000000",
"balance_after": "30.000000",
"currency": "USD",
"provider": "stripe"
}
],
"page": 1,
"limit": 20,
"has_next": false,
"next_cursor": null,
"from": null,
"to": null
}
- Filters & pagination: Optional
fromandto(omit for all-time credited records),limit(default 20, max 100),page,cursor. provideriswechat,alipay,stripe, ornull.
4. Standalone recharge portal endpoints (type = "recharge")
The standalone recharge page /{locale}/recharge/{uuid} uses three login-free endpoints authenticated with a recharge-scoped UUID:
Fetch balance and currency
curl "$PLATFORM_ORIGIN/api/v1/me/recharge-portal" \
-H "Authorization: Bearer $RECHARGE_LINK_UUID"
Returns {"balance":"9.500000","currency":"USD","user_name":"Alice","expires_at":"2026-11-24T09:30:00.000Z"}.
Create a recharge order
curl -X POST "$PLATFORM_ORIGIN/api/v1/me/recharge-portal" \
-H "Authorization: Bearer $RECHARGE_LINK_UUID" \
-H "Content-Type: application/json" \
-d '{"provider":"stripe","amount":50,"locale":"en"}'
CNYdeployments supportwechat(returnscodeUrlfor QR rendering) andalipay(returnscheckoutUrl);USDdeployments supportstripe(returnscheckoutUrl).- Alipay and Stripe checkouts return directly to
/{locale}/recharge/{uuid}?payment=pending&order={orderId}without requiring login.
Poll order status
curl "$PLATFORM_ORIGIN/api/v1/me/recharge-portal/$ORDER_ID" \
-H "Authorization: Bearer $RECHARGE_LINK_UUID"
Returns the order status (pending / completed) and updated current_balance. All balance, link, and order responses set Cache-Control: no-store.