Guides
Error handling
The Liveday API uses standard HTTP status codes to indicate the success or failure of a request.
HTTP status codes
| Code | Description |
|---|---|
200 | OK - Request succeeded |
401 | Unauthorized - Missing or invalid API key |
403 | Forbidden - API key lacks required scope |
500 | Internal Server Error - Something went wrong on our end |
Response format
Success
Successful responses include a data field and a trace_id:
{
"data": { ... },
"trace_id": "abc123def456"
}
Error
Error responses include an error field with a description:
{
"error": "Invalid or missing API key.",
"trace_id": "abc123def456"
}
Handling errors
const response = await fetch(
'https://api.liveday.se/analytics_search/api/transactions',
{ headers: { Authorization: 'Bearer sk_your_api_key' } }
)
if (!response.ok) {
const body = await response.json()
console.error(`API Error (${response.status}): ${body.error}`)
console.error(`Trace ID: ${body.trace_id}`)
}
Trace IDs
Every response includes a trace_id field. When contacting support about an error, include the trace ID — it helps us find the exact request in our logs.
Retry on 5xx errors
If you receive a 5xx error, it's safe to retry the request after a short delay. Use exponential backoff to avoid overwhelming the server.