Manage User Devices
Update user device settings including availability and SIP passwords.
Update User Device
HTTP Request
PUT /v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>
Request Parameters
| Parameter | Description |
|---|---|
available | Boolean — true (ON) or false (OFF). Only 1 device can be ON at a time |
contact_uri | Phone number in E.164 format. Changing requires re-verification |
Code Examples
- cURL
- Python
- Node.js
- PHP
- Go
curl -u '<api_key>:<api_token>' -X PUT 'https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>' \
-H 'Content-Type: application/json' \
-d '{"available": true}'
import requests
payload = {
'available': True,
}
response = requests.put(
'https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>',
auth=('<api_key>', '<api_token>'),
json=payload
)
print(response.status_code)
print(response.json())
const apiKey = '<api_key>';
const apiToken = '<api_token>';
const url = 'https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>';
const payload = {
available: true,
};
const response = await fetch(url, {
method: 'PUT',
headers: {
'Authorization': 'Basic ' + Buffer.from(`${apiKey}:${apiToken}`).toString('base64'),
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
const data = await response.json();
console.log(response.status, data);
<?php
$payload = array(
'available' => true,
);
$ch = curl_init('https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>');
curl_setopt($ch, CURLOPT_USERPWD, "<api_key>:<api_token>");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status . "\n" . $response;
?>
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
endpoint := "https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>"
payload := `{"available": true}`
req, err := http.NewRequest("PUT", endpoint, strings.NewReader(payload))
if err != nil {
panic(err)
}
req.SetBasicAuth("<api_key>", "<api_token>")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
respBody, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(respBody))
}
Response
{
"request_id": "string",
"method": "PUT",
"http_code": 200,
"response": {
"code": 200,
"status": "success",
"data": {
"id": 1,
"name": "Agent Phone",
"contact_uri": "+919999999999",
"type": "tel",
"available": true,
"verified": true,
"status": "free"
}
}
}
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
10809 | 409 | Device is unverified |
10810 | 403 | Another device is already ON |
10811 | 409 | Device already exists |
10817 | 403 | Non-PSTN device cannot be updated |
Create/Update SIP Password
HTTP Request
PUT /v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>/password
Request Body
{
"password": "SecureP@ss1"
}
Password Requirements
- Minimum 8 characters
- At least 3 of the following 4 categories:
- Lowercase letters
- Uppercase letters
- Numbers
- Special characters (
!@#$%^&*)
Code Examples
- cURL
- Python
- Node.js
- PHP
- Go
curl -u '<api_key>:<api_token>' -X PUT 'https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>/password' \
-H 'Content-Type: application/json' \
-d '{"password": "<new_sip_password>"}'
import requests
payload = {
'password': '<new_sip_password>',
}
response = requests.put(
'https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>/password',
auth=('<api_key>', '<api_token>'),
json=payload
)
print(response.status_code)
print(response.json())
const apiKey = '<api_key>';
const apiToken = '<api_token>';
const url = 'https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>/password';
const payload = {
password: '<new_sip_password>',
};
const response = await fetch(url, {
method: 'PUT',
headers: {
'Authorization': 'Basic ' + Buffer.from(`${apiKey}:${apiToken}`).toString('base64'),
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
const data = await response.json();
console.log(response.status, data);
<?php
$payload = array(
'password' => '<new_sip_password>',
);
$ch = curl_init('https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>/password');
curl_setopt($ch, CURLOPT_USERPWD, "<api_key>:<api_token>");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status . "\n" . $response;
?>
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
endpoint := "https://ccm-api.exotel.com/v2/accounts/<account_sid>/users/<user_id>/devices/<device_id>/password"
payload := `{"password": "<new_sip_password>"}`
req, err := http.NewRequest("PUT", endpoint, strings.NewReader(payload))
if err != nil {
panic(err)
}
req.SetBasicAuth("<api_key>", "<api_token>")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
respBody, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(respBody))
}
Response
{
"request_id": "string",
"method": "PUT",
"http_code": 200,
"response": {
"code": 200,
"status": "success",
"data": null
}
}