Skip to main content

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", "value"],
"msg": "Sensor value must be a finite number (not NaN or Infinity).",
"type": "value_error"
}
]
}
}

HTTP status codes

Success

CodeMeaningWhen
200 OKSuccessStandard successful response
201 CreatedResource createdA request that creates a resource
204 No ContentSuccess, no bodyDeletes, logout, and similar
207 Multi-StatusPartial successBatch ingestion with mixed results

Client errors

CodeMeaningCommon causes
400 Bad RequestInvalid requestMissing fields, malformed JSON
401 UnauthorizedAuthentication failedMissing, expired, or revoked token
403 ForbiddenNot permittedYour role cannot perform this operation
404 Not FoundResource not foundUnknown ID, or a resource you cannot access
409 ConflictConflicting stateDuplicate identifier, already acknowledged
422 Unprocessable EntityValidation errorThe request body fails schema validation
429 Too Many RequestsRate limitedSee Rate Limiting

Server errors

CodeMeaningAction
500 Internal Server ErrorUnexpected errorRetry; contact support if it persists
502 Bad GatewayUpstream dependency unavailableRetry after a short delay
503 Service UnavailableTemporarily unavailableRetry after a short delay

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.

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}")