Assign a conversation to a user
Assign a conversation to a user of your account. It replaces the user it was assigned to before, if any. The team assignment, if there is one, stays.
Endpoint
POST https://api.p.2chat.io/open/conversations/<session-key>/assignment/user
<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.
Body
| Field | Type | Required | Description |
|---|---|---|---|
user_uuid | string | Yes | UUID of an active user of your account. Get it from List Account Users. If the API key owner isn't an admin, the user must also have access to the conversation's number. See permissions. |
Invocation
- cURL
- Python
- JavaScript
- PHP
curl --location --request POST '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' \
--header 'Content-Type: application/json' \
--data-raw '{
"user_uuid": "USR4f1c8a73-2e91-4d6b-9c44-1a72bfe0d521"
}'
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"
}
payload = {
"user_uuid": "USR4f1c8a73-2e91-4d6b-9c44-1a72bfe0d521"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
const axios = require('axios');
const response = await axios.post('https://api.p.2chat.io/open/conversations/WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176/assignment/user', {
"user_uuid": "USR4f1c8a73-2e91-4d6b-9c44-1a72bfe0d521"
}, {
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 => 'POST',
CURLOPT_POSTFIELDS => '{"user_uuid": "USR4f1c8a73-2e91-4d6b-9c44-1a72bfe0d521"}',
CURLOPT_HTTPHEADER => array(
'X-User-API-Key: your_api_key_here',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
Success (HTTP 200 OK)
{
"success": true,
"data": {
"assigned_user": {
"uuid": "USR4f1c8a73-2e91-4d6b-9c44-1a72bfe0d521",
"first_name": "Ada",
"last_name": "Lovelace",
"email": "ada@example.com"
},
"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. |
Error
{
"success": false,
"error": true,
"error_message": "Description of what went wrong"
}
| HTTP status | When |
|---|---|
400 | user_uuid is empty, it's not an active user of your account, or the API key owner isn't an admin and the user has no access to the conversation's number |
422 | user_uuid is missing from the body |
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 |