Support Tickets
How a signed-in customer opens a support ticket, reads their tickets, and runs the chat-style reply thread with the support team — including why a "create" lands live and why a resolved ticket goes read-only.
This is the customer support surface, rooted at /api/v1/support/tickets. A signed-in user can open a ticket, list their tickets, read a single ticket, and carry on a chat-style reply thread with the support team. Every endpoint sits behind the api token guard — an anonymous call returns 401 AUTH_REQUIRED. Ownership is strict and per-user: you can only see and reply to your own tickets, and touching someone else's returns 403 FORBIDDEN.
Admin triage (agent replies and status changes) happens on a separate /api/v1/admin/support/* surface covered in Admin and the API reference. It drives the state transitions your app must react to, so those transitions are documented in the lifecycle table below.
Auth & headers on every call: Authorization: Bearer <oat_...>. Send Accept-Language: ar for Arabic error copy (persisted as your preferred language on the first authenticated request). Read meta.requestId from each response for support/tracing. All wire timestamps are UTC ISO-8601 with a trailing Z.
Response envelope is always one of:
{ "data": { /* payload */ }, "meta": { "requestId": "req_01..." } }{ "error": { "code": "AUTH_REQUIRED", "message": "..." }, "meta": { "requestId": "req_01..." } }There is no customer-side draft or pending pre-publish step. Resolved and closed tickets are read-only.
POST /api/v1/support/ticketscreates the ticket live immediately withstatus: "open". There is no separate "submit/activate" call. Do not build a draft state.- The reverse is what bites: once a support agent sets the ticket to
resolvedorclosed, any further reply returns409 CONFLICTwith codeSUPPORT_TICKET_CLOSED. The thread cannot be revived from the customer side — the only path forward is to open a brand-new ticket.
The flow at a glance
Step 1 — Authenticate
Obtain a Bearer access token (oat_...) — see Authentication. Every call below requires it.
Step 2 — Open a ticket
POST /api/v1/support/tickets with subject, message, and an optional priority. The server creates it live with status: "open" (waiting on support) and priority defaulting to "normal". Returns 201 with the ticket.
Step 3 — List & read your tickets
GET /api/v1/support/tickets for the list (newest first), GET /api/v1/support/tickets/:id for one ticket. Both are scoped to you.
Step 4 — Load the reply thread
GET /api/v1/support/tickets/:id/messages (oldest first). The opening complaint lives on ticket.message, not in this thread — render the ticket body first, then the messages.
Step 5 — Reply (and react to agent replies)
POST /api/v1/support/tickets/:id/messages with { body }. A user reply on a pending ticket flips it back to open. When an agent replies on the admin surface, you receive an SSE support_message notification — refresh the thread instead of polling.
Step 6 — Handle resolution
When an agent sets the ticket to resolved or closed, further replies return 409 SUPPORT_TICKET_CLOSED. Detect this and prompt the user to open a new ticket — do not retry.
Per-step detail
GET /api/v1/support/tickets — list your tickets
Returns your tickets newest-first, scoped to the caller. 401 AUTH_REQUIRED if unauthenticated.
GET /api/v1/support/tickets HTTP/1.1
Authorization: Bearer oat_abc123
Accept-Language: en{
"data": {
"items": [
{
"id": "tkt_01jq8z4c0e3p5q7r9s2t4w6x8z",
"userId": "usr_01...",
"subject": "Refund request — order TM-20260518-0019",
"message": "I was charged twice. The second charge needs to be refunded.",
"status": "open",
"priority": "high",
"assignedAdminId": null,
"resolvedAt": null,
"closedAt": null,
"createdAt": "2026-06-21T09:00:00.000Z",
"updatedAt": "2026-06-21T09:00:00.000Z"
}
]
},
"meta": { "requestId": "req_01..." }
}POST /api/v1/support/tickets — open a new ticket
Body: subject (2–200 chars, required), message (2–5000 chars, required), priority (optional, one of low / normal / high). priority defaults to "normal" server-side. Returns 201 with the created ticket at status: "open". 422 VALIDATION_ERROR on bad input, 401 if unauthenticated.
POST /api/v1/support/tickets HTTP/1.1
Authorization: Bearer oat_abc123
Content-Type: application/json
{
"subject": "Refund request — order TM-20260518-0019",
"message": "I was charged twice. The second charge needs to be refunded.",
"priority": "high"
}{
"data": {
"ticket": {
"id": "tkt_01jq8z4c0e3p5q7r9s2t4w6x8z",
"userId": "usr_01...",
"subject": "Refund request — order TM-20260518-0019",
"message": "I was charged twice. The second charge needs to be refunded.",
"status": "open",
"priority": "high",
"assignedAdminId": null,
"resolvedAt": null,
"closedAt": null,
"createdAt": "2026-06-21T09:00:00.000Z",
"updatedAt": "2026-06-21T09:00:00.000Z"
}
},
"meta": { "requestId": "req_01..." }
}The ticket is actionable the instant this 201 returns — status is "open", never "new". There is nothing else to call to "publish" it. (If you see "new", "in_progress", or "assigned" in any older sample, ignore them — the live customer-facing set is exactly open | pending | resolved | closed.)
GET /api/v1/support/tickets/:id — read one ticket
Ownership is enforced (ticket.userId === user.id). Returns the same ticket shape as above. 403 FORBIDDEN if the ticket belongs to another user, 404 NOT_FOUND if the id does not exist, 401 if unauthenticated.
GET /api/v1/support/tickets/tkt_01jq8z4c0e3p5q7r9s2t4w6x8z HTTP/1.1
Authorization: Bearer oat_abc123GET /api/v1/support/tickets/:id/messages — the reply thread
Same ownership gate as show. Returns the reply thread oldest-first. Each message is { id, ticketId, authorId, authorType, body, createdAt }, where authorType is "user" or "admin". 403 / 404 / 401 as for show.
GET /api/v1/support/tickets/tkt_01jq8z4c0e3p5q7r9s2t4w6x8z/messages HTTP/1.1
Authorization: Bearer oat_abc123{
"data": {
"items": [
{
"id": "smg_01...",
"ticketId": "tkt_01jq8z4c0e3p5q7r9s2t4w6x8z",
"authorId": "adm_01...",
"authorType": "admin",
"body": "We've issued the refund — it should land in 3–5 business days.",
"createdAt": "2026-06-21T09:30:00.000Z"
}
]
},
"meta": { "requestId": "req_01..." }
}The opening complaint text is ticket.message (returned on the ticket object), not the first row of this thread. The thread holds replies only. To show the full conversation, render ticket.message (as the customer's first message) followed by the /messages items.
POST /api/v1/support/tickets/:id/messages — reply
Body: body (1–5000 chars, required). Appends a message with authorType: "user". Returns 201 with the new message.
- If the ticket was
pending(waiting on you), this reply flips it back toopen(waiting on support) — a side effect, there is no status endpoint on the customer side. - If the ticket is already
resolvedorclosed, you get409 CONFLICTwith codeSUPPORT_TICKET_CLOSED— open a new ticket instead. 403if not owner,404if missing,422on validation,401if unauthenticated.
POST /api/v1/support/tickets/tkt_01jq8z4c0e3p5q7r9s2t4w6x8z/messages HTTP/1.1
Authorization: Bearer oat_abc123
Content-Type: application/json
{ "body": "Any update on the refund?" }{
"data": {
"message": {
"id": "smg_02...",
"ticketId": "tkt_01jq8z4c0e3p5q7r9s2t4w6x8z",
"authorId": "usr_01...",
"authorType": "user",
"body": "Any update on the refund?",
"createdAt": "2026-06-21T10:00:00.000Z"
}
},
"meta": { "requestId": "req_01..." }
}The 409 when the ticket is already resolved or closed:
{
"error": {
"code": "SUPPORT_TICKET_CLOSED",
"message": "This ticket is closed. Open a new ticket to continue."
},
"meta": { "requestId": "req_01..." }
}Live updates (SSE)
When a support agent replies on the admin surface, the server pushes an SSE notification to the ticket owner so the chat UI updates without polling:
type: "support_message",category: "support".titleis the ticket subject;bodyis the agent's reply truncated to 140 chars.data: { ticketId, messageId }.
On receiving it, call GET /api/v1/support/tickets/:id/messages to refresh the thread (and re-read the ticket if you need the updated status). Do not poll. The support_message event arrives on your own SSE channel users/<yourId>/notifications — see Chat & Realtime (SSE) for how to subscribe to that stream.
Lifecycle
Status semantics are inverted from how they sound — label your UI by who is waiting, not by the raw enum word:
open= waiting on support to respond.pending= waiting on the customer to respond.
State table
| State | Meaning | How you got here | What's allowed next |
|---|---|---|---|
open | Waiting on support | Ticket created (POST /support/tickets), or a customer reply on a pending ticket | Customer can reply; support can reply (→ pending), resolve, or close |
pending | Waiting on the customer | A support agent replied to an open ticket (admin surface) | Customer reply flips it back to open; support can resolve or close |
resolved | Marked done by support; resolvedAt stamped | Agent set status resolved (admin surface) | Read-only for the customer — replies return 409 SUPPORT_TICKET_CLOSED. Support can reopen or close |
closed | Finalized by support; closedAt stamped | Agent set status closed (admin surface) | Read-only for the customer — replies return 409 SUPPORT_TICKET_CLOSED. Support can reopen |
Transitions
- (none) →
openviaPOST /api/v1/support/tickets(customer; creation always lands onopen). open→pendingvia an admin reply onPOST /api/v1/admin/support/tickets/:id/reply(support; out of mobile scope — react to the resultingsupport_messageSSE).pending→openviaPOST /api/v1/support/tickets/:id/messages(customer; a reply auto-reopens — there is no direct status endpoint for customers).open/pending→resolvedviaPOST /api/v1/admin/support/tickets/:id/status { "status": "resolved" }(support; stampsresolvedAt).open/pending/resolved→closedviaPOST /api/v1/admin/support/tickets/:id/status { "status": "closed" }(support; stampsclosedAt).resolved/closed→open/pendingviaPOST /api/v1/admin/support/tickets/:id/status(support; reopen clearsresolvedAtandclosedAt).
The only transition a customer can trigger directly is (none) → open (create) and pending → open (reply). Everything else is admin-driven; the customer app observes it via the ticket's status and the support_message SSE.
Implementation Notes
| Integration issue | Correct handling |
|---|---|
| Building a draft/submit step for new tickets | POST /support/tickets creates the ticket live at status: "open". There is no "publish" call — treat the 201 as fully done. |
Retrying a reply that returned 409 | A 409 SUPPORT_TICKET_CLOSED means the ticket is resolved or closed and cannot be revived. Prompt the user to open a new ticket, do not retry the same one. |
Rendering status: "new" / "in_progress" / "assigned" | Those are non-canonical legacy doc artefacts. The live set is exactly `open |
| Labeling the UI by the raw enum word | open = waiting on support; pending = waiting on the customer. The words are inverted — label by who-is-waiting. |
| Looking for a customer "set status" endpoint | No customer endpoint exists for direct status changes. The customer influences state only by replying (pending → open). resolved / closed / reopen are admin-only. |
Treating /:id/messages as the whole conversation | The opening complaint is ticket.message on the ticket object — it is not a row in the thread. Render the ticket body + the thread together. |
Sending priority: "medium" | Allowed values are low / normal / high. The default is "normal" (not "medium", despite an older sample). |
Expecting assignedAdminId to be set on create | It is null until an agent engages with the ticket. |
| Polling for agent replies | Listen for the support_message SSE (category: "support", data: { ticketId, messageId }) and refresh the thread on receipt. |
| Reading/replying on another user's ticket | Ownership is strict and silent: 403 FORBIDDEN for someone else's ticket, 404 NOT_FOUND for an unknown id. There is no shared/public view. |
Hitting 422 on create/reply | Enforce client-side: subject 2–200 chars, message 2–5000 chars on create; reply body 1–5000 chars. |
| Calling any endpoint without a token | The whole group is behind the api guard. A missing/expired oat_ token returns { error: { code: "AUTH_REQUIRED" } }. |
Related
- Authentication — how to obtain the
oat_access token used here. - Chat & Realtime (SSE) — subscribe to the
support_messageSSE that signals an agent reply. - Profile & Preferences — the rest of the authenticated customer self-service surface.
- API reference — full endpoint and schema catalogue.
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.
Reporting Content
Mobile review/community-post reporting, permanent duplicate handling, content snapshots, and the admin moderation actions.