You can programmatically add or remove users from a conversation depending on your use-case.

It's important to note that you can only add users to a conversation with a unique conversation id supplied by you. For more information about conversations with and without unique identifier supplied by you, check the Conversations documentation.

Joining

You can add any user to a conversation with the Join call. When you add a new user to a conversation, that user will have access to all of the chat history including any chat history created before they joined. This also applies to a user that was removed and added again later. The Join call expects a payload as specified in the reference. It always overwrites values set before. If you don't pass anything it will fallback to the following defaults:

{
    "access": "ReadWrite",
    "notify": true
}
curl https://api.talkjs.com/v1/YOUR_APP_ID/conversations/order_391_fc/participants/u_924772 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X PUT
-d '{ "access": "Read", "notify": true }'

Modifying participation settings

If a user is already a participant of the conversation then you can toggle sending notifications, or modify their writing rights. The payload structure is the same as for the Join call. This call will only update fields given in the payload, leaving the old ones as they were.

curl https://api.talkjs.com/v1/YOUR_APP_ID/conversations/order_391_fc/participants/u_924772 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X PATCH
-d '{ "access": "ReadWrite", "notify": false }'

Leaving

You can also remove anyone from a conversation with the Leave call. Removed users no longer receive notifications, and can no longer write anything or read any messages that were sent after their removal. They can, however, still read the conversation up until they were removed. Their messages will still be in the history and can still be seen by other participants.

curl https://api.talkjs.com/v1/YOUR_APP_ID/conversations/order_391_fc/participants/u_924772 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X DELETE

Read the full Participation reference.