Skip to main content

Error Handling

The Haltless API uses standard HTTP status codes and returns structured JSON error responses.

Error response format

{
"detail": "Human-readable error message."
}

For validation errors:

{
"detail": [
{
"loc": ["body", "email"],
"msg": "value is not a valid email address",
"type": "value_error"
}
]
}

HTTP status codes

Success codes

CodeMeaningWhen
200 OKSuccessStandard response for successful requests
201 CreatedResource createdPOST requests that create a new resource
204 No ContentSuccess with no bodyDELETE operations, logout
207 Multi-StatusPartial successBatch operations (e.g., ingestion)

Client error codes

CodeMeaningCommon causes
400 Bad RequestInvalid requestMissing fields, invalid JSON, constraint violations
401 UnauthorizedAuthentication failedMissing/expired token, revoked API key
402 Payment RequiredSubscription issueCanceled subscription, past grace period
403 ForbiddenInsufficient permissionsRole doesn't have access to this operation
404 Not FoundResource not foundInvalid ID, resource belongs to another tenant
409 ConflictDuplicate resourceEmail already exists, duplicate identifier
422 Unprocessable EntityValidation errorRequest body fails schema validation
429 Too Many RequestsRate limitedExceeded tier rate limit

Server error codes

CodeMeaningAction
500 Internal Server ErrorUnexpected errorContact support if persistent
503 Service UnavailableService downRetry after a short delay

Common error messages

Authentication

MessageCauseSolution
Invalid email or password.Wrong credentialsCheck email/password
Authentication token has expired.Expired JWTRefresh your token
Invalid authentication token.Malformed or revoked JWTRe-authenticate
User account is inactive.Account deactivatedContact your admin

Resources

MessageCauseSolution
Machine not found.Invalid machine IDVerify the UUID
A machine with this identifier already exists for this tenant.Duplicate identifierUse a unique machine_identifier
Tenant not found.Invalid tenant contextCheck your authentication

Rate limiting

MessageCauseSolution
Rate limit exceeded.Too many requestsWait for Retry-After seconds
Password verification failed. Sign-off requires re-authentication.Wrong password on compliance sign-offEnter the correct password

Handling errors in code

Python

import requests

response = requests.get(
"https://api.haltless.io/api/v1/machines",
headers={"Authorization": f"Bearer {token}"}
)

if response.status_code == 200:
machines = response.json()
elif response.status_code == 401:
# Token expired , refresh and retry
new_token = refresh_token()
response = requests.get(url, headers={"Authorization": f"Bearer {new_token}"})
elif response.status_code == 429:
retry_after = int(response.headers["Retry-After"])
time.sleep(retry_after)
# Retry the request
else:
error = response.json()
print(f"Error {response.status_code}: {error['detail']}")

TypeScript

async function apiRequest(url: string, token: string) {
const response = await fetch(url, {
headers: { Authorization: `Bearer ${token}` },
});

if (response.ok) {
return response.json();
}

if (response.status === 401) {
// Refresh token and retry
const newToken = await refreshToken();
return apiRequest(url, newToken);
}

if (response.status === 429) {
const retryAfter = parseInt(response.headers.get("Retry-After") || "5");
await new Promise((r) => setTimeout(r, retryAfter * 1000));
return apiRequest(url, token);
}

const error = await response.json();
throw new Error(`API error ${response.status}: ${error.detail}`);
}