Authentication API
The Authentication API allows you to manage API keys for accessing Cue's ad serving endpoints.
Create API Key
Create a new API key for your account.
POST /api/v1/auth/api-keys
Headers
Content-Type: application/json
x-user-id: your-user-id
Request Body
{
"name": "My App API Key"
}
Response
{
"id": "api-key-123",
"name": "My App API Key",
"key": "cue_live_abcd1234...",
"isActive": true,
"createdAt": "2024-01-15T10:30:00Z",
"lastUsedAt": null,
"requestCount": 0
}
Example
curl -X POST https://app.oncue.ad/api/v1/auth/api-keys \
-H "Content-Type: application/json" \
-H "x-user-id: user-123" \
-d '{
"name": "My App API Key"
}'
const response = await fetch('https://app.oncue.ad/api/v1/auth/api-keys', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-user-id': 'user-123'
},
body: JSON.stringify({
name: 'My App API Key'
})
});
const apiKey = await response.json();
List API Keys
Get all API keys for your account.
GET /api/v1/auth/api-keys
Headers
x-user-id: your-user-id
Response
[
{
"id": "api-key-123",
"name": "My App API Key",
"key": "cue_live_abcd1234...",
"isActive": true,
"createdAt": "2024-01-15T10:30:00Z",
"lastUsedAt": "2024-01-15T11:45:00Z",
"requestCount": 142
},
{
"id": "api-key-456",
"name": "Test API Key",
"key": "cue_test_efgh5678...",
"isActive": false,
"createdAt": "2024-01-10T09:15:00Z",
"lastUsedAt": "2024-01-12T14:20:00Z",
"requestCount": 23
}
]
Example
curl -X GET https://app.oncue.ad/api/v1/auth/api-keys \
-H "x-user-id: user-123"
const response = await fetch('https://app.oncue.ad/api/v1/auth/api-keys', {
headers: {
'x-user-id': 'user-123'
}
});
const apiKeys = await response.json();
Delete API Key
Delete an API key. This action cannot be undone.
DELETE /api/v1/auth/api-keys/:id
Headers
x-user-id: your-user-id
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The API key ID |
Response
{
"message": "API key deleted successfully"
}
Example
curl -X DELETE https://app.oncue.ad/api/v1/auth/api-keys/api-key-123 \
-H "x-user-id: user-123"
const response = await fetch('https://api.oncue.ad/api/v1/auth/api-keys/api-key-123', {
method: 'DELETE',
headers: {
'x-user-id': 'user-123'
}
});
const result = await response.json();
Toggle API Key Status
Enable or disable an API key.
PATCH /api/v1/auth/api-keys/:id/toggle
Headers
x-user-id: your-user-id
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The API key ID |
Response
{
"id": "api-key-123",
"name": "My App API Key",
"key": "cue_live_abcd1234...",
"isActive": false,
"createdAt": "2024-01-15T10:30:00Z",
"lastUsedAt": "2024-01-15T11:45:00Z",
"requestCount": 142
}
Example
curl -X PATCH https://app.oncue.ad/api/v1/auth/api-keys/api-key-123/toggle \
-H "x-user-id: user-123"
const response = await fetch('https://api.oncue.ad/api/v1/auth/api-keys/api-key-123/toggle', {
method: 'PATCH',
headers: {
'x-user-id': 'user-123'
}
});
const apiKey = await response.json();
Error Responses
Common error responses for authentication endpoints:
400 Bad Request
{
"error": "Validation failed",
"message": "API key name is required",
"statusCode": 400
}
401 Unauthorized
{
"error": "Unauthorized",
"message": "User ID is required",
"statusCode": 401
}
404 Not Found
{
"error": "Not found",
"message": "API key not found",
"statusCode": 404
}
429 Too Many Requests
{
"error": "Rate limit exceeded",
"message": "Too many requests, please try again later",
"statusCode": 429
}