API Keys, Usage, and Billing Helpers
This page documents workspace-level API-key management and lightweight usage/billing helper endpoints.Endpoints
API key lifecycle
GET /api/workspaces/:workspaceId/api-keysPOST /api/workspaces/:workspaceId/api-keysPUT /api/workspaces/:workspaceId/api-keys/:keyIdDELETE /api/workspaces/:workspaceId/api-keys/:keyId
Workspace helper reads
GET /api/workspaces/:workspaceId/usageGET /api/workspaces/:workspaceId/billing
Auth, scopes, and feature gates
- API-key lifecycle routes are session-only and reject API-key auth.
- Permission family:
api_keys:read,api_keys:create,api_keys:update,api_keys:delete
- API key creation/update/delete require API-access entitlement (
apiAccessfeature). - Helper reads require
billing:read.
Create API key payload
POST /api/workspaces/:workspaceId/api-keys
nameis required.scopesdefaults to link CRUD scopes if omitted.- Invalid scopes return
INVALID_SCOPES. rateLimitis clamped to100..10000.expiresAtmust be valid ISO date string if provided.- Plan limits are enforced before creation.
- Concurrent create requests can return
409 CONCURRENT_REQUEST.
- Plain API key value is returned only on creation.
Update API key payload
PUT /api/workspaces/:workspaceId/api-keys/:keyId
nameenabledrateLimit
Usage helper response shape
GET /api/workspaces/:workspaceId/usage returns:
usage: links, rules, domains, campaigns, pixels, apiKeys, clickslimits: current plan limitscredits: balance/included/used cycle microsplan: plan tier
Billing helper response shape
GET /api/workspaces/:workspaceId/billing is a compatibility helper that returns workspace plan and basic billing fields.
Use /api/billing/* routes for full subscription lifecycle, credit purchases, auto-recharge, and invoice history.
Common errors
400: invalid name/scopes/rateLimit/expiresAt403: missing permission or feature gate, plan limit exceeded404: API key/workspace not found409: concurrent create lock or state conflict

