Skip to content
Developer documentation

Authentication and credentials

Three credential classes, three different headers, three different lifetimes. Using the wrong one is the second most common integration bug.

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.

CredentialHeaderWho holds itLifetime
Maps API keyX-API-Key: bdy_...Your backendUntil revoked
Tracking API keyAuthorization: Bearer bdy_...Your backendUntil revoked
Client tokenAuthorization: Bearer bdy_cli_...A device or a browserMinutes (you choose the TTL)
Session ingest tokenAuthorization: Bearer ...One device, one sessionThe 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.

shell
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.

shell
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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.