API Reference
Complete API documentation for integrating Cordiul with your applications.
Authentication
Programmatic requests use an API key in the Authorization header. Endpoints that support API keys also accept Clerk session (browser) auth.
Authorization: Bearer YOUR_API_KEYprogrammaticAuthorization: Bearer ck_live_xxxxxxxxxxxxCreate and manage keys under Settings → API Keys. Supported endpoints (e.g. List calls) accept this Bearer token for server-to-server or script access.
Base URL
https://your-domain.com/apiEndpoints
Create API Key
Creates a new API key for authentication. API keys are used to authenticate requests to the API.
POST /api/api-keysRequest Body
{
"name": "My API Key",
"permissions": ["calls:read", "calls:write"]
}Code Examples
curl --request POST \
--url 'https://your-domain.com/api/api-keys' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"name": "My API Key",
"permissions": [
"calls:read",
"calls:write"
]
}'Response
{
"success": true,
"data": {
"id": "key_123",
"name": "My API Key",
"key": "sk_live_...",
"created_at": "2024-01-09T20:00:00Z"
}
}Get All API Keys
List all API keys for the current user.
GET /api/api-keysCode Examples
curl --request GET \
--url 'https://your-domain.com/api/api-keys' \
--header 'x-api-key: YOUR_API_KEY' \
Response
{
"success": true,
"data": {
"keys": [
{
"id": "key_123",
"name": "My API Key",
"created_at": "2024-01-09T20:00:00Z",
"last_used_at": "2024-01-09T21:00:00Z"
}
]
}
}Create Call
Create a new call. This endpoint initiates a call to the specified phone number.
POST /api/calls/createRequest Body
contact_idrequiredstring - Contact IDphone_numberrequiredstring - Phone number in E.164 formatfrom_numberoptionalstring - Phone number to call from{
"contact_id": "contact_123",
"phone_number": "+1234567890",
"from_number": "+0987654321"
}Code Examples
curl --request POST \
--url 'https://your-domain.com/api/calls/create' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contact_id": "contact_123",
"phone_number": "+1234567890",
"from_number": "+0987654321"
}'Response
{
"success": true,
"data": {
"id": "call_123",
"status": "initiating",
"contact_id": "contact_123",
"phone_number": "+1234567890",
"created_at": "2024-01-09T20:00:00Z"
}
}Get All Calls
Retrieve a list of calls with optional filtering by status, contact, or date range.
GET /api/calls/listQuery Parameters
limitoptionalnumber - Number of results (default: 50, max: 5000)statusoptionalstring - Filter by call statuscontact_idoptionalstring - Filter by contact IDCode Examples
curl --request GET \
--url 'https://your-domain.com/api/calls/list?limit=50&status=completed' \
--header 'x-api-key: YOUR_API_KEY' \
Response
{
"success": true,
"data": {
"calls": [
{
"id": "call_123",
"status": "completed",
"contact_id": "contact_123",
"phone_number": "+1234567890",
"duration": 120,
"created_at": "2024-01-09T20:00:00Z"
}
],
"total": 1
}
}Response Format
All API responses follow a consistent format:
{
"success": true,
"data": { ... },
"error": null
}Error Codes
400 Bad RequestInvalid request parameters or missing required fields
401 UnauthorizedMissing or invalid API key
403 ForbiddenAPI key doesn't have required permissions
404 Not FoundResource not found
429 Too Many RequestsRate limit exceeded
500 Internal Server ErrorServer error - please try again later