TrackMe API Docs
Getting started

Localisation & Timezone

How to drive Arabic vs English copy with Accept-Language, send the device timezone with X-Timezone, and why every wire timestamp stays UTC.

Two request headers control how the API talks back to you: Accept-Language picks the language of human-facing copy, and X-Timezone picks the IANA zone used to render display strings. Neither header changes the machine-readable data — every timestamp on the wire is UTC ISO-8601 with a trailing Z, no matter what you send. Set both headers once in your HTTP client and forget them.

These headers apply to every JSON endpoint under /api/v1 — public, authenticated customer, and owner alike. They are independent of the Bearer token: an anonymous discovery call honours Accept-Language and X-Timezone exactly the same way an authenticated /me call does.

Send both headers on every request, not just login. The server resolves language and timezone per request from the headers present on that request. There is no server-side "remembered" device language for API callers — if you send Accept-Language: ar at login and then omit it on the next call, the next call falls back to English. Configure them as default headers on your Dio/http client so they ride along automatically.

The end-to-end sequence

This is all there is to it. Do this once when you build your HTTP client.

Step 1 — Set the two default headers on your client

Add both headers to every outbound request. Accept-Language is en or ar. X-Timezone is the device's IANA zone name from the OS (e.g. Asia/Riyadh, Africa/Cairo).

GET /api/v1/trucks/search HTTP/1.1
Host: api.trackme.example
Authorization: Bearer oat_01j9z...
Accept-Language: ar
X-Timezone: Asia/Riyadh

Step 2 — Read data fields as UTC, always

Every timestamp in data is UTC ISO-8601 with a Z. Parse it as UTC, then convert to local time in the app for display. The X-Timezone header does not rewrite these fields.

{
  "data": {
    "id": "ord_01j9z...",
    "status": "preparing",
    "createdAt": "2026-06-21T09:14:03.000Z",
    "scheduledPickupAt": "2026-06-21T11:30:00.000Z"
  },
  "meta": { "requestId": "req_01j9z..." }
}

Step 3 — Let the server localise copy it generates for you

Error messages, push-notification text, and emails are resolved server-side from Accept-Language. You do not translate these yourself — render error.message (or the notification body) directly.

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "يجب أن يكون البريد الإلكتروني صالحًا."
  },
  "meta": { "requestId": "req_01j9z..." }
}

Step 4 — (Customers only) save the user's language preference explicitly

If you let a signed-in user pick their app language in settings, persist it with PATCH /api/v1/me ({ "language": "ar" }). This is a stored profile field, separate from the per-request Accept-Language header — see the gotcha below.

Localisation — Accept-Language

Send Accept-Language: en or Accept-Language: ar. The default when the header is missing or unrecognised is en. The server matches on the language prefix, so en-US resolves to en and ar-SA resolves to ar — full BCP-47 tags are tolerated. Only the first value in a comma-separated list is read; quality values (;q=0.8) are ignored.

What the resolved locale drives:

SurfaceLocalised by Accept-Language?
Domain error message (validation, conflict, etc.)Yes
Push notification title/bodyYes
Transactional emails (subject + body)Yes
OTP delivery copy (email / SMS / WhatsApp)Yes
Owner-entered content (truck name, menu items, job posts)Resolved by the locale too, with per-field fallback to English when the Arabic value is blank
Error code (VALIDATION_ERROR, AUTH_REQUIRED, …)No — code is a stable identifier; only message is translated

Resolution order

For API callers the header is effectively the only signal, but the full order the server walks is:

  1. ?locale= query parameter — admin-web convenience only; persisted into the session.
  2. Session value — the admin sticky preference. Not set for token-auth API calls.
  3. Accept-Language header — the mobile-app channel. For API callers, this is the single source of truth.
  4. Fallback to en.

user.language is not the request language. The server never reads the saved user.language column to decide which language to reply in — locale is resolved per request from the header chain above. PATCH /api/v1/me with { "language": "ar" } only writes a stored preference for your app to read back later; it does not change how the API localises the next response. If you save ar to the profile but keep sending Accept-Language: en, every error and notification still comes back in English. Keep the header in sync with the user's chosen language.

Timezone — X-Timezone

Send the device's IANA timezone name, e.g. X-Timezone: Asia/Riyadh. Use the canonical IANA name (Asia/Riyadh, Africa/Cairo, America/New_York), not a UTC offset like +03:00 and not an abbreviation like AST — those fail validation and silently fall back to Asia/Riyadh. The header binds the request timezone for the lifetime of that request; it affects only server-rendered display strings (push-notification copy, email subject lines, pretty-printed scheduled-pickup times). Raw ISO timestamps in data stay UTC regardless.

Resolution order (full chain)

The timezone middleware resolves the request zone in this exact order and stops at the first valid IANA name:

  1. ?tz= query parameter — a convenience override; also persisted into the session for admin sticky navigation.
  2. Session timezone — the admin sticky value from a previous ?tz= choice. Not set for token-auth API calls.
  3. X-Timezone header — the canonical mobile-app channel. Send your device IANA name here on every request.
  4. Accept-Timezone header — a tolerated legacy alias for older clients. Prefer X-Timezone.
  5. Asia/Riyadh fallback — used when no signal arrives, or when the supplied value fails IANA validation.

Each candidate is validated independently: a whitespace-only or invalid X-Timezone is skipped, and resolution falls through to Accept-Timezone, then the fallback — it does not pin you to the fallback prematurely. Because invalid names are coerced rather than rejected, a malformed header never errors the request; it just means your display strings render in Asia/Riyadh.

UTC on the wire

Every machine-readable timestamp the API returns is UTC ISO-8601 with a Z suffix (2026-06-21T09:14:03.000Z). This is true on every endpoint and is unaffected by X-Timezone.

  • Parse as UTC, convert in-app for display. Do not assume the device-local zone when parsing; the Z is authoritative.
  • X-Timezone exists so the server can pre-format the copy it generates (notifications, emails). A client that ignores X-Timezone entirely and formats UTC payloads itself is fully correct and unaffected.
  • Send timestamps to the server in UTC too. When a request body carries a time (e.g. a scheduled pickup), send UTC ISO-8601 with Z.

Do not double-convert. If the app sends X-Timezone: Asia/Riyadh, it should not also manually add 3 hours when displaying a createdAt from data. The data field is never shifted by the header; it remains UTC. The header only changes server-generated copy, never JSON timestamps. Convert the UTC value to local time exactly once, in your display layer.

List endpoints and cursors

List endpoints return data.items plus meta.pagination shaped { nextCursor, hasMore, limit }. The same UTC rule applies to every timestamp in each item (e.g. a review's createdAt). Cursor pagination keys off the time-sortable record id, so a client's timezone has no effect on paging:

{
  "data": {
    "items": [
      { "id": "rev_01j9z...", "rating": 5, "createdAt": "2026-06-20T18:02:11.000Z" }
    ]
  },
  "meta": {
    "requestId": "req_01j9z...",
    "pagination": { "nextCursor": "crsr_01j9z...", "hasMore": true, "limit": 20 }
  }
}

Quick reference

HeaderValuesDrivesMissing →
Accept-Languageen | ar (prefix-matched, so en-US → en)Error/notification/email/OTP copy + owner-content localeen
X-TimezoneIANA name, e.g. Asia/RiyadhServer-rendered display strings onlyAsia/Riyadh

Implementation Notes

  • Headers are per request. There is no remembered device language or timezone for token-auth callers — set both as default headers on your HTTP client so they are sent on every call.
  • code is never translated, message is. Branch your UI on error.code; show error.message as-is to the user.
  • user.language ≠ Accept-Language. Saving a profile language does not change response localisation. Keep the header aligned with the user's choice.
  • Offsets and abbreviations are not IANA. +03:00 / AST fail validation and fall back to Asia/Riyadh. Use the OS-provided IANA zone name.
  • Accept-Timezone is legacy. It still works but X-Timezone is the canonical channel — send X-Timezone.
  • Everything on the wire is UTC Z. Convert to local time exactly once, in your display layer.

On this page