Skip to Content
The AKIN Travel developer platform is in beta — APIs may change. Get started →
ErrorsOverview

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 }

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);

Reference

The full list of error codes is in Error codes — generated from the API source, so it cannot drift.

Last updated on