User Presence
Manage and monitor user presence status and availability.
Overview​
User presence indicates a user's current availability status. Presence status is visible to other users and affects call routing behavior.
Presence Status​
| Status | Description | Availability |
|---|---|---|
available | User is available and can receive calls | Will receive calls |
busy | User is in a call or meeting | May not receive calls |
away | User is temporarily away | Voicemail or forwarding |
dnd | Do Not Disturb - user does not want calls | No calls, voicemail only |
offline | User is logged out | No calls |
invisible | User appears offline but is available | Hidden status |
Endpoints​
GET /v1/accounts/{accountId}/users/{userId}/presence
POST /v1/accounts/{accountId}/users/{userId}/presence
GET /v1/accounts/{accountId}/users/presence
Get User Presence​
Retrieve the current presence status of a user.
Endpoint​
GET https://api.audian.com:8443/v2/accounts/{accountId}/users/{userId}/presence
Example​
curl -X GET https://api.audian.com:8443/v2/accounts/acc_1234567890/users/user_123456/presence \
-H "X-Auth-Token: YOUR_API_TOKEN"
Response​
{
"userId": "user_123456",
"status": "available",
"customMessage": "In office, working on client proposal",
"lastUpdate": "2023-10-20T10:15:00Z",
"activeCall": false,
"activeMeeting": false,
"doNotDisturb": {
"enabled": false,
"reason": null,
"until": null
},
"callForwarding": {
"enabled": false,
"destination": null
}
}
Set User Presence​
Update a user's presence status.
Endpoint​
POST https://api.audian.com:8443/v2/accounts/{accountId}/users/{userId}/presence
Request Body​
| Parameter | Type | Required | Description |
|---|---|---|---|
status | string | Yes | Presence status |
message | string | No | Custom status message |
duration | integer | No | Duration in seconds |
Example​
curl -X POST https://api.audian.com:8443/v2/accounts/acc_1234567890/users/user_123456/presence \
-H "Content-Type: application/json" \
-H "X-Auth-Token: YOUR_API_TOKEN" \
-d '{
"status": "away",
"message": "In a meeting until 2 PM",
"duration": 3600
}'
Response​
{
"userId": "user_123456",
"status": "away",
"customMessage": "In a meeting until 2 PM",
"lastUpdate": "2023-10-20T10:30:00Z",
"expiresAt": "2023-10-20T11:30:00Z"
}
Bulk Presence Status​
Get presence for multiple users.
Endpoint​
GET https://api.audian.com:8443/v2/accounts/{accountId}/users/presence
Query Parameters​
| Parameter | Type | Description |
|---|---|---|
userIds | string | Comma-separated user IDs |
status | string | Filter by status |
limit | integer | Number of results |
Example​
curl -X GET "https://api.audian.com:8443/v2/accounts/acc_1234567890/users/presence?userIds=user_123456,user_789012&status=available" \
-H "X-Auth-Token: YOUR_API_TOKEN"
Response​
{
"data": [
{
"userId": "user_123456",
"status": "available",
"customMessage": "In office",
"lastUpdate": "2023-10-20T10:15:00Z"
},
{
"userId": "user_789012",
"status": "dnd",
"customMessage": "Do not disturb",
"lastUpdate": "2023-10-20T10:00:00Z"
}
]
}
Do Not Disturb (DND)​
Enable DND​
curl -X POST https://api.audian.com:8443/v2/accounts/acc_1234567890/users/user_123456/dnd \
-H "Content-Type: application/json" \
-H "X-Auth-Token: YOUR_API_TOKEN" \
-d '{
"enabled": true,
"reason": "Busy",
"duration": 3600
}'
Response​
{
"userId": "user_123456",
"dnd": {
"enabled": true,
"reason": "Busy",
"startTime": "2023-10-20T10:30:00Z",
"endTime": "2023-10-20T11:30:00Z",
"sendToVoicemail": true
}
}
Disable DND​
curl -X DELETE https://api.audian.com:8443/v2/accounts/acc_1234567890/users/user_123456/dnd \
-H "X-Auth-Token: YOUR_API_TOKEN"
Call Forwarding​
Set Call Forwarding​
curl -X POST https://api.audian.com:8443/v2/accounts/acc_1234567890/users/user_123456/call-forwarding \
-H "Content-Type: application/json" \
-H "X-Auth-Token: YOUR_API_TOKEN" \
-d '{
"enabled": true,
"destination": "+1-555-9999",
"destinationType": "external",
"noAnswerAfter": 20
}'
Response​
{
"userId": "user_123456",
"callForwarding": {
"enabled": true,
"destination": "+1-555-9999",
"destinationType": "external",
"noAnswerAfter": 20,
"lastUpdate": "2023-10-20T10:35:00Z"
}
}
Disable Call Forwarding​
curl -X DELETE https://api.audian.com:8443/v2/accounts/acc_1234567890/users/user_123456/call-forwarding \
-H "X-Auth-Token: YOUR_API_TOKEN"
JavaScript/Node.js Example​
const axios = require('axios');
async function setUserPresence(accountId, userId, status, message) {
try {
const response = await axios.post(
`https://api.audian.com:8443/v2/accounts/${accountId}/users/${userId}/presence`,
{
status: status,
message: message,
duration: 3600
},
{
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN'
}
}
);
console.log('Presence updated:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
}
}
async function getUserPresence(accountId, userId) {
try {
const response = await axios.get(
`https://api.audian.com:8443/v2/accounts/${accountId}/users/${userId}/presence`,
{
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
}
);
console.log('User presence:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
}
}
// Usage
setUserPresence('acc_1234567890', 'user_123456', 'away', 'In a meeting');
getUserPresence('acc_1234567890', 'user_123456');
Python Example​
import requests
def set_user_presence(account_id, user_id, status, message=None):
url = f'https://api.audian.com:8443/v2/accounts/{account_id}/users/{user_id}/presence'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN'
}
data = {
'status': status,
'duration': 3600
}
if message:
data['message'] = message
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Presence updated:', response.json())
return response.json()
else:
print('Error:', response.json())
def get_user_presence(account_id, user_id):
url = f'https://api.audian.com:8443/v2/accounts/{account_id}/users/{user_id}/presence'
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
print('User presence:', response.json())
return response.json()
else:
print('Error:', response.json())
# Usage
set_user_presence('acc_1234567890', 'user_123456', 'away', 'In a meeting')
get_user_presence('acc_1234567890', 'user_123456')
Presence Events​
Subscribe to presence change events:
curl -X POST https://api.audian.com:8443/v2/accounts/acc_1234567890/webhooks \
-H "Content-Type: application/json" \
-H "X-Auth-Token: YOUR_API_TOKEN" \
-d '{
"url": "https://yourserver.com/webhooks/presence",
"events": ["user.presence.changed"]
}'
Webhook Event Example​
{
"event": "user.presence.changed",
"timestamp": "2023-10-20T10:35:00Z",
"data": {
"userId": "user_123456",
"status": "away",
"message": "In a meeting",
"previousStatus": "available"
}
}
Presence Rules​
Auto-Update Rules​
Configure automatic presence updates:
curl -X POST https://api.audian.com:8443/v2/accounts/acc_1234567890/users/user_123456/presence-rules \
-H "Content-Type: application/json" \
-H "X-Auth-Token: YOUR_API_TOKEN" \
-d '{
"rules": [
{
"condition": "activeCall",
"setStatus": "busy"
},
{
"condition": "activeMeeting",
"setStatus": "busy"
},
{
"condition": "afterHours",
"setStatus": "away",
"message": "Offline"
}
]
}'
Best Practices​
- Auto-Update: Enable automatic presence updates during calls
- Messages: Use clear, helpful status messages
- Timing: Set appropriate duration for temporary statuses
- Forwarding: Use call forwarding when away
- DND: Use DND during focused work
- Consistency: Keep presence synchronized across devices
Status Codes​
| Code | Description |
|---|---|
200 | Success |
201 | Created |
400 | Bad request |
401 | Unauthorized |
404 | User not found |
500 | Server error |