Skip to main content

UC-016 — Manage the Inbox

Real-world scenarios​

  • Customer support triage: The ShopOnline support team uses the API to feed their internal dashboard and assign conversations to available operators.
  • Archive resolved conversations: After closing a ticket, the operator archives the conversation to keep the inbox clean and focused on open cases.
  • Monitor unread messages: The supervisor checks how many unread conversations there are to assess team workload.
  • Workload distribution: The supervisor lists assignable team members and assigns each conversation to a specific agent via API; the assignment shows up in their personalised inbox view.

Inbox management flow​

The diagram shows the typical workflow: listing, reading (which also marks the conversation as read), archiving, and optionally assigning the conversation to a teammate.

Prerequisites​

  • Active API Key with inbox management permissions
  • At least one active channel with inbound messages configured
  • Receiving webhook configured (optional, for real-time notifications)

Step 1 — Retrieve active conversations​

List the conversations of the active inbox, newest first. Narrow the list with unreadOnly, channelIds and dateFrom; section picks the inbox section (ACTIVE by default, ARCHIVED or TRASHED).

curl -X GET "https://api.qlara.ai/api/partner-gateway/inbox/conversations?orderBy=-lastMessageDate" \
-H "X-Api-Key: YOUR_API_KEY"

Response — Conversation list​

The response is a JSON array, one entry per conversation:

[
{
"id": 61920,
"companyId": 189,
"hasUnreadMessages": true,
"lastCheckedAt": "2026-04-09 12:10:00.000+0000",
"userName": "Marco Rossi",
"phoneNumber": "+393471234567",
"externalUserId": null,
"profilePicture": null,
"unreadCount": 3,
"lastMessageText": "Buongiorno, vorrei informazioni sulla spedizione del mio ordine",
"lastMessageDate": "2026-04-09 12:30:00.000+0000",
"socialMedia": "whatsapp",
"channelId": 42,
"companyProfileName": "ShopOnline",
"companyProfilePicture": null,
"companyProfileId": "42",
"companyPhoneNumber": "+390212345678",
"companyPhoneNumberType": null,
"whatsappWindowExpire": "2026-04-10 12:30:00.000+0000",
"assignedUserId": null,
"status": "OPEN",
"visibility": "ACTIVE"
},
{
"id": 61918,
"companyId": 189,
"hasUnreadMessages": true,
"lastCheckedAt": "2026-04-09 11:00:00.000+0000",
"userName": "giulia.bianchi",
"phoneNumber": null,
"externalUserId": "1309399970616060",
"profilePicture": "https://storage.example.com/profiles/giulia.jpg",
"unreadCount": 1,
"lastMessageText": "Ciao, avete ancora la borsa in vetrina?",
"lastMessageDate": "2026-04-09 11:45:00.000+0000",
"socialMedia": "instagram",
"channelId": 1308,
"companyProfileName": "shoponline_official",
"companyProfilePicture": null,
"companyProfileId": "17841473473831061",
"companyPhoneNumber": null,
"companyPhoneNumberType": null,
"whatsappWindowExpire": null,
"assignedUserId": 4521,
"status": "OPEN",
"visibility": "ACTIVE"
}
]

socialMedia is lowercase (whatsapp, rcs, instagram, facebook or chatbot). Joined to channelId it gives a channelIds filter value, such as WHATSAPP-42 or INSTAGRAM-1308 (upper or lower case). externalUserId is the contact's Instagram or Facebook Messenger user ID, null on WhatsApp, RCS and the chatbot. status is OPEN, IN_PROGRESS or CLOSED, and visibility is the inbox section the conversation is in (ACTIVE, ARCHIVED or TRASHED).

Filter for unread

Add &unreadOnly=true to the query to display only conversations with unread messages, useful for triage.

Behind the scenes — How the inbox works
  1. Aggregation: The inbox aggregates the conversations of WhatsApp, RCS, Facebook Messenger, Instagram and the website chatbot into a single unified view. SMS replies never reach the inbox.
  2. Threading: A conversation is one contact on one channel, with one of your senders on it (a WhatsApp number, an RCS agent, a Facebook Page, an Instagram account or a chatbot). The contact is identified by phone number on WhatsApp and RCS (phoneNumber), by the social account on Facebook Messenger and Instagram (externalUserId, with phoneNumber null) and as an anonymous visitor on the website chatbot (phoneNumber null). The same number on WhatsApp and on RCS gives two separate conversations.
  3. Sorting: Conversations are sorted by last message timestamp (most recent first).
  4. No pagination: the endpoint returns the whole list of the requested section as a JSON array. Narrow it with unreadOnly=true, channelIds and dateFrom (last message at or after an instant: yyyy-MM-dd, yyyy-MM-ddTHH:mm:ss in UTC, or ISO-8601 with an offset), pick the section with section (ACTIVE by default, ARCHIVED or TRASHED), and sort it with orderBy (-lastMessageDate for newest first). An invalid section or dateFrom is answered 400.

Step 2 — Read messages in a conversation​

Retrieve the latest messages of a specific conversation: up to 20 per call, the most recent ones, ordered oldest first. For older messages, page backwards by message id with idTo, as described in Message pagination of UC-015.

curl -X GET "https://api.qlara.ai/api/partner-gateway/inbox/conversations/61920/messages" \
-H "X-Api-Key: YOUR_API_KEY"

Response — Thread messages​

{
"profile": {
"userName": "Marco Rossi",
"profilePicture": null,
"additionalInfo": "Marco Rossi",
"contactId": null,
"externalUserId": null
},
"messages": [
{
"id": 27514,
"text": "Buongiorno, vorrei informazioni sulla spedizione del mio ordine",
"template": null,
"isUnsupported": false,
"isRead": false,
"replyMessage": null,
"reaction": null,
"createdAt": "2026-04-09 12:25:00.000+0000",
"attachments": [],
"isUserReply": true,
"status": "RECEIVED",
"isEdited": false,
"chatbotId": null,
"chatbotInfo": null
},
{
"id": 27515,
"text": "Il numero ordine e #ORD-20260405",
"template": null,
"isUnsupported": false,
"isRead": false,
"replyMessage": null,
"reaction": null,
"createdAt": "2026-04-09 12:26:00.000+0000",
"attachments": [],
"isUserReply": true,
"status": "RECEIVED",
"isEdited": false,
"chatbotId": null,
"chatbotInfo": null
},
{
"id": 27516,
"text": "Potete aiutarmi?",
"template": null,
"isUnsupported": false,
"isRead": false,
"replyMessage": null,
"reaction": null,
"createdAt": "2026-04-09 12:30:00.000+0000",
"attachments": [],
"isUserReply": true,
"status": "RECEIVED",
"isEdited": false,
"chatbotId": null,
"chatbotInfo": null
}
]
}

isUserReply: true marks a message written by the contact, false one of your replies. Timestamps use the yyyy-MM-dd HH:mm:ss.SSSZ format. profile.userName is the name in your contact book when the conversation matches a contact (contactId), otherwise the name on the channel, which additionalInfo always carries. chatbotId and chatbotInfo are filled only on the messages a chatbot sent.

Reading marks the conversation as read

A call without idFrom and idTo, like this one, also marks the conversation as read: its unreadCount goes to 0 and the channel is told that every unread inbound message was read, so the contact can see a read receipt. The messages of this same response can still show isRead: false. To read the latest page without that effect, add idFrom=1: you get the same messages and the conversation stays unread.

Step 3 — Mark as read (if needed) and archive​

The GET of Step 2 already marked the conversation as read. Call PATCH .../read only when you read the messages with idFrom or idTo, or to mark a conversation as read without fetching it. Then archive the conversation.

# Mark as read
curl -X PATCH https://api.qlara.ai/api/partner-gateway/inbox/conversations/61920/read \
-H "X-Api-Key: YOUR_API_KEY"

Response — Marked as read​

204 No Content — the unread counter of the conversation is now 0, and the channel is told that the unread inbound messages were read.

# Archive the resolved conversation
curl -X PATCH https://api.qlara.ai/api/partner-gateway/inbox/conversations/61920/archive \
-H "X-Api-Key: YOUR_API_KEY"

Response — Conversation archived​

204 No Content — the conversation no longer appears in GET /inbox/conversations; list it with section=ARCHIVED.

Behind the scenes — Archiving and restoring
  1. Archiving: The conversation is moved to the archive and no longer appears in the active list; GET /inbox/conversations?section=ARCHIVED lists it. Messages remain accessible. The call does not check the current state: archiving an archived conversation returns 204, and a trashed one is moved to the archive.
  2. Restoring: Use PATCH /conversations/{chatId}/unarchive to bring a conversation back to the active inbox, from the archive or from the trash. On a conversation that is already active it returns 204 and changes nothing.
  3. New message: If the contact of an archived or trashed conversation sends a new message, the conversation is automatically restored to the active inbox, with status OPEN.
  4. Automatic closing and archiving: A conversation with no new message for 7 days gets status CLOSED and stays in the active list. Once it has been CLOSED for 30 days it is archived, so an untouched conversation leaves the default list about 37 days after its last message.

Step 4 — Assign or release a conversation​

Distribute the inbox workload by assigning a conversation to a specific team member, or release it back to the unassigned queue.

List assignable team members​

curl -X GET https://api.qlara.ai/api/partner-gateway/inbox/conversations/assignable-users \
-H "X-Api-Key: YOUR_API_KEY"

Response — Team members​

[
{
"id": 4521,
"fullName": "Anna Bianchi",
"profilePicture": "https://cdn.example.com/users/4521/avatar.png"
},
{
"id": 4522,
"fullName": "Luca Verdi",
"profilePicture": "https://cdn.example.com/users/4522/avatar.png"
},
{
"id": 4523,
"fullName": "Marco Rossi",
"profilePicture": null
}
]

Assign the conversation to a user​

curl -X POST https://api.qlara.ai/api/partner-gateway/inbox/conversations/98765/assignee \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"userId": 4521}'

Response​

204 No Content — the conversation is now owned by user 4521. A subsequent GET /inbox/conversations/98765 will reflect the new assignedUserId.

Release the conversation​

curl -X DELETE https://api.qlara.ai/api/partner-gateway/inbox/conversations/98765/assignee \
-H "X-Api-Key: YOUR_API_KEY"

Response​

204 No Content — the conversation is back to unassigned. The operation is idempotent: calling it on an already-unassigned conversation still returns 204.

One assignee at a time

Each conversation can have at most one assignee. A new POST .../assignee replaces the previous assignment without requiring an explicit DELETE.

Behind the scenes — Assignment lifecycle
  1. Exclusive ownership: Only one team member can own a conversation at a time. Re-assigning silently replaces the previous owner.
  2. Notifications: Assigning sends no notification to the assignee. Notifications about new inbound messages go to every user of your company whether or not the conversation is assigned; on a conversation handled by a chatbot they start only once it has an assignee. To alert the assigned agent, notify them from your application.
  3. Idempotent release: DELETE .../assignee returns 204 whether or not there was a previous assignee, so retry logic is safe.
  4. Cross-company guard: The userId in the assign request must belong to your company. Attempts to assign to a user from another account return 404, not 403, to avoid leaking user existence across tenants.

Expected result​

StepActionResult
1GET /inbox/conversationsConversation list with preview and unread count
2GET /inbox/conversations/{chatId}/messagesLatest messages of the thread (up to 20); the conversation is marked as read
3PATCH /{chatId}/read + PATCH /{chatId}/archiveConversation read and archived
4POST /{chatId}/assignee + DELETE /{chatId}/assigneeConversation assigned to a teammate and later released

Complete end-to-end example​

Scenario ShopOnline: automatic triage of unread conversations.

# 1. Retrieve unread conversations
echo "=== Unread Conversations ==="
CHATS=$(curl -s -X GET "https://api.qlara.ai/api/partner-gateway/inbox/conversations?unreadOnly=true&orderBy=-lastMessageDate" \
-H "X-Api-Key: YOUR_API_KEY")

echo "$CHATS" | jq '.[] | {id, channel: .socialMedia, contact: .userName, unread: .unreadCount}'

# 2. Read the latest messages of the first conversation
# idFrom=1 returns the same page without marking the conversation as read
FIRST_CHAT=$(echo "$CHATS" | jq -r '.[0].id')
echo "=== Messages for $FIRST_CHAT ==="
curl -s -X GET "https://api.qlara.ai/api/partner-gateway/inbox/conversations/${FIRST_CHAT}/messages?idFrom=1" \
-H "X-Api-Key: YOUR_API_KEY" | jq '.messages[] | {isUserReply, text, createdAt}'

# 3. Mark as read once handled (204, no body)
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH "https://api.qlara.ai/api/partner-gateway/inbox/conversations/${FIRST_CHAT}/read" \
-H "X-Api-Key: YOUR_API_KEY")
echo "marked as read: HTTP $STATUS"

Variants​

List archived and trashed conversations​

Without section the list holds only the active inbox. Archived conversations, including those archived automatically, and trashed ones are listed separately:

curl -X GET "https://api.qlara.ai/api/partner-gateway/inbox/conversations?section=ARCHIVED" \
-H "X-Api-Key: YOUR_API_KEY"

curl -X GET "https://api.qlara.ai/api/partner-gateway/inbox/conversations?section=TRASHED" \
-H "X-Api-Key: YOUR_API_KEY"

Restore an archived conversation​

If a conversation was archived by mistake, restore it:

curl -X PATCH https://api.qlara.ai/api/partner-gateway/inbox/conversations/61920/unarchive \
-H "X-Api-Key: YOUR_API_KEY"

Common errors​

400 Bad Request — Invalid section or dateFrom​

{
"status": "fail",
"data": "Invalid 'section': 'ASSIGNED_TO_ME'. Allowed values: ACTIVE, ARCHIVED, TRASHED"
}

Solution: section selects the inbox section, not the assignee: use ACTIVE, ARCHIVED or TRASHED. A malformed dateFrom gets the same kind of body, naming dateFrom and its accepted formats.

404 Not Found — Conversation not found​

{
"status": "fail",
"data": "Resource not found."
}

Solution: Verify that the chatId is correct. Use GET /inbox/conversations to get the list of valid IDs. A conversation that does not exist and one of another account give the same body. A chatId that is not a number gives 404 with "data": "HTTP 404 Not Found".

404 Not Found — User not in your company​

The assign call answers with the same body as an unknown conversation:

{
"status": "fail",
"data": "Resource not found."
}

Solution: Either the conversation or the userId you tried to assign is not in your account: the body does not say which. Call GET /inbox/conversations/assignable-users to list the valid user IDs before retrying.

502 Bad Gateway — User check unavailable​

{
"status": "error",
"message": "Server error."
}

Solution: POST .../assignee and GET /inbox/conversations/assignable-users rely on the user-profile service, which was temporarily unavailable. Retry after a short delay.

Next steps​

References​