API des contacts #
Créez, mettez à jour et gérez les contacts dans votre base de données VoxPria.
Créer un contact #
Point de terminaison : POST /api/v1/contacts
curl -X POST "https://app.voxpria.com/api/v1/contacts"
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"phone": "+14155551234",
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"metadata": {
"customerId": "12345",
"accountType": "premium"
}
}'
Réponse #
{
"success": true,
"data": {
"contactId": "contact_abc123",
"phone": "+14155551234",
"firstName": "John",
"lastName": "Doe",
"createdAt": "2025-02-09T12:00:00Z"
}
}
Importation groupée de contacts #
Point de terminaison : POST /api/v1/contacts/bulk
Importez jusqu’à 10 000 contacts à la fois :
curl -X POST "https://app.voxpria.com/api/v1/contacts/bulk"
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"contacts": [
{
"phone": "+14155551234",
"firstName": "John",
"lastName": "Doe"
},
{
"phone": "+14155555678",
"firstName": "Jane",
"lastName": "Smith"
}
]
}'
Réponse #
{
"success": true,
"data": {
"imported": 2,
"skipped": 0,
"errors": []
}
}
Lister les contacts #
Point de terminaison : GET /api/v1/contacts
curl -X GET "https://app.voxpria.com/api/v1/contacts?page=1&limit=50" -H "Authorization: Bearer YOUR_API_KEY"
Mettre à jour un contact #
Point de terminaison : PUT /api/v1/contacts/:id
curl -X PUT "https://app.voxpria.com/api/v1/contacts/contact_abc123"
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"email": "newemail@example.com",
"metadata": {
"accountType": "enterprise"
}
}'
Supprimer un contact #
Point de terminaison : DELETE /api/v1/contacts/:id
curl -X DELETE "https://app.voxpria.com/api/v1/contacts/contact_abc123" -H "Authorization: Bearer YOUR_API_KEY"
Exemple de code – Importation groupée #
JavaScript #
async function bulkImportContacts(contacts) {
const response = await axios.post(
'https://app.voxpria.com/api/v1/contacts/bulk',
{ contacts },
{
headers: {
'Authorization': `Bearer ${process.env.VOXPRIA_API_KEY}`
}
}
);
return response.data;
}
// Utilisation
const contacts = [
{ phone: '+14155551234', firstName: 'John', lastName: 'Doe' },
{ phone: '+14155555678', firstName: 'Jane', lastName: 'Smith' }
];
const result = await bulkImportContacts(contacts);
console.log(`Imported: ${result.data.imported}`);
Python #
def bulk_import_contacts(contacts):
response = requests.post(
'https://app.voxpria.com/api/v1/contacts/bulk',
json={'contacts': contacts},
headers={
'Authorization': f'Bearer {os.getenv("VOXPRIA_API_KEY")}'
}
)
return response.json()
# Utilisation
contacts = [
{'phone': '+14155551234', 'firstName': 'John', 'lastName': 'Doe'},
{'phone': '+14155555678', 'firstName': 'Jane', 'lastName': 'Smith'}
]
result = bulk_import_contacts(contacts)
print(f"Imported: {result['data']['imported']}")
