API des appels #
L’API des appels vous permet de déclencher des appels vocaux IA et de récupérer les données d’appel de façon programmatique.
Déclencher un appel #
Point de terminaison : POST /api/v1/calls
Requête #
curl -X POST "https://app.voxpria.com/api/v1/calls"
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"agentId": "agent_abc123",
"toNumber": "+14155551234",
"variables": {
"customerName": "John Doe",
"accountNumber": "12345"
}
}'
Réponse #
{
"success": true,
"data": {
"callId": "call_xyz789",
"status": "queued",
"toNumber": "+14155551234",
"agentId": "agent_abc123",
"createdAt": "2025-02-09T12:00:00Z"
}
}
Obtenir les détails d’un appel #
Point de terminaison : GET /api/v1/calls/:id
curl -X GET "https://app.voxpria.com/api/v1/calls/call_xyz789" -H "Authorization: Bearer YOUR_API_KEY"
Réponse #
{
"success": true,
"data": {
"callId": "call_xyz789",
"status": "completed",
"duration": 127,
"recording": "https://...",
"transcript": "...",
"outcome": "successful",
"startedAt": "2025-02-09T12:00:00Z",
"completedAt": "2025-02-09T12:02:07Z"
}
}
Lister les appels #
Point de terminaison : GET /api/v1/calls
curl -X GET "https://app.voxpria.com/api/v1/calls?page=1&limit=50" -H "Authorization: Bearer YOUR_API_KEY"
États d’appel #
| État | Description |
|---|---|
queued |
L’appel est en file d’attente pour traitement |
ringing |
Le téléphone sonne |
in_progress |
L’appel est en cours |
completed |
L’appel s’est terminé avec succès |
failed |
L’appel a échoué |
no_answer |
Aucune réponse |
busy |
La ligne était occupée |
Exemple de code — déclencher un appel #
JavaScript #
const axios = require('axios');
async function triggerCall(agentId, phoneNumber, variables = {}) {
const response = await axios.post(
'https://app.voxpria.com/api/v1/calls',
{
agentId,
toNumber: phoneNumber,
variables
},
{
headers: {
'Authorization': `Bearer ${process.env.VOXPRIA_API_KEY}`,
'Content-Type': 'application/json'
}
}
);
return response.data;
}
// Usage
const result = await triggerCall(
'agent_abc123',
'+14155551234',
{ customerName: 'John Doe' }
);
console.log('Call ID:', result.data.callId);
Python #
import requests
import os
def trigger_call(agent_id, phone_number, variables=None):
response = requests.post(
'https://app.voxpria.com/api/v1/calls',
json={
'agentId': agent_id,
'toNumber': phone_number,
'variables': variables or {}
},
headers={
'Authorization': f'Bearer {os.getenv("VOXPRIA_API_KEY")}',
'Content-Type': 'application/json'
}
)
return response.json()
# Usage
result = trigger_call(
'agent_abc123',
'+14155551234',
{'customerName': 'John Doe'}
)
print('Call ID:', result['data']['callId'])
