UC-016 — Manage the Inbox
- Goal
- Manage inbound conversations: triage, reading, archiving
- Channel
- WhatsApp, RCS, Facebook Messenger, Instagram and the website chatbot (no SMS)
- Estimated time
- 15 minutes
- APIs involved
- GET/api
/partner-gateway /inbox /conversations - GET/api
/partner-gateway /inbox /conversations /{chatId} - GET/api
/partner-gateway /inbox /conversations /{chatId} /messages - PATCH/api
/partner-gateway /inbox /conversations /{chatId} /archive - PATCH/api
/partner-gateway /inbox /conversations /{chatId} /unarchive - PATCH/api
/partner-gateway /inbox /conversations /{chatId} /read - POST/api
/partner-gateway /inbox /conversations /{chatId} /assignee - DELETE/api
/partner-gateway /inbox /conversations /{chatId} /assignee - GET/api
/partner-gateway /inbox /conversations /assignable-users
- GET/api
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).
Add &unreadOnly=true to the query to display only conversations with unread messages, useful for triage.
Behind the scenes — How the inbox works
- 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.
- 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, withphoneNumbernull) and as an anonymous visitor on the website chatbot (phoneNumbernull). The same number on WhatsApp and on RCS gives two separate conversations. - Sorting: Conversations are sorted by last message timestamp (most recent first).
- No pagination: the endpoint returns the whole list of the requested section as a JSON array. Narrow it with
unreadOnly=true,channelIdsanddateFrom(last message at or after an instant:yyyy-MM-dd,yyyy-MM-ddTHH:mm:ssin UTC, or ISO-8601 with an offset), pick the section withsection(ACTIVEby default,ARCHIVEDorTRASHED), and sort it withorderBy(-lastMessageDatefor newest first). An invalidsectionordateFromis answered400.
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.
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
- Archiving: The conversation is moved to the archive and no longer appears in the active list;
GET /inbox/conversations?section=ARCHIVEDlists 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. - Restoring: Use
PATCH /conversations/{chatId}/unarchiveto 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. - 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. - Automatic closing and archiving: A conversation with no new message for 7 days gets status
CLOSEDand stays in the active list. Once it has beenCLOSEDfor 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.
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
- Exclusive ownership: Only one team member can own a conversation at a time. Re-assigning silently replaces the previous owner.
- 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.
- Idempotent release:
DELETE .../assigneereturns 204 whether or not there was a previous assignee, so retry logic is safe. - Cross-company guard: The
userIdin 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
| Step | Action | Result |
|---|---|---|
| 1 | GET /inbox/conversations | Conversation list with preview and unread count |
| 2 | GET /inbox/conversations/{chatId}/messages | Latest messages of the thread (up to 20); the conversation is marked as read |
| 3 | PATCH /{chatId}/read + PATCH /{chatId}/archive | Conversation read and archived |
| 4 | POST /{chatId}/assignee + DELETE /{chatId}/assignee | Conversation 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
- UC-015 — Two-Way Conversation: Reply to messages received in the inbox
- UC-019 — Analyze Message History: Analyze history for reports and audits
- Webhooks Guide: Configure the webhook that notifies you of inbound messages in real time