TrackMe API Docs
Flow guides

Community Posts

How to publish short photo posts to the community feed, then read, like, reply to, and delete them — with the two-step photo upload and the cursor rules the feed and replies use.

Community is a lightweight social feed of short user-authored posts (up to 2000 characters) with up to four optional photos, plus likes and threaded-flat replies. Reading is public — the feed and a single post are anonymous-allowed. Authoring requires a Bearer token — creating posts, liking/unliking, replying, and deleting all need Authorization: Bearer <oat_...> (the api guard).

All JSON lives under /api/v1. Successful responses use the standard envelope { "data": ..., "meta": { "requestId": "req_..." } }; list responses add meta.pagination. Errors use { "error": { "code", "message" }, "meta": ... }.

Audience: customer and owner mobile application engineers. This guide leads with the end-to-end sequence, then per-step detail, lifecycle states, and implementation notes.

There is no draft, pending, or moderation step. POST /api/v1/community/posts creates the post at status: published and it is live in the public feed the instant the 201 returns. There is no separate "publish" or "activate" call — the create operation publishes the post. Do not build a "save then publish" flow.

The flow at a glance

Step 1 — (Only if posting photos) Upload images and collect fileIds

For each photo, call POST /api/v1/uploads with purpose=community_image and keep the returned fileId. Maximum 4 photos. You cannot send raw image bytes to the create endpoint — it only accepts fileIds. Skip this step entirely for a text-only post.

Step 2 — Publish the post

POST /api/v1/community/posts with { body, fileIds? } and a Bearer token. The 201 carries the fully serialized, already-live post (status: published, likesCount: 0, repliesCount: 0, likedByMe: false, resolved owner, and images[]). It is immediately visible in the feed.

Step 3 — Read the feed (or a single post)

GET /api/v1/community/posts returns published posts newest-first, cursor-paginated. ?ownerId= scopes to one author. GET /api/v1/community/posts/:id returns one post. Both are anonymous-allowed; a valid Bearer token makes likedByMe reflect the caller's own like state.

Step 4 — Engage: like, unlike, reply

POST/DELETE /api/v1/community/posts/:id/like toggle the like (both idempotent) and return the fresh { likesCount, likedByMe }. POST /api/v1/community/posts/:id/replies adds a flat reply and bumps repliesCount. GET /api/v1/community/posts/:id/replies lists replies oldest-first.

Step 5 — Delete (author or admin)

DELETE /api/v1/community/posts/:id soft-deletes the post (author or an active admin only), detaches its photos, and audit-logs it. The post and its detail/replies then return 404.

Per-step detail

Step 1 — Mint photo fileIds

Photos go through the standard two-step upload pipeline. Upload each image with purpose=community_image, collect the fileId values, then pass them to the create call. The purpose is capped at 4 — passing more than 4 fileIds to create is a 422.

POST /api/v1/uploads HTTP/1.1
Authorization: Bearer oat_xxx
Content-Type: application/json

{ "purpose": "community_image", "...": "see the uploads guide for the full handshake" }

Step 2 — Publish a community post

Body: { content: string (1–2000 chars), country: string, city?: string | null, channel?: "discussion" | "news", mediaUrls?: string[], replyToId?: string | null }. body remains an alias of content, and uploaded fileIds remain supported (max 4). Country and city must be active catalog entries. Omitting city selects the nationwide room. Channel defaults to discussion; only admins can publish or reply in news. HTTPS media URLs are limited to four. A replyToId must belong to the same country, city and channel. Returns 201 with post fields in data and the legacy data.post alias, or data.reply when replying.

POST /api/v1/community/posts HTTP/1.1
Authorization: Bearer oat_xxx
Content-Type: application/json

{
  "body": "Pop-up tonight on Tahlia — first 20 burgers half-price. See you there!",
  "country": "SA",
  "city": "Riyadh",
  "fileIds": ["fil_01jq8zu1a3c5e7g9j1l3n5p7q9"]
}
{
  "data": {
    "post": {
      "id": "cpost_01jq9a...",
      "ownerId": "usr_me...",
      "body": "Pop-up tonight on Tahlia — first 20 burgers half-price. See you there!",
      "conversationId": null,
      "status": "published",
      "likesCount": 0,
      "repliesCount": 0,
      "createdAt": "2026-06-21T18:02:00.000Z",
      "updatedAt": "2026-06-21T18:02:00.000Z",
      "owner": {
        "id": "usr_me...",
        "fullName": "Khaled",
        "avatar": { "thumb": "https://.../thumb.jpg" },
        "truckName": "Smash Wagon"
      },
      "likedByMe": false,
      "images": [
        {
          "id": "fil_01jq8zu...",
          "purpose": "community_image",
          "urls": {
            "original": "https://.../original.jpg",
            "thumb": "https://.../thumb.jpg",
            "medium": "https://.../medium.jpg",
            "large": "https://.../large.jpg"
          }
        }
      ]
    }
  },
  "meta": { "requestId": "req_abc" }
}

conversationId is in the response schema but is always null from these endpoints — nothing in the community module ever sets it. Treat it as a nullable, currently-unused field; never depend on it being populated.

Step 3 — Read the feed and a single post

Feed — GET /api/v1/community/posts?country=SA&city=Riyadh&channel=discussion. Country is required; omitted/empty city returns only nationwide posts, and omitted channel means discussion. Other params: ownerId, cursor, and integer limit (1–50, default 30). Returns published, non-deleted posts newest-first (createdAt desc, then id desc). Pagination is in both data.pagination and meta.pagination. Each item exposes userId, userName, userAvatar, userType, content, reactions, replyCount, mediaUrls, likedByMe, and legacy owner/body/count/image fields. Invalid catalog locations or cursors return 422.

GET /api/v1/community/posts?country=SA&city=Riyadh&limit=20 HTTP/1.1
Accept-Language: en
{
  "data": {
    "items": [
      {
        "id": "cpost_01jq9a...",
        "ownerId": "usr_me...",
        "body": "Pop-up tonight on Tahlia...",
        "conversationId": null,
        "status": "published",
        "likesCount": 3,
        "repliesCount": 1,
        "createdAt": "2026-06-21T18:02:00.000Z",
        "updatedAt": "2026-06-21T18:02:00.000Z",
        "owner": { "id": "usr_me...", "fullName": "Khaled", "avatar": null, "truckName": "Smash Wagon" },
        "likedByMe": false,
        "images": []
      }
    ]
  },
  "meta": { "requestId": "req_abc", "pagination": { "nextCursor": "eyJjcmVhdGVkQXQ...", "hasMore": true, "limit": 20 } }
}

Each images[] entry is the standard file reference — { id, purpose, urls }, where urls always has original and adds thumb / medium / large when those variants exist. The item key is id, not fileId; the fileId you minted at upload time becomes this id once attached.

Keep paging while meta.pagination.hasMore is true (equivalently, until nextCursor is null). The feed is newest-first; replies are oldest-first — never reuse a feed cursor on the replies endpoint or vice versa.

Single post — GET /api/v1/community/posts/:id returns { data: { post } } (same shape as a feed item). It resolves only published, non-soft-deleted posts. A 404 NOT_FOUND here means the post never existed or was soft-deleted — drop it from local state rather than retrying.

{ "data": { "post": { "id": "cpost_01jq9a...", "status": "published", "likedByMe": true } }, "meta": { "requestId": "req_abc" } }

likedByMe is identity-scoped. On the public feed/detail it is false for anonymous callers and only reflects the real like state when a valid Bearer token is sent. Never cache likedByMe across users.

Step 4 — Like, unlike, reply

Like — POST /api/v1/community/posts/:id/like. Idempotent: liking an already-liked post is a no-op (no duplicate row, no double-increment). Returns the fresh count.

POST /api/v1/community/posts/cpost_01jq9a.../like HTTP/1.1
Authorization: Bearer oat_xxx
{ "data": { "likesCount": 4, "likedByMe": true }, "meta": { "requestId": "req_abc" } }

Unlike — DELETE /api/v1/community/posts/:id/like. Idempotent: unliking a not-liked post is a no-op; likesCount is floored at 0.

{ "data": { "likesCount": 3, "likedByMe": false }, "meta": { "requestId": "req_abc" } }

Both return 404 if the post is not published/does not exist, 401 if unauthenticated. Trust the like/unlike response payload for the fresh { likesCount, likedByMe } — do not re-fetch the post to discover the new state, and do not optimistically guess the count.

Reply — POST /api/v1/community/posts/:id/replies. Body: { body: string (trimmed, 1–2000 chars, required) }. Increments the parent's repliesCount and returns the reply with a resolved owner. Replies are flat (no nesting) and have no like or delete endpoint in this module. 404 if the parent is not published/does not exist; 422 on validation; 401 if unauthenticated.

POST /api/v1/community/posts/cpost_01jq9a.../replies HTTP/1.1
Authorization: Bearer oat_xxx
Content-Type: application/json

{ "body": "What time does the pop-up start?" }
{
  "data": {
    "reply": {
      "id": "creply_01jq9b...",
      "postId": "cpost_01jq9a...",
      "ownerId": "usr_other...",
      "owner": { "id": "usr_other...", "fullName": "Sara", "avatar": null, "truckName": null },
      "body": "What time does the pop-up start?",
      "createdAt": "2026-06-21T18:10:00.000Z"
    }
  },
  "meta": { "requestId": "req_abc" }
}

List replies — GET /api/v1/community/posts/:id/replies. Anonymous-allowed. Query params: ?limit= (1–50, default 20), ?cursor=. Cursor-paginated OLDEST-first (ascending), keyed by id only — ids are ULIDs, so id order is chronological. 404 if the parent is not published/does not exist.

GET /api/v1/community/posts/cpost_01jq9a.../replies?limit=20 HTTP/1.1
{
  "data": { "items": [ /* replies, oldest first */ ] },
  "meta": { "requestId": "req_abc", "pagination": { "nextCursor": "eyJpZCI...", "hasMore": true, "limit": 20 } }
}

Step 5 — Delete a post (author or admin)

DELETE /api/v1/community/posts/:id. The caller must be the post author OR hold an active admin membership. This is a soft-delete only — it sets status: soft_deleted + deletedAt, detaches all attached photos, and writes an audit record (community_post.delete). There is no hard delete and no restore endpoint in this module.

DELETE /api/v1/community/posts/cpost_01jq9a... HTTP/1.1
Authorization: Bearer oat_xxx
{ "data": { "success": true }, "meta": { "requestId": "req_abc" } }
  • 403 FORBIDDEN — a non-author without admin rights. This is not a 404; the post exists, you just cannot delete it.
  • 404 NOT_FOUND — the post is missing or already soft-deleted.
  • 401 AUTH_REQUIRED — unauthenticated.

Once deleted, the post returns 404 on detail, replies, like, and unlike. There is no reply-delete or reply-like endpoint; post/reply moderation is handled through the admin Reports queue, not via any /community route.

Lifecycle

A post has exactly two states. There is no draft, pending, or hidden state — published is the only state a post is ever created in.

State table

StateMeaningHow you got hereWhat's allowed next
publishedLive in the public feed; visible to everyonePOST /api/v1/community/posts — created here directly, no intermediateRead, like/unlike, reply, list replies, delete (author/admin)
soft_deletedHidden from every read endpoint; photos detached, audit-loggedDELETE /api/v1/community/posts/:id (author or active admin)Nothing — returns 404 everywhere; no restore endpoint

Transitions

  • (none) → published via POST /api/v1/community/posts. Actor: any authenticated user. Created directly as published — no draft/pending intermediate, live the instant the 201 returns.
  • published → soft_deleted via DELETE /api/v1/community/posts/:id. Actor: the post author OR an active admin. Sets status: soft_deleted + deletedAt, detaches photos, audit-logged. Irreversible from mobile.

Implementation Notes

Integration issueCorrect handling
Building a "save draft, then publish" flow.There is no draft step. POST /community/posts creates the post as published and it is live the instant the 201 returns. The create IS the publish.
Posting raw image bytes to the create endpoint.Photos require the two-step pipeline first: mint fileIds via POST /api/v1/uploads (purpose=community_image, max 4), then pass them in fileIds[]. More than 4 is a 422.
Sending a photo-only post with no text.body is required (1–2000 chars). Every post needs body text; fileIds is the optional part.
Treating a 404 on a post as a transient error.Read endpoints only return published, non-deleted posts. A 404 on detail/replies/like/unlike means it is gone — drop it from local state, do not retry.
Caching likedByMe across users (or trusting it for anon callers).likedByMe is identity-scoped: false for anonymous callers, real only with a valid Bearer token. Recompute per identity.
Re-fetching the post to learn the new like count.Like/unlike return the fresh { likesCount, likedByMe } in their own response — trust that payload. Both are idempotent; likesCount is floored at 0.
Reusing a feed cursor on the replies endpoint (or vice versa).The feed is newest-first (createdAt+id keyset); replies are oldest-first (id-only ULID keyset). Use each list's own meta.pagination.nextCursor.
Reading the image id off image.fileId.In the response, each images[] entry is a file reference keyed by id (plus purpose and urls). The fileId name only exists in the request you send to create.
Ignoring meta.pagination.hasMore.Every list response returns { nextCursor, hasMore, limit }. Page while hasMore is true; nextCursor is null on the last page.
Expecting 403 to mean a bad id on delete.A non-author non-admin gets 403 FORBIDDEN — the post exists, you just cannot delete it. 404 means missing/already soft-deleted.
Looking for an edit, reply-delete, or reply-like endpoint.None exist in this module. There is no PATCH/PUT, replies are flat (no threading) with no like/delete. Moderation is via the admin Reports queue.
Expecting a restore / un-delete.Delete is soft-delete only; there is no restore endpoint exposed to mobile.
Depending on conversationId.It is in the schema but always null here — nothing in the community module sets it. Treat it as nullable and unused.
Expecting localized wire timestamps.Send Accept-Language: ar for Arabic error copy. Wire timestamps (createdAt, updatedAt) are always UTC ISO-8601 with Z regardless of X-Timezone.

On this page