Authentication
The app does not hold the credential that creates tokens. The backend does. tokenProvider returns the next bearer. The backend calls YAS with the server key.
- The SDK calls
tokenProvider. - The app calls its backend.
- The backend calls
POST /v1/vehicles/tokenswith the server key.POST /v1/tokensis deprecated. - YAS returns
accessTokenandexpiresAt. tokenProviderreturns those values to the SDK.
Return accessToken and expiresAt within 30 seconds. Pass expiresAt exactly as YAS returned it. Only the first completion counts. These are failures: no completion within 30 seconds, a null or empty token, the same token as the previous one, an expiresAt the SDK cannot read, or an expiresAt that is already in the past. On iOS, a token that contains a newline is also a failure. Mint the token for the partnerId, driverId, and vehicleId from setup. A token that does not match those values is rejected.
If tokenProvider fails, recording continues and the trace stays on the phone. Call endTrip when the job ends.
The server key never enters the app. The backend also sends that key on POST /v1/vehicles/trips/end (beta). POST /v1/trips/end is deprecated.
tokenProvider asks your backend, then returns the bearer. Do not show UI inside it.
tokenProvider: { completion in // completion(accessToken, expiresAt) // completion(nil, nil) on failure.}tokenProvider = { completion -> // completion(accessToken, expiresAt) // completion(null, null) on failure.}Server key
Section titled “Server key”| Caller | The backend |
| Header | Authorization: Bearer <serverKey> |
| Body | partnerId, driverId, vehicleId |
| Success | accessToken, expiresAt, tokenType (Bearer) |
| Failure | Body { "error": "<code>" }. 400 invalid_body when the body is not a JSON object, partnerId does not match ^[a-z0-9-]{1,64}$, or driverId or vehicleId is missing or empty. 401 invalid_credentials when the server key is missing or wrong. 403 forbidden when the server key is not enabled for this call. 403 identity_mismatch when partnerId does not match the server key. The format check runs before the partner match. |
curl https://api.example.yas/v1/vehicles/tokens \ -H "authorization: Bearer $SERVER_KEY" \ -H "content-type: application/json" \ -d '{"partnerId":"partner","driverId":"drv_example","vehicleId":"veh_example"}'POST /v1/vehicles/tokens HTTP/1.1Host: api.example.yasAuthorization: Bearer <server-key>Content-Type: application/json
{"partnerId":"partner","driverId":"drv_example","vehicleId":"veh_example"}A successful response:
{ "accessToken": "eyJexample", "expiresAt": "2026-10-16T12:00:00.000Z", "tokenType": "Bearer"}The token lasts 24 hours.
Next: Permissions.
API region
Section titled “API region”For database-heavy calls to the Supabase-hosted API, send x-region: ap-southeast-1 to run near the Singapore database. Check x-sb-edge-region in the response. Pinning disables automatic regional failover; change or remove the header during a regional outage. This header is for API calls, not uploads to returned Storage URLs. See Supabase regional invocation.
