Errors

Every error the LinkTrail SDKs report on iOS, Android, React Native and Flutter, what causes each, and the HTTP statuses behind them: 401, 404, 429, 5xx.

All four SDKs report the same eight errors, because the wrappers pass the native ones through. They arrive on onError — and, on the calls that return a result (the async/suspend forms on iOS and Android, the Promises in React Native, the Futures in Flutter), as the thrown or rejected error.

The eight errors

iOS `LinkTrailError`Android `LinkTrailError`React Native `code`FlutterCause and fix
.missingAPIKeyMissingApiKeymissing_api_keyLinkTrailMissingApiKeyExceptionconfigure got a blank key. Thrown by configure itself (React Native rejects). Pass your lt_live_… key.
.invalidAPIKeyInvalidApiKeyinvalid_api_keyLinkTrailInvalidApiKeyExceptionThe backend answered 401: the key is wrong or revoked. Arrives on onError, never from configure, and only once the install is sent — after setConsent, or at configure with requireConsent: false. Check Settings → API Keys.
.server(statusCode:body:)Server(statusCode, body)serverLinkTrailServerExceptionAny other non-2xx answer, after retries. Read the status code: see the table below.
.transport(message:)Transport(detail)transportLinkTrailTransportExceptionThe request never got an answer: offline, a timeout, or a network that blocks https://backend.linktrail.io. Retried before it is reported.
.decoding(message:)Decoding(detail)decodingLinkTrailDecodingExceptionThe answer was not the JSON the SDK expected — often a proxy or captive portal answering in its place.
.emptyResponseEmptyResponseempty_responseLinkTrailEmptyResponseExceptionThe answer had no body where one was expected. Usually the same cause as a decoding error.
.notALinkTrailURLNotALinkTrailUrlnot_a_linktrail_urlLinkTrailNotALinkTrailUrlExceptionhandleDeepLink was given a URL that is not a LinkTrail link — see Which links the SDK claims. Not a fault: route it yourself. (The plain iOS and Android forms return false instead; React Native resolves null.)
.invalidURL(_:)InvalidUrl(url)invalid_urlLinkTrailInvalidUrlExceptionThe SDK could not build a request URL. Not expected in normal use — report it on the SDK's issue tracker.

The wrappers add one each: React Native's not_configured (a call made before configure finished) and unknown, and Flutter's LinkTrailUnknownException for a native code it does not recognise.

HTTP statuses

The SDKs call https://backend.linktrail.io. Its errors are JSON of the shape { "code": …, "message": … } — except the per-IP 429, whose body is the plain text Too many requests, please try again later.

StatusMeansWhat the SDK does
401The API key is wrong, revoked or missing: {"code":401,"message":"Invalid or missing API key"}Not retried. Reported as the invalid-API-key error.
404The app is not registered in the key's workspace: {"code":404,"message":"No app found for this identifier in your workspace"}. The SDK sends the identifier the build has — a debug build with a suffixed ID needs its own registered app.Not retried. Reported as a server error with status 404.
429Too many requests from one IP address (currently 100 a minute on the SDK endpoints). This body is plain text, not JSON.Retried with exponential backoff, honouring Retry-After, then reported as a server error with status 429.
408The request timed out.Reported as a server error with status 408. A custom event that gets it is kept in the offline queue and sent again later.
5xxA backend error.Retried the same way, then reported as a server error with that status.
400The request failed validation. The SDKs should never send one — report it.Not retried. Reported as a server error with status 400.

By default the SDKs make 3 attempts, starting at a 0.5-second backoff and capped at 8 seconds; retryPolicy changes it (.disabled / DISABLED turns retries off). Network failures are retried the same way before they are reported as transport errors.

Invalid options never throw. configure fixes each out-of-range value and logs a WARNING: fewer than 1 attempt becomes 1, a base delay of 0 or less becomes 0.5 s, a maximum delay of 0 or less becomes 8 s, a maximum delay below the base delay is raised to it, and a request timeout of 0 or less becomes 15 s.

Only retryable failures are queued. A custom event that still fails after its retries with a transport error, 408, 429 or a 5xx is kept in the offline queue and sent again later. Any other status (400, 401, 403, 404, 409, 422, …) reaches onError and the event is dropped — it is not retried on a later launch, and the log shows [LinkTrail] [WARNING] Event '<name>' rejected (<status>) — not retried.

Every request the SDKs make — install, open, events and link resolve, retries included — sends an X-LinkTrail-SDK header naming the SDK build: ios/<version> or android/<version>, and on Android the wrappers send react-native/<version> or flutter/<version>. Known gap: on iOS the React Native and Flutter wrappers report ios/<version> until iOS 0.1.1. The header never changes the response.

Note

A failing install does not throw from configure and does not crash the app — it is only visible on onError and in the SDK logs. Watch both while integrating; Troubleshooting lists the usual causes by symptom.