Error handling
Every error returned by the AKIN Travel API is a GraphQL error with two stable extension fields:
extensions.code— machine-readable identifier. Branch on this.extensions.translationKey— i18n key your client can map to localised copy.
The message field is a human-readable English fallback. Copy may change between releases. Do not pattern-match on messages.
The shape
{
"errors": [
{
"message": "Authentication required",
"extensions": { "code": "AUTH_REQUIRED", "translationKey": "errors.authRequired" }
}
],
"data": null
}Recommended pattern
Read the first error’s extensions.code and switch on it. The same logic applies in any language:
function handle(code: string) {
switch (code) {
case 'AUTH_REQUIRED':
case 'TOKEN_EXPIRED':
return redirectToSignIn();
case 'ACCESS_DENIED':
return showAccessDeniedToast();
case 'RATE_LIMITED':
return scheduleRetry(); // honour the Retry-After header
default:
return reportToTelemetry(code);
}
}
// Raw fetch (any stack)
const body = await res.json();
const code = body.errors?.[0]?.extensions?.code;
if (code) handle(code);On React with the SDK, the same code lives on ApolloError:
import { ApolloError } from '@apollo/client';
if (err instanceof ApolloError) handle(err.graphQLErrors[0]?.extensions?.code as string);Partner Reporting API refusals
The Partner Reporting API refuses with three codes. The message says which check failed; branch on the code.
| Code | Message starts with | Cause | What to do |
|---|---|---|---|
ACCESS_DENIED | The Partner Reporting API is not available | The API is switched off | Try again later, or ask your AKIN Travel contact |
ACCESS_DENIED | Unauthorized: Valid partner API key required | No key, or a key that is not valid | Send a valid key in x-partner-api-key |
ACCESS_DENIED | Forbidden: this is a publishable (browser-safe) partner API key | A publishable key | Use a secret key, from your server |
ACCESS_DENIED | Forbidden: partner API key is missing required scope "reporting:read" | The key does not hold the scope. A publishable key never holds it | Add reporting:read to a secret key in the dashboard |
ACCESS_DENIED | Forbidden: this partner has no Partner Reporting API grant | Your partner does not hold the grant | Ask AKIN to turn it on |
ACCESS_DENIED | Property is not accessible with this partner API key | propertyId is not one of your properties | Use one of your own property ids |
RATE_LIMITED | Partner Reporting API rate limit exceeded | More than 60 reporting calls a minute on this key (HTTP 429) | Wait until extensions.resetsAt (Rate limits) |
VALIDATION_ERROR | (names the rule) | A date, window or cursor outside the rules. A page size is never refused: it is read as 1 to 500 | Fix the argument named in extensions.context.field |
Reference
The full list of error codes is in Error codes — generated from the API source, so it cannot drift.
Last updated on