Authentication and credentials
Three credential classes, three different headers, three different lifetimes. Using the wrong one is the second most common integration bug.
Bardiya issues credentials that are not interchangeable. The contract declares one security scheme per operation, and the reference page for each operation names it.
| Credential | Header | Who holds it | Lifetime |
|---|---|---|---|
| Maps API key | X-API-Key: bdy_... | Your backend | Until revoked |
| Tracking API key | Authorization: Bearer bdy_... | Your backend | Until revoked |
| Client token | Authorization: Bearer bdy_cli_... | A device or a browser | Minutes (you choose the TTL) |
| Session ingest token | Authorization: Bearer ... | One device, one session | The session |
Maps keys
Maps operations accept X-API-Key. The style and tile endpoints additionally accept ?api_key= because MapLibre cannot attach request headers to tile fetches; treat a tile URL as a credential and avoid logging it.
curl "https://api.bardiyamap.com/v1/places/search?q=cairo" \
-H "X-API-Key: $BARDIYA_API_KEY"Tracking keys
Tracking operations accept only Authorization: Bearer. A Maps key in that position is rejected, and a tracking key in X-API-Key is rejected. Sessions, webhooks, subscriptions and client tokens are all tracking-family.
curl "https://api.bardiyamap.com/v1/tracking/sessions?limit=10" \
-H "Authorization: Bearer $BARDIYA_TRACKING_KEY"Never ship the organization key
A browser bundle, a React Native binary and an Android APK are all readable by their users. The safe pattern is: your backend holds the organization key, the device holds a short-lived client token that your backend mints for a specific subject, and the device sends that token.
- Mint on the server
POST /v1/tracking/client-tokens with the subjects the device may act for and a short ttl_seconds. The response contains the plaintext token once.
- Deliver over your own authenticated channel
Send the token to the device through your app session, never in a URL, a query string or an analytics payload.
- Refresh before expiry
When the token expires the device must come back to your backend. Do not extend the TTL to days to avoid the refresh: that converts a short-lived credential into a permanent one.
- Scope ingest per session
POST /v1/tracking/sessions/{session_id}/ingest-token issues a credential bound to one session. A leaked device token then cannot write to another session.
Scopes
A key carries scopes. A request whose key lacks the required scope returns 403 with a stable error code, not 401. List the scopes available in your organization from GET /console/api-key-scopes in the console session, or read them on each key in the console.
Rotation and revocation
Create the replacement key, deploy it, confirm the new key works, then revoke the old one. Revocation is immediate and cannot be undone. A revoked key produces 401 on every operation, including tiles already embedded in a deployed style.
