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
201Created - Resource created successfully
400Bad Request - Invalid request body or parameters
401Unauthorized - Missing or invalid API key
403Forbidden - API key lacks required permissions
404Not Found - Resource does not exist
422Unprocessable Entity - Validation failed
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Something went wrong on our end

Error response format

All errors follow a consistent format:

{
  "error": {
    "code": "validation_error",
    "message": "The given data was invalid.",
    "details": [
      {
        "field": "name",
        "message": "The name field is required."
      }
    ]
  }
}

Handling errors

const response = await fetch('https://api.liveday.se/v1/events', {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
})

if (!response.ok) {
  const { error } = await response.json()
  console.error(`API Error: ${error.code} - ${error.message}`)
}

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