API Reference
Programmatic access to forecasting, inventory, transfers, catalog, and alerts uses tenant-scoped credentials. The primary pattern is Bearer API keys issued from your organization’s admin settings.
API keys authenticate requests without browser sessions. Keys are tenant-scoped and support granular permissions via scopes.
/admin/api)API keys are displayed only once at creation. If lost, create a new key. Never commit keys to version control.
1curl -X POST "https://app.betterdata.co/api/admin/api-keys" \2 -H "Authorization: Bearer YOUR_SESSION_TOKEN" \3 -H "Content-Type: application/json" \4 -d '{5 "name": "Production API Key",6 "scopes": ["inventory:read", "forecast:read"]7 }'1curl -X GET "https://app.betterdata.co/api/inventory/channel-location?locationId=loc_123&page=1&limit=50" \2 -H "Authorization: Bearer bdk_live_ABC123_<your-key>" \3 -H "Content-Type: application/json"| Area | Examples |
| --- | --- |
| Inventory | inventory:read, inventory:write, inventory:* |
| Forecasting | forecast:read, forecast:write |
| Planning / procurement / shipping / reports | planning:*, procurement:*, shipping:*, reports:read |
| Admin | admin:read, admin:write (tenant admin) |
| Wildcard | * — all operations (use with caution) |
GET /api/admin/api-keys (session auth)PATCH /api/admin/api-keys/{id}POST /api/admin/api-keys/{id}/revokePOST /api/admin/api-keys/{id}/rotate| Code | Status | Meaning |
| --- | --- | --- |
| MISSING_AUTHORIZATION | 401 | No Authorization header |
| INVALID_API_KEY | 401 | Key not found or invalid |
| REVOKED_API_KEY | 401 | Key revoked |
| EXPIRED_API_KEY | 401 | Key expired |
| INACTIVE_ORGANIZATION | 403 | Org not active |
| IP_RESTRICTION | 403 | Key not allowed from this IP |
| INSUFFICIENT_SCOPE | 403 | Missing scope |
Store keys in environment variables or a secrets manager; rotate periodically and grant least privilege.
The Better Data LLM Gateway uses standard HTTP headers to verify clients.
For server-to-server calls or a self-hosted gateway with a configured key list:
Header:
1Authorization: Bearer YOUR_API_KEYConfigure keys in LLM Gateway Configuration.
Include X-Session-Id to tie requests to a user’s cart and conversation history:
1X-Session-Id: unique_session_string_123When using the Hosted Gateway, use Cloud API keys from the dashboard — scoped to your account and your plan.
For handoffs from an AI to a storefront, the gateway can issue a short-lived Secure Link Token as a query parameter; the storefront upgrades it to a session cookie.
Example:
1https://mystore.com/checkout?token=st_abc123Inbound platform webhooks (e.g. Stripe) are verified with provider signatures — not your tenant API key. See Webhooks for Stripe and Square.
