Skip to main content

Error Response Format

All API errors return a JSON body with a detail field:
{
  "detail": "Human-readable error message"
}
For validation errors (422), the format includes field-level details:
{
  "detail": [
    {
      "loc": ["body", "field_name"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

HTTP Status Codes

Success Codes

CodeMeaningWhen Used
200OKSuccessful GET, PUT, PATCH, DELETE
201CreatedSuccessful POST that creates a resource

Client Error Codes

CodeMeaningCommon Causes
400Bad RequestInvalid input, malformed request body, invalid phone number format
401UnauthorizedMissing authentication, expired JWT, invalid API key
403ForbiddenInsufficient role permissions (e.g., Member trying to create an agent)
404Not FoundResource doesn’t exist, or not in the user’s workspace
409ConflictDuplicate resource (e.g., registering an already-registered phone number)
422Validation ErrorRequest body fails Pydantic schema validation

Server Error Codes

CodeMeaningCommon Causes
500Internal Server ErrorUnhandled exception, database error, external service failure

Common Error Messages

Authentication Errors

MessageCodeCauseFix
"Invalid or missing token"401No access_token cookie or invalid JWTRe-login or check JWT_API_SECRET
"Token expired"401JWT has expiredCall POST /auth/refresh
"Invalid API key"401API key doesn’t exist in databaseVerify key or create a new one
"User not found"401JWT references deleted userRe-register

Authorization Errors

MessageCodeCauseFix
"Insufficient permissions"403User’s role is too lowRequest role upgrade from workspace admin
"Not a member of this workspace"403User doesn’t belong to the workspaceGet invited by an admin
"Admin access required"403Endpoint requires Admin roleContact workspace admin

Resource Errors

MessageCodeCauseFix
"Agent not found"404Agent ID doesn’t exist or wrong workspaceVerify ID and workspace
"Phone number already registered"409SIP trunk for this number existsUse the existing trunk or delete first
"Batch is currently running"400Tried to delete a running batchWait for completion
"File too large"400Uploaded file exceeds limitUse smaller file or compress

External Service Errors

MessageCodeCauseFix
"LiveKit SIP error: ..."500SIP trunk creation failedCheck LiveKit connectivity and credentials
"Twilio error: ..."500Phone number purchase failedCheck Twilio balance and credentials
"S3 error: ..."500Recording URL generation failedCheck S3 credentials and bucket config

Pagination

Paginated endpoints include these fields:
FieldTypeDescription
itemsarrayCurrent page of results
totalintegerTotal number of items
pageintegerCurrent page number
page_sizeintegerItems per page
total_pagesintegerTotal number of pages

Rate Limiting

Rate limiting is not currently implemented. All endpoints accept unlimited requests. Plan to implement rate limiting using slowapi or nginx-level throttling in a future release.