Theme

Guides

Error handling

The Liveday API uses standard HTTP status codes to indicate the success or failure of a request.

HTTP status codes

CodeDescription
200OK - Request succeeded
400Bad Request - A parameter is invalid, or the page asked for is larger than 6 MB (see Page too large)
401Unauthorized - Missing or invalid API key
403Forbidden - API key lacks required scope
429Too Many Requests - Rate limit exceeded (60 req/min default)
500Internal 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 object whose message describes what went wrong:

{
  "error": {
    "message": "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.message}`)
  console.error(`Trace ID: ${body.trace_id}`)
}

Page too large

A page of transactions holds at most 1000 and must fit in a 6 MB response. When the page you ask for wouldn't fit, the API answers 400 instead of a cut-short page, and the message names a smaller size that fits:

{
  "error": {
    "message": "These 1000 transactions take 7.6 MB, more than the 5.9 MB a response can carry. Ask for fewer at a time: size=625 or less, moving from on by the number returned."
  },
  "trace_id": "abc123def456"
}

Ask again with that size, and move from on by the number of transactions each page returned. Pagination shows a loop that does this.

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.

Previous
Pagination