FleetbaseFleetbase

Order Chat

Chat between a customer and the driver delivering their order. The chat opens when a driver is assigned and closes, read-only, once the order is completed, canceled or expired. Every request needs the `Customer-Token` header of the customer who placed the order. New messages and read receipts are broadcast in realtime on the SocketCluster channel given by the chat's `channel` (`chat.{chat id}`) as `chat_message.*` and `chat_receipt.*` events. The driver's messages also reach the customer as `order_chat_message` notifications. When the server requires socket authentication, subscribe with a token from `POST customers/socket-token`. Sending a message or marking the chat read returns `403` when the customer isn't part of the chat. Responses: `Send Order Chat Message` returns `{ "message": {…} }`, `List Order Chat Messages` returns `{ "messages": [...] }` and `Mark Order Chat as Read` returns `{ "read": n }`.

The Order Chat object

The chat for an order, with its participants and latest messages (oldest first). Messages are `{ id, content, sender: { id, role, name }, is_mine, attachments: [{ id, url, type }], read, created_at }`.
Attributes
idstringoptional

Public identifier of the chat.

channelstringoptional

SocketCluster channel to subscribe to for live messages.

orderstringoptional

Public identifier of the order.

statusenumoptional

closed once the order is completed, canceled or expired; messages can still be read. One of open, closed.

mestringoptional

The requesting customer's participant ID.

participantsarray of objectsoptional

id, role (customer or driver), name, avatar_url and is_online.

messagesarray of objectsoptional

The latest messages, oldest first.

unread_countintegeroptional

Messages from the driver the customer has not read.

The Order Chat object
{
  "id": "chat_5Nq8vR2",
  "channel": "chat.chat_5Nq8vR2",
  "order": "order_9Ks2mP1",
  "status": "open",
  "me": "chat_participant_2Lm4kQ7",
  "participants": [
    {
      "id": "chat_participant_2Lm4kQ7",
      "role": "customer",
      "name": "Ada Buyer",
      "avatar_url": null,
      "is_online": true
    },
    {
      "id": "chat_participant_7Rt3pW9",
      "role": "driver",
      "name": "Ravi Kumar",
      "avatar_url": "https://files.example.com/ravi.png",
      "is_online": true
    }
  ],
  "messages": [
    {
      "id": "chat_message_3Hk9mL2",
      "content": "Picked up your order, about 8 minutes away.",
      "sender": {
        "id": "chat_participant_7Rt3pW9",
        "role": "driver",
        "name": "Ravi Kumar"
      },
      "is_mine": false,
      "attachments": [],
      "read": true,
      "created_at": "2026-10-07T13:52:00Z"
    }
  ],
  "unread_count": 0
}
GET/v1/orders/chat

Get Order Chat

Returns the order's chat (see the Order Chat object) with its latest 50 messages, oldest first, opening it when a driver is assigned. unread_count counts messages from others the customer hasn't read. Subscribe to channel for live messages.

Refusals: 401 without a customer token, 404 for an order not placed through this storefront, 403 for another customer's order, and 409 with "reason": "driver_not_assigned" when no driver is assigned yet (or the order finished without ever having a chat).

GET/v1/orders/chat
curl https://api.fleetbase.io/v1/orders/chat \
  -H "Authorization: Bearer flb_live_…" \
  -H "Customer-Token: {{customer_token}}"
GET/v1/orders/chat/messages

List Order Chat Messages

Older messages of the order's chat, oldest first, as { "messages": [...] }. Pass the oldest message you have as before to page back. A before that isn't in this chat returns 404.

Refusals: 401 without a customer token, 404 for an order not placed through this storefront, 403 for another customer's order, and 409 with "reason": "driver_not_assigned" when no driver is assigned yet (or the order finished without ever having a chat).

Query parameters
beforestringoptional

Message ID; only messages sent before it are returned.

limitintegeroptional

Maximum number of messages. Defaults to 50; values above 100 are treated as 100.

GET/v1/orders/chat/messages
curl https://api.fleetbase.io/v1/orders/chat/messages?before=&limit=50 \
  -H "Authorization: Bearer flb_live_…" \
  -H "Customer-Token: {{customer_token}}"
POST/v1/orders/chat/messages

Send Order Chat Message

Sends a message to the driver and returns { "message": Message }. Send content, files (photos), or both. The driver is notified and the message is broadcast on the chat channel. Once the order is finished the chat is read-only and sending returns 423 with "reason": "chat_closed".

Refusals: 401 without a customer token, 404 for an order not placed through this storefront, 403 for another customer's order, and 409 with "reason": "driver_not_assigned" before a driver is assigned.

Body parameters
contentstringoptional

Message text, up to 2000 characters. Required without files.

filesarray of objectsoptional

Up to 4 photos, each \{ "data": base64, "type": "image/jpeg" \}. data and type are required for each file, and type must be an image type (image/…). Required without content. Invalid input returns 422.

POST/v1/orders/chat/messages
curl -X POST https://api.fleetbase.io/v1/orders/chat/messages \
  -H "Authorization: Bearer flb_live_…" \
  -H "Content-Type: application/json" \
  -H "Customer-Token: {{customer_token}}" \
  -d '{
  "content": "I'\''m in tower B, unit 08-112."
}'
POST/v1/orders/chat/read

Mark Order Chat as Read

Marks the driver's messages as read for the customer and returns { "read": n }, the number of messages marked. The driver sees the read receipts on the chat channel.

Refusals: 401 without a customer token, 404 for an order not placed through this storefront, 403 for another customer's order, and 409 with "reason": "driver_not_assigned" before a driver is assigned.

POST/v1/orders/chat/read
curl -X POST https://api.fleetbase.io/v1/orders/chat/read \
  -H "Authorization: Bearer flb_live_…" \
  -H "Customer-Token: {{customer_token}}"
Order Chat | Fleetbase