For most use cases, we recommend never closing a conversation. Nothing is more frustrating than getting back to a chat and having the system prevent you from responding or following up.

However, there are many legitimate reasons to want to close a chat, so that people can't write additional messages.

TalkJS does not have an explicit "close chat" feature, but it does allow you to control the access rights of a user in a conversation. If you remove everybody's write access, they'll see that the text entry field is disabled, but they can still see what was discussed. That's effectively the same as closing a conversation.

To do this, use the REST API to send a PATCH call for every participant in a conversation, changing the access to "Read" instead of the default "ReadWrite". For example, for a conversation id "54321" has participants with user ids "1" and "5", you'd do these REST calls:

curl https://api.talkjs.com/v1/YOUR_APP_ID/conversations/54321/participants/1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X PATCH
-d '{ "access": "Read" }'

curl https://api.talkjs.com/v1/YOUR_APP_ID/conversations/54321/participants/5 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X PATCH
-d '{ "access": "Read" }'

The REST API from the example above is documented here. User access rights are described in more detail under Joining and Leaving.