Skip to main content

Error Handling

Vault returns errors as JSON with success: false and a message field. Use the HTTP status code and message to decide whether to retry, fix the request, or prompt the user.

Response format

{
  "success": false,
  "message": "Human-readable error message",
  "data": null
}

What to do by status

CodeMeaningWhat to do
400Bad RequestFix input (see message); don’t retry same body
401UnauthorizedCheck API key or JWT; re-auth if token expired
403ForbiddenCheck permissions or MFA
404Not FoundToken or resource doesn’t exist or was deleted
409ConflictResolve duplicate or state conflict
429Too Many RequestsBack off; use retry_after_seconds if present
5xxServer/upstream errorRetry with exponential backoff

Handling in code

Check response.ok or response.status, then parse the JSON and use data.success and data.message. For 5xx and 429, retry after a delay. For 4xx (except 429), fix the request or show the message to the user.

Full reference