Response Format
This guide explains how the Audian API structures and returns responses.
Response Structure​
All API responses follow a consistent format:
{
"auth_token": "{AUTH_TOKEN}",
"data": { /* Resource data */ },
"request_id": "{REQUEST_ID}",
"status": "success"
}
Response Components​
- auth_token: Your authentication token (returned for convenience)
- data: The actual response content (varies by endpoint)
- request_id: Unique identifier for this request (useful for debugging)
- status: "success" or "error"
Successful Responses​
Single Resource​
{
"auth_token": "eyJhbGciOiJSUzI1...",
"data": {
"id": "user_abc123",
"username": "jsmith",
"first_name": "John",
"last_name": "Smith",
"email": "jsmith@example.com"
},
"request_id": "req_xyz789",
"status": "success"
}
List of Resources​
{
"auth_token": "eyJhbGciOiJSUzI1...",
"data": [
{
"id": "user_abc123",
"username": "jsmith",
"first_name": "John",
"last_name": "Smith"
},
{
"id": "user_def456",
"username": "jdoe",
"first_name": "Jane",
"last_name": "Doe"
}
],
"page_size": 25,
"next_start_key": "user_ghi789",
"request_id": "req_xyz789",
"status": "success"
}
Pagination Fields​
When listing resources:
- page_size: Number of items returned
- next_start_key: Key to use for fetching the next page (absent if no more pages)
- start_key: Key of the first item in current page
Status Codes Reference​
Success Codes (2xx)​
| Code | Meaning | Common Scenario |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created |
| 204 | No Content | Successful, empty response (DELETE) |
Client Error Codes (4xx)​
| Code | Meaning | Common Scenario |
|---|---|---|
| 400 | Bad Request | Invalid parameters |
| 401 | Unauthorized | Authentication failed |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource doesn't exist |
| 409 | Conflict | Resource conflict |
| 429 | Too Many Requests | Rate limited |
Server Error Codes (5xx)​
| Code | Meaning | Common Scenario |
|---|---|---|
| 500 | Server Error | Internal service error |
| 503 | Service Unavailable | Maintenance/outage |
Error Responses​
Standard Error Format​
{
"auth_token": "eyJhbGciOiJSUzI1...",
"data": {
"message": "invalid credentials"
},
"error": "401",
"message": "invalid_credentials",
"request_id": "req_error_123",
"status": "error"
}
401 Unauthorized​
{
"data": {
"message": "invalid credentials"
},
"error": "401",
"message": "invalid_credentials",
"status": "error"
}
404 Not Found​
{
"data": {
"message": "bad identifier"
},
"error": "404",
"message": "bad_identifier",
"status": "error"
}
400 Bad Request​
{
"data": {
"message": "validation failed",
"errors": {
"username": "is required"
}
},
"error": "400",
"status": "error"
}
Parsing Responses​
Python​
import requests
response = requests.get(
f'https://api.audian.com:8443/v2/accounts/{ACCOUNT_ID}/users',
headers={'X-Auth-Token': API_KEY}
)
data = response.json()
if data.get('status') == 'success':
users = data['data']
print(f"Found {len(users)} users")
else:
error = data.get('data', {}).get('message', 'Unknown error')
print(f"Error: {error}")
Node.js​
const response = await fetch(
`https://api.audian.com:8443/v2/accounts/${ACCOUNT_ID}/users`,
{
headers: { 'X-Auth-Token': API_KEY }
}
);
const json = await response.json();
if (json.status === 'success') {
const users = json.data;
console.log(`Found ${users.length} users`);
} else {
console.error(`Error: ${json.data?.message || 'Unknown error'}`);
}
Response Headers​
All responses include standard headers:
Content-Type: application/json
X-Request-ID: req_abc123
Empty Responses​
Some operations return empty success responses:
# Response for DELETE
HTTP/1.1 204 No Content
Or:
{
"auth_token": "eyJhbGciOiJSUzI1...",
"data": {},
"request_id": "req_delete_123",
"status": "success"
}
Best Practices​
Do's ✓​
- Always check the
statusfield first - Use
request_idwhen contacting support - Handle both success and error cases
- Parse timestamps correctly
- Check for
next_start_keyin list responses
Don'ts ✗​
- Don't assume HTTP status code equals API success
- Don't ignore error messages in the
datafield - Don't skip error handling
Next Steps​
- Request Format - Formatting requests
- Pagination - Managing results
- Filtering - Filter results