TrackMe API Docs
Flow guides

Discovery & Search

How the customer app finds food trucks — geo discovery, federated and menu-item search, the cuisine taxonomy, per-truck reads, favoriting, reviews, and the short location-share link.

This is how the customer mobile app finds trucks and their content. Almost every endpoint here is public (anonymous-allowed) — no token required — so a brand-new app session can browse, search, and open a truck before the user ever signs in. Only favoriting and creating a review need a Bearer token.

The domain spans four discovery surfaces plus per-truck reads:

  1. Truck discovery — GET /api/v1/trucks/search (geo + text + filters + sort, cursor-paginated).
  2. Federated quick-jump — GET /api/v1/search?q= (trucks + menu items + jobs + listings, 5 each, no pagination).
  3. Menu-item search — GET /api/v1/menu/items/search?q= (one dish across all trucks).
  4. Taxonomy — GET /api/v1/categories (cuisine + truck-class chips).
  5. Per-truck reads — detail (/trucks/:id), menu (/trucks/:truckId/menu), reviews (/trucks/:truckId/reviews).
  6. Engage (auth) — favorite / unfavorite, list favorites, create a review.
  7. Share link — GET /t/:token, outside /api/v1, no auth.

Auth & headers. Authenticated calls send Authorization: Bearer <oat_...>. Send Accept-Language: ar for Arabic copy (localised text falls back to the other locale per-field when blank). Most localised objects carry a langActual of "en" or "ar" — but the trimmed-down federated-search hits (GET /api/v1/search) do not include langActual. Wire timestamps are always UTC ISO-8601 with a trailing Z. Read meta.requestId from every response for support/tracing.

Response envelope is always one of:

{
  "data": {
    /* payload */
  },
  "meta": { "requestId": "req_01..." }
}
{ "error": { "code": "NOT_FOUND", "message": "..." }, "meta": { "requestId": "req_01..." } }

A truck is only discoverable when status = active AND it is not soft-deleted — on EVERY public surface. A draft, suspended, or soft_deleted truck is invisible: it silently drops out of search and returns 404 on detail, menu, reviews, favorite, and the share resolver. There is no separate "suspended" response.

Practical consequence: a truck the user bookmarked or favorited can start returning 404 because an admin suspended it or the owner deleted it. Handle 404 on a previously-known truck gracefully — drop it from the list, do not crash.

For the inverse case, a newly owner-created truck is active and discoverable the instant create returns 201 — there is no draft step to publish. See Truck Lifecycle and Implementation notes.

The flow at a glance

Step 1 — Load the taxonomy for filter chips

GET /api/v1/categories (optionally ?type=cuisine or ?type=truck). Only active categories come back. Cache these to render filter chips.

Step 2 — Discover trucks

GET /api/v1/trucks/search — pass the device lat/lng to annotate every result with distanceKm and sort nearest-first. This does not filter distant trucks; add radiusKm only when you explicitly want a radius filter. Combine with q, openNow, categoryId, city, or sort. You get active, non-deleted truck summaries.

Step 3 — Page through results

Read meta.pagination.nextCursor and pass it back as ?cursor=. Stop when meta.pagination.hasMore is false. Do not use page numbers.

For an omnibox use GET /api/v1/search?q= (5 hits each across trucks/menu items/jobs/listings, no pagination). To find a specific dish use GET /api/v1/menu/items/search?q= (paged by limit, with estimatedTotal). Both require a non-empty q (422 otherwise).

Step 5 — Open a truck

GET /api/v1/trucks/:id returns the truck plus a viewer block. Send the Bearer token to populate viewer.isFavorite, viewer.canOrder, viewer.canReview, and viewer.reviewableOrderId; anonymous callers get them all false/null.

Step 6 — Read menu + reviews

GET /api/v1/trucks/:truckId/menu (categories + items) and GET /api/v1/trucks/:truckId/reviews (visible only, newest-first).

Step 7 — Engage (authenticated)

POST / DELETE /api/v1/trucks/:id/favorite, list saved trucks with GET /api/v1/me/favorite-trucks, and after a completed order POST /api/v1/trucks/:truckId/reviews (one review per order — use viewer.reviewableOrderId).

Per-step detail

Taxonomy — GET /api/v1/categories

GET /api/v1/categories?type=cuisine HTTP/1.1
Accept-Language: en

?type=truck returns truck-class taxonomy, ?type=cuisine returns cuisine tags, omit type for both. A bad type is 422 VALIDATION_ERROR. Inactive / soft-deleted categories never appear (only the admin list shows those).

Truck discovery — GET /api/v1/trucks/search

GET /api/v1/trucks/search?lat=24.7136&lng=46.6753&radiusKm=5&q=burger&openNow=true&sort=rating&limit=20 HTTP/1.1
Accept-Language: en
ParamBoundsNotes
q≤ 200Optional — browse by geo/filters alone if omitted.
lat / lngvalid coordsSupply together. Adds distanceKm and defaults to nearest-first. Does not filter.
radiusKm0.1–100, optionalThe only parameter that filters by distance. Omit it to keep far trucks.
openNowbooltrue evaluates the stored weekly openingHours in X-Timezone (default Asia/Riyadh). Trucks without a schedule fall back to their live isOpen value.
categoryId≤ 30Filter by a category id from Step 1.
city≤ 80City-name filter.
sortdistance | rating | featured | newestdistance is the geo default. Legacy aliases popularity and recent are still accepted.
cursor≤ 500From meta.pagination.nextCursor.
limit1–50
{
  "data": {
    "items": [
      {
        "id": "trk_01jq8z9a0b1c2d3e4f5g6h7j8k",
        "name": "Crispy Cart",
        "langActual": "en",
        "isOpen": true,
        "isFeatured": true,
        "ratingAverage": 4.7,
        "reviewsCount": 128,
        "distanceKm": 1.3,
        "city": "Riyadh"
      }
    ]
  },
  "meta": {
    "requestId": "req_01...",
    "pagination": { "nextCursor": "eyJpZCI6...", "hasMore": true, "limit": 20 }
  }
}

The list payload is wrapped in data.items (an object), not a bare data array. Favorites and reviews use the same data.items envelope.

  • With geo and no explicit sort, results are ordered by stable (distanceKm, id) order. The cursor preserves that order across pages.
  • sort=rating uses rating then review count; featured uses featured first then distance/rating; newest uses publication time.
  • distanceKm is present only when lat/lng were supplied.
  • Without geo and without sort, ordering defaults to newest publication first.
  • Bad params → 422 VALIDATION_ERROR.

Federated search — GET /api/v1/search

A quick-jump omnibox. One round-trip, each section capped at 5 hits, no pagination. All four arrays are always present (possibly empty).

GET /api/v1/search?q=burger HTTP/1.1
Accept-Language: en
{
  "data": {
    "trucks": [
      /* ≤5 truck hits */
    ],
    "menuItems": [
      /* ≤5 menu-item hits */
    ],
    "jobs": [
      /* ≤5 job hits */
    ],
    "listings": [
      /* ≤5 marketplace listing hits */
    ]
  },
  "meta": { "requestId": "req_01..." }
}

q is required (1–200 chars); empty / whitespace → 422. For a full browse list, use truck discovery or menu-item search instead — this endpoint is not a browse list.

Finds a dish across all active trucks (Meilisearch). Each hit carries its truckId + truckName so you can deep-link.

GET /api/v1/menu/items/search?q=shawarma&limit=20 HTTP/1.1
Accept-Language: en
{
  "data": {
    "items": [
      {
        "id": "itm_01jq8z5e0f1g2h3j4k5l6m7n8p",
        "truckId": "trk_01jq8z9a0b1c2d3e4f5g6h7j8k",
        "truckName": "Crispy Cart",
        "name": "Shawarma Plate",
        "description": "Chicken shawarma, garlic sauce, pickles.",
        "priceMinor": 2800,
        "isAvailable": true,
        "langActual": "en"
      }
    ],
    "estimatedTotal": 42
  },
  "meta": { "requestId": "req_01..." }
}

q required (1–200), optional truckId scopes to one truck, limit 1–50. Empty/oversized q → 422.

Truck detail + viewer flags — GET /api/v1/trucks/:id

GET /api/v1/trucks/trk_01jq8z9a0b1c2d3e4f5g6h7j8k HTTP/1.1
Authorization: Bearer oat_...
Accept-Language: en
{
  "data": {
    "truck": {
      "id": "trk_01jq8z9a0b1c2d3e4f5g6h7j8k",
      "ownerId": "usr_01jq8z4b2k6h7n8m9p0r3s5t7v",
      "name": "Crispy Cart",
      "status": "active",
      "isOpen": true,
      "isFeatured": true,
      "ratingAverage": 4.7,
      "reviewsCount": 218,
      "openingHours": [{ "day": 0, "opensAt": "09:00", "closesAt": "21:00", "isClosed": false }],
      "contactPhone": "+966555012345",
      "contactWhatsapp": "+966555012345",
      "whatsappNumber": "+966555012345",
      "contactPreferences": ["whatsapp", "phone"],
      "langActual": "en"
    },
    "viewer": {
      "isFavorite": true,
      "canOrder": true,
      "canReview": true,
      "reviewableOrderId": "ord_01jq8z3a0n0y9v0x1g4t2c7m6e"
    }
  },
  "meta": { "requestId": "req_01..." }
}
  • Only active + non-deleted trucks resolve; otherwise 404 NOT_FOUND.
  • viewer flags are all false/null for anonymous callers.
  • viewer.canOrder just means "the caller is authenticated."
  • viewer.canReview is true only when the caller has a completed order with this truck and has not reviewed it yet — then reviewableOrderId is the orderId to pass to the review create. Do not let the user free-pick an order.
{
  "data": {
    "categories": [{ "id": "mct_...", "name": "Burgers", "sortOrder": 1 }],
    "items": [
      {
        "id": "itm_...",
        "categoryId": "mct_...",
        "name": "Smash Double",
        "priceMinor": 3500,
        "currencyCode": "SAR",
        "isAvailable": true,
        "isPopular": true,
        "image": {
          "id": "fil_...",
          "purpose": "menu_item",
          "urls": { "original": "https://.../signed.jpg" }
        },
        "additions": [
          {
            "id": "mia_...",
            "name": "Cheese",
            "priceMinor": 300,
            "isAvailable": true,
            "sortOrder": 0
          }
        ]
      }
    ]
  },
  "meta": { "requestId": "req_01..." }
}

Only active trucks; 404 otherwise. Admin-hidden items (their deleted_at is set) are excluded. image is a FileRef object ({ id, purpose, urls }) or null when the item has no photo — never a bare URL string. Prices are integer minor units — divide by the currency's exponent (100 for SAR) for display.

Reviews — GET /api/v1/trucks/:truckId/reviews

GET /api/v1/trucks/trk_01.../reviews?limit=20 HTTP/1.1

Published reviews only, newest-first. limit 1–50 (default 20); bad limit → 422; non-discoverable truck → 404. Each row carries the reviewer's user.fullName + avatar URL map (null if the account is gone), rating, comment, and signed image URLs.

Favorite / unfavorite (auth) — POST / DELETE /api/v1/trucks/:id/favorite

Both are idempotent.

POST /api/v1/trucks/trk_01.../favorite HTTP/1.1
Authorization: Bearer oat_...
{ "data": { "isFavorite": true }, "meta": { "requestId": "req_01..." } }

POST returns { isFavorite: true }; DELETE returns { isFavorite: false }. 401 if unauthenticated; POST returns 404 if the truck is not discoverable.

List favorites (auth) — GET /api/v1/me/favorite-trucks

GET /api/v1/me/favorite-trucks?limit=50 HTTP/1.1
Authorization: Bearer oat_...

Truck summaries, newest-favorited first; each carries favoritedAt. limit 1–200 (default 50). 401 unauth, 422 bad limit.

Create a review (auth) — POST /api/v1/trucks/:truckId/reviews

POST /api/v1/trucks/trk_01.../reviews HTTP/1.1
Authorization: Bearer oat_...
Content-Type: application/json

{
  "orderId": "ord_01jq8z3a0n0y9v0x1g4t2c7m6e",
  "rating": 5,
  "comment": "Best smash burger in Riyadh.",
  "fileIds": ["fil_01jq8zf1a3c5e7g9j1l3n5p7q9"]
}

One review per completed order — pass viewer.reviewableOrderId from the detail call. The image field is fileIds (max 3), not imageFileIds — each id must come from a prior POST /api/v1/uploads with purpose=review_image. comment is optional (max 2000 chars).

StatusMeaning
201Review created (drives ratingAverage / reviewsCount).
409 CONFLICTA review already exists for that orderId.
403 FORBIDDENThat order is not the caller's completed order on this truck.
422 VALIDATION_ERRORBad rating (must be 1–5) or body.

A short, no-auth link an owner generates for the truck's current location — shared via SMS/WhatsApp. It lives outside /api/v1 so the URL stays short (APP_URL/t/<token>).

GET /t/aB3xY9 HTTP/1.1
{
  "data": {
    "truckId": "trk_01jq8z9a0b1c2d3e4f5g6h7j8k",
    "name": "Crispy Cart",
    "isOpen": true,
    "isFeatured": true,
    "ratingAverage": 4.7,
    "location": {
      "lat": 24.7136,
      "lng": 46.6753,
      "address": "King Fahd Road, near Kingdom Centre",
      "nearbyLandmark": "Kingdom Centre",
      "lastUpdatedAt": "2026-06-21T09:30:00.000Z"
    }
  },
  "meta": { "requestId": "req_01..." }
}

It uses the standard envelope but its data shape is its own (a truckId + location block, not the full truck-detail shape) — do not reuse the truck-detail parser on it. 404 if the token is unknown or the truck is not active / is soft-deleted.

Truck Lifecycle

Discovery only ever shows active + non-deleted trucks. isOpen is a separate, operational flag layered on top of status. The owner/admin transitions below are documented in full elsewhere — they are here so you understand when a truck appears in or vanishes from discovery.

State table

StateMeaningHow you got hereWhat's allowed next
draftNot discoverable. Rare — normal owner create never lands here.Edge/admin flows onlyOwner/admin publish → active
activeDiscoverable on all public surfaces.Owner create (instant), publish, or restoreSuspend (admin), soft-delete, feature, open/close
suspendedHidden from public (404 / dropped from search); owner can still see + edit.Admin suspendAdmin restore → active
soft_deletedHidden everywhere.Owner delete, or admin deleteOwner restore (own delete only) or admin/support restore
isOpen = trueCurrently serving. Independent of status.Owner sets isOpen true + currentLat/LngManual close, or auto-close on GPS drift
isOpen = falseNot serving. Still discoverable if active.Owner default / manual close / drift auto-closeOwner re-open (needs current GPS)
menu item hiddenVanishes from public menu and the owner's own list.Admin moderation sets deleted_atAdmin restore (owner cannot self-reverse)
review visibleShows on the public list.Customer create + no moderation removalAdmin soft-delete or image removal

Transitions

  • (none) → active — POST /api/v1/owner/trucks (create stamps status=active + publishedAt in the same transaction; no draft step). (owner)
  • draft → active — POST /api/v1/owner/trucks/:id/publish or admin publish. (owner / admin — edge case only)
  • active → suspended — POST /api/v1/admin/food-trucks/:id/suspend. (admin)
  • suspended → active — POST /api/v1/admin/food-trucks/:id/restore. (admin)
  • active → soft_deleted — DELETE /api/v1/owner/trucks/:id or DELETE /api/v1/admin/food-trucks/:id. (owner / admin)
  • soft_deleted → active — POST /api/v1/owner/trucks/:id/restore (owner-deleted only) or admin restore. Owner restore returns 403 TRUCK_RESTORE_FORBIDDEN if the takedown was admin moderation. (owner / admin)
  • isOpen false → true — PATCH /api/v1/owner/trucks/:id with isOpen=true + currentLat/currentLng (anchors drift). (owner)
  • isOpen true → false — POST /api/v1/owner/trucks/:id/heartbeat tripping the drift threshold (auto-close + push) or a manual PATCH. (system / owner)
  • active (unfeatured) → active (featured) — POST /api/v1/owner/trucks/:id/feature → settles only after the Paymob webhook. (owner + gateway)
  • menu item visible → hidden — PATCH /api/v1/admin/menu/items/:id/moderate (status=hidden). (admin)

No draft step on owner create. POST /api/v1/owner/trucks sets status='active' and stamps publishedAt in one transaction, so the truck is discoverable the moment create returns 201. isOpen defaults to false. Do not build a create-then-publish UI. The POST /api/v1/owner/trucks/:id/publish endpoint exists but is effectively unreachable from the normal flow — treat it as defensive (it returns published: false on an already-active truck, 409 if suspended/archived/soft-deleted).

Implementation Notes

Integration issueCorrect handling
Expecting a create-then-publish flow for owner trucks.Owner create is instant: status=active + publishedAt in the same transaction. The truck is live on 201.
Crashing when a bookmarked/favorited truck returns 404.A suspended or soft_deleted truck 404s on detail/menu/reviews and drops from search. Handle 404 gracefully — remove it from the UI.
Conflating "open" with "discoverable".isOpen is independent of status. An active truck can be isOpen=false. Discovery returns both unless you pass openNow=true.
Caching isOpen and never re-reading it.GPS drift auto-closes a truck server-side (default 150m) without owner action and pushes the owner. Re-read isOpen rather than caching.
Reading viewer flags without auth.viewer.isFavorite / canReview / reviewableOrderId are false/null for anonymous calls. Send the Bearer token.
Letting the user pick any order to review.canReview is true only for a completed, not-yet-reviewed order; use reviewableOrderId. A wrong/duplicate order → 403 / 409.
Treating /api/v1/search as a browse list.It caps each section at 5 hits and has no pagination. Use /trucks/search (full list) or /menu/items/search (paged, with estimatedTotal).
Sending an empty q to the search endpoints./api/v1/search and /menu/items/search require q (min length 1) → 422. Only truck discovery's q is optional.
Passing radiusKm or sort=distance without geo.Both require lat/lng. There is no implicit radius: geo alone annotates and orders all matching trucks; only an explicit radiusKm filters.
Treating prices as decimals.Prices are integer priceMinor + a separate currencyCode. Divide by the currency exponent (100 for SAR).
Reusing the truck-detail parser on /t/:token.The share resolver returns its own data shape (truckId + a location block), not the full truck detail.
Assuming POST /feature makes a truck featured immediately.Featuring is a paid flow that only takes effect after the Paymob webhook settles. Request sort=featured when the UI needs promoted trucks first.
Surprised a menu item the owner added disappeared.Admin moderation sets deleted_at, hiding the item from the public menu and the owner's own list — and the owner cannot self-restore.
Parsing data as a bare array on list endpoints.Truck discovery, favorites, and reviews wrap rows in data.items (an object). Read data.items, not data[0].
Sending review images as imageFileIds.The review body field is fileIds (max 3). imageFileIds is silently ignored — no image attaches.
Reading menu image as a URL string.image is a FileRef object ({ id, purpose, urls }) or null. Pull the URL from image.urls.

On this page