Skip to main content
Every error response from the InfraAudit API follows a consistent JSON structure so you can handle errors programmatically regardless of the endpoint.

Error response format

{
  "error": "resource not found",
  "code": "NOT_FOUND",
  "details": "drift with id 99 does not exist"
}
error
string
required
A human-readable message describing what went wrong. Suitable for logging but not for display to end users.
code
string
A machine-readable error code. Use this field for programmatic error handling. May be absent on some error types.
details
string
Additional context about the error, such as which field failed validation or which resource was not found. Optional.

HTTP status codes

StatusWhen it is returned
200 OKRequest succeeded.
201 CreatedResource was created successfully.
204 No ContentRequest succeeded with no response body (typical for DELETE).
400 Bad RequestMalformed JSON, missing required fields, or invalid parameter values.
401 UnauthorizedMissing, expired, or invalid auth token.
403 ForbiddenToken is valid but the user lacks permission.
404 Not FoundThe requested resource does not exist.
409 ConflictState conflict — for example, trying to connect a provider that is already connected.
422 Unprocessable EntityRequest is valid JSON but fails business-logic validation.
429 Too Many RequestsRate limit exceeded. See Rate limiting.
500 Internal Server ErrorUnexpected server-side error.

Handling errors

response=$(curl -s -w "\n%{http_code}" \
  https://api.infraaudit.dev/v1/drifts/99 \
  -H "Authorization: Bearer $TOKEN")

http_code=$(echo "$response" | tail -1)
body=$(echo "$response" | head -1)

if [ "$http_code" -ne 200 ]; then
  echo "Error $http_code: $(echo $body | jq -r '.error')"
fi

Common error codes

CodeHTTP statusMeaning
NOT_FOUND404The resource ID does not exist.
UNAUTHORIZED401Token missing or invalid.
FORBIDDEN403Insufficient permissions.
VALIDATION_ERROR422A field failed business-logic validation.
CONFLICT409Resource already exists or is in a conflicting state.
RATE_LIMITED429Too many requests. Check retryAfter in the response body.
The code field is not present on all error responses. Always fall back to the HTTP status code for error handling.