Manage chats

Learn how to accept requests, archive, mute, mark as read, and delete Facebook chats with Unipile API.

Accept a message request

Message requests are in the PENDING inbox. To accept one, use Accept a Chat Request.

curl --request POST \
     --url https://api.unipile.com/v2/acc_123456789/inboxes/PENDING/chats/chat_id/accept \
     --header 'X-API-KEY: api-key' \
     --header 'accept: application/json'

Update a chat

To change the state of a chat, use Update a Chat with one or several of these fields:

FieldEffect
read_statustrue marks the chat as read, false as unread.
archive_statustrue archives the chat, false moves it back to the main inbox.
muted_untilA date to mute the chat until that date, true to mute it indefinitely, false to unmute it.
nameRenames the chat.
pictureChanges the chat's picture.

Facebook has no chat labels or pinned chats: setting label or pin_status returns 501 api/not_implemented.

const { data } = await messagingApi.updateChat({
  path: {
    account_id: "acc_123456789",
    chat_id: "chat_id",
  },
  body: {
    archive_status: true,
  },
});
chat = messaging_api.update_chat(
    "chat_id",
    "acc_123456789",
    {"archive_status": True},
)
curl --request PATCH \
     --url https://api.unipile.com/v2/acc_123456789/chats/chat_id \
     --header 'X-API-KEY: api-key' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "archive_status": true
}
'

Mark a message as read

To mark a message as read, use Read a Message.

await messagingApi.readMessage({
  path: {
    account_id: "acc_123456789",
    chat_id: "chat_id",
    message_id: "message_id",
  },
});
messaging_api.read_message(
    "chat_id",
    "message_id",
    "acc_123456789",
)
curl --request POST \
     --url https://api.unipile.com/v2/acc_123456789/chats/chat_id/messages/message_id/read \
     --header 'X-API-KEY: api-key' \
     --header 'accept: application/json'

To be notified when a message is read or delivered, set up a Webhook that listens for message.receipt.read and message.receipt.delivery events.


Delete a chat

To delete a chat, use Delete a Chat.

await messagingApi.deleteChat({
  path: {
    account_id: "acc_123456789",
    chat_id: "chat_id",
  },
});
messaging_api.delete_chat("chat_id", "acc_123456789")
curl --request DELETE \
     --url https://api.unipile.com/v2/acc_123456789/chats/chat_id \
     --header 'X-API-KEY: api-key' \
     --header 'accept: application/json'

Did this page help you?