Error codes

What ApiVault returns when a request fails, what each code means, and how to fix it.

Error format

The REST API returns a JSON body with a readable error message. Errors a program might want to handle also carry a stable code. Check the code rather than the message, which can change.

Error responseJSON
{
  "error": "That vault key is incorrect.",
  "code": "INVALID_VAULT_KEY"
}

The CLI prints the message, or the same object with --json, and exits with code 1.

HTTP status codes

StatusMeaning
400The request is missing something or is malformed
401No valid credential, or a vault key is needed
403The credential is valid but not allowed to do this
404Not found, or outside what this credential can see
409Conflicts with something that already exists
429Too many attempts; the Retry-After header says how many seconds to wait
500Something failed on our side; try again, then check the system status

Error codes

CodeStatusMeaningFix
VAULT_KEY_REQUIRED401The project uses custom encryption and no vault key was sentSend the vault key, or use --vault-key or APIVAULT_KEY in the CLI
INVALID_VAULT_KEY403The vault key is wrongSend the right one. Repeated failures lead to VAULT_KEY_RATE_LIMITED
VAULT_KEY_RATE_LIMITED429Too many wrong vault keysWait for the Retry-After delay. See attempt limits
DUPLICATE_KEY409A key with that name already exists in that environment; conflicts lists themUpdate the existing key, or use another name or environment
INSUFFICIENT_SCOPE403The token lacks the scope this needsCreate a token with that scope
PROJECT_MISMATCH403The request names a project other than the service token's ownRemove the project, or use that project's token
ENVIRONMENT_MISMATCH403The request names an environment other than the token's pinRemove the environment, or use a token for that one

Service token refusals

These responses carry only a message, with no code. The project's audit log records each one under the event type shown.

StatusMessageAudit eventFix
401This service token expired.SERVICE_TOKEN_EXPIREDCreate a new token
401This service token has been revoked.SERVICE_TOKEN_REVOKEDCreate a new token
403This service token is not allowed from this IP address.SERVICE_TOKEN_DENIED_IPUpdate the IP allowlist

A plain 401 Unauthorized means the value never matched a token at all, usually because of a truncated copy or a secret set on the wrong repository.

MCP tool errors

MCP tools use the same codes, plus UNAUTHORIZED, NOT_FOUND, VALIDATION and DECRYPT_FAILED. What an agent should do about each one is on MCP tools & scopes.