Errori
Le API Replicer utilizzano codici di stato HTTP standard e restituiscono risposte di errore JSON consistenti.
Formato della risposta di errore
json
{
"error": {
"code": "validation_error",
"message": "agentId, toNumber, and fromNumber are required",
"details": null
},
"requestId": "req-abc123"
}| Campo | Tipo | Descrizione |
|---|---|---|
error.code | string | Codice di errore leggibile dalla macchina |
error.message | string | Descrizione leggibile dall'utente |
error.details | object | null | Contesto aggiuntivo (quando disponibile) |
requestId | string | Identificativo univoco per il debug |
Codici di errore
Errori client (4xx)
| Status HTTP | Codice | Descrizione |
|---|---|---|
400 | bad_request | JSON malformato o body della richiesta non valido |
400 | validation_error | Campi mancanti o valori non validi |
401 | unauthorized | API key mancante o non valida |
403 | forbidden | API key inattiva o scaduta |
403 | insufficient_scope | La API key non ha lo scope richiesto |
404 | not_found | La risorsa non esiste o non appartiene alla tua organizzazione |
429 | rate_limit_exceeded | Troppe richieste — controlla l'header Retry-After |
Errori server (5xx)
| Status HTTP | Codice | Descrizione |
|---|---|---|
500 | internal_error | Qualcosa è andato storto dal nostro lato |
503 | not_implemented | Endpoint pianificato ma non ancora disponibile |
Gestire gli errori
javascript
const response = await fetch('https://api.replicer.ai/v1/calls', {
method: 'POST',
headers: {
'Authorization': 'Bearer rpl_live_your_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({ agentId, toNumber, fromNumber }),
})
if (!response.ok) {
const { error, requestId } = await response.json()
switch (error.code) {
case 'rate_limit_exceeded':
const retryAfter = response.headers.get('Retry-After')
// Attendi e riprova
break
case 'unauthorized':
// Controlla la tua API key
break
case 'validation_error':
// Correggi il body della richiesta
console.error(error.message)
break
default:
// Log del requestId per il supporto
console.error(`Error ${error.code}: ${error.message} (${requestId})`)
}
}Request ID
Ogni risposta include un campo requestId. Quando contatti il supporto per un errore, includi questo ID per facilitare l'indagine.

