K
Guides

Error Handling

The API uses standard HTTP status codes to indicate success or failure. Errors include a JSON body with details.

Status codes

CodeMeaning
200Success
400Bad Request — invalid parameters
401Unauthorized — invalid or missing API key
404Not Found — resource does not exist
429Too Many Requests — rate limit exceeded
500Internal Server Error

Error response format

All errors return a consistent JSON structure:

json
{
  "error": {
    "code": "invalid_request",
    "message": "The 'name' field is required.",
    "details": {}
  }
}

Handling errors in code

python
import requests

response = requests.get("https://api.poyst.com/api/health")

if response.status_code == 200:
    data = response.json()
else:
    error = response.json().get("error", {})
    print(f"Error {response.status_code}: {error.get('message')}")