Errors
The Haltless API uses standard HTTP status codes and returns structured JSON error bodies.
Error response shape
Most errors return a single human-readable message:
{
"detail": "Machine not found."
}
Some errors return a structured body with a machine-readable error_code:
{
"error_code": "VALIDATION_ERROR",
"message": "Request validation failed.",
"details": {
"errors": [
{
"loc": ["body", "readings", 0, "value"],
"msg": "Value error, Sensor value must be a finite number (not NaN or Infinity).",
"type": "value_error"
}
]
}
}
Read detail first and fall back to message. Branch on error_code where one is present rather than on the message text, which may change.
HTTP status codes
Success
| Code | Meaning | When |
|---|---|---|
200 OK | Success | Standard successful response |
201 Created | Resource created | A request that creates a resource |
204 No Content | Success, no body | Deletes, logout, and similar |
207 Multi-Status | Partial success | Batch ingestion with mixed results |
Client errors
| Code | Meaning | Common causes |
|---|---|---|
400 Bad Request | The request cannot be done | An expired or used link, an unsupported combination, a wrong confirmation code. Missing fields and malformed JSON return 422 |
401 Unauthorized | Authentication failed | Missing, expired, or revoked token or API key |
402 Payment Required | Company suspended | Edge-agent API key used while your company's account is suspended (see below) |
403 Forbidden | Not permitted | Your role cannot perform this operation, your email is not verified yet, your password has expired (see below), the portal's security check did not pass (error_code TURNSTILE_FAILED), or a Haltless administrator is impersonating you and the action would change credentials, access or the AI provider |
404 Not Found | Resource not found | Unknown ID, or a resource you cannot access |
409 Conflict | Conflicting state | Duplicate identifier, already acknowledged |
413 Content Too Large | Request too large | A request body over 10 MB |
422 Unprocessable Entity | Validation error | The request body fails schema validation |
423 Locked | Company suspended | Signing in while your company's account is suspended |
429 Too Many Requests | Rate limited | See Rate Limiting. Also returned while an account is locked after repeated failed sign-ins |
Server errors
| Code | Meaning | Action |
|---|---|---|
500 Internal Server Error | Unexpected error | Retry; contact support if it persists |
502 Bad Gateway | Upstream dependency unavailable | Retry after a short delay |
503 Service Unavailable | Temporarily unavailable | Retry after a short delay |
504 Gateway Timeout | The request took longer than 110 seconds | Retry; narrow the request (for example a shorter time range) if it keeps happening |
Validation errors
A 422 response lists each field that failed validation under details.errors. Each entry names the field location (loc), a message (msg), and an error type. Fix the flagged fields and resubmit.
For POST /api/v1/ingest, one invalid reading (a non-finite value, a missing unit, a timestamp out of range) fails the whole request with 422, and nothing in it is stored. loc gives the reading's position in the readings array. A reading that is valid but names a System Haltless does not know is different: the rest of the batch is stored, and that reading is reported in the 207 response. See Sensor Data.
Company suspended
While a platform administrator has suspended your company's account:
- Signing in returns
423 Locked. - Requests with an existing access token or a service-account key return
403 Forbidden. - Edge-agent API keys get
402 Payment Requiredon/api/v1/ingestand/api/v1/agent/heartbeat. The body tells the agent when to check again; the Edge Agent pauses collection and resumes by itself once the account is reinstated.
{
"detail": {
"error_code": "TENANT_SUSPENDED",
"message": "This company account has been suspended. Contact your administrator for help.",
"next_check_seconds": 300
}
}
Password expired
Passwords expire after 90 days. Until the user sets a new one, requests made with their access token return 403 with this body (changing the password is still allowed):
{
"error_code": "AUTH_PASSWORD_EXPIRED",
"message": "Your password has expired. Please set a new one to continue.",
"change_password_url": "/settings#change-password"
}
Timeouts
A request that runs past 110 seconds returns 504 with {"error_code": "GATEWAY_TIMEOUT", "message": "The server took too long to process the request. Please try again."}.
Request IDs
Every response carries an X-Request-ID header. You can send your own: up to 128 letters, digits, ., _, : and -. Anything else is replaced by an ID Haltless generates, and the request still goes through. Quote the ID when you contact support.
Handling errors in code
import requests
response = requests.get(
"https://api.haltless.io/api/v1/machines",
headers={"Authorization": f"Bearer {token}"},
)
if response.ok:
machines = response.json()
elif response.status_code == 401:
token = refresh_token()
# retry with the new token
elif response.status_code == 429:
retry_after = int(response.headers.get("Retry-After", "5"))
time.sleep(retry_after)
# retry the request
else:
error = response.json()
message = error.get("detail") or error.get("message")
print(f"Error {response.status_code}: {message}")