What if an API call fails?
Robust error handling is just as important as calling the right endpoints. The Leafy Energy API uses standard HTTP status codes plus a structured JSON error body.
Common codes
- 400 Bad Request – invalid request (missing or malformed parameter).
- 401 Unauthorized – API key missing or invalid.
- 403 Forbidden – key not allowed to access this resource.
- 404 Not Found – resource does not exist or does not belong to this customer.
- 429 Too Many Requests – rate limit exceeded.
Example error response
{
"error": {
"code": "rate_limit_exceeded",
"message": "Too many requests. Please retry later.",
"retry_after_seconds": 30
}
}
In training scenarios you can deliberately trigger these errors to practise building resilient integrations.
Comments
0 comments
Please sign in to leave a comment.