Unassign a conversation
Remove the user, the team, or both from a conversation. Use the endpoint for what you want to remove:
| Endpoint | Removes | Keeps |
|---|---|---|
DELETE /open/conversations/<session-key>/assignment/user | The user | The team |
DELETE /open/conversations/<session-key>/assignment/team | The team | The user |
DELETE /open/conversations/<session-key>/assignment | Both | — |
Removing something that isn't assigned is not an error: the request succeeds and returns the current assignment.
Endpoint
DELETE https://api.p.2chat.io/open/conversations/<session-key>/assignment/user
DELETE https://api.p.2chat.io/open/conversations/<session-key>/assignment/team
DELETE https://api.p.2chat.io/open/conversations/<session-key>/assignment
<session-key>is thesession_keyof the conversation, e.g.WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176. See where to get it.
Authentication
Include your API key in the X-User-API-Key header. Learn more about authentication.
Invocation
The example removes only the user. Change the path to /assignment/team or /assignment to remove the team or both.
- cURL
- Python
- JavaScript
- PHP
curl --location --request DELETE 'https://api.p.2chat.io/open/conversations/WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176/assignment/user' \
--header 'X-User-API-Key: your_api_key_here'
import requests
url = "https://api.p.2chat.io/open/conversations/WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176/assignment/user"
headers = {
"X-User-API-Key": "your_api_key_here"
}
response = requests.delete(url, headers=headers)
print(response.json())
const axios = require('axios');
const response = await axios.delete('https://api.p.2chat.io/open/conversations/WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176/assignment/user', {
headers: {
'X-User-API-Key': 'your_api_key_here'
}
});
console.log(response.data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.p.2chat.io/open/conversations/WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176/assignment/user',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'X-User-API-Key: your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
Success (HTTP 200 OK)
{
"success": true,
"data": {
"assigned_user": null,
"assigned_team": {
"uuid": "VUGa71c3e09-8b52-4f0d-9d1e-5c6b2f8e4a10",
"name": "Sales"
}
}
}
| Field | Description |
|---|---|
data.assigned_user | The user the conversation is assigned to, or null. See the assignment object. |
data.assigned_team | The team the conversation is assigned to, or null. |
DELETE /assignment always returns null in both fields.
Error
{
"success": false,
"error": true,
"error_message": "Description of what went wrong"
}
| HTTP status | When |
|---|---|
401 | The API key is missing or invalid |
403 | The user who owns the API key can't open this conversation. See permissions |
404 | There is no conversation with that session_key in your account |