Errors
The envelope
Every failed request returns the same shape:
code is a stable identifier — branch on it, not on message, which is written
for humans and may be reworded. details is only present on validation errors.
Error codes
Two statuses fall outside that table because they come from specific endpoints
rather than the shared mapping: Minecraft routes return 502 when an upstream
service fails, and GET /v1/jobs/{id}/wait returns 504 when the
timeout elapsed before the job finished.
Validation errors
A missing or malformed parameter is a 422, and details lists each one. The
field is the Zod path joined with a dot, so it reads query.to,
path.guildId, or body.volume depending on where the parameter lives.
GET /v1/fun/roleplay is the exception: it answers 400 with
bad_request for validation failures, because it overrides the global handler.
Everything else is 422.
Success envelopes are not uniform
Most endpoints wrap their payload in data, but the wrapper differs by area:
Read the schema in the API reference rather than assuming a
shape. The JavaScript SDK hides this: it unwraps data for you and
resolves to the inner value.
Request IDs
Every response carries an X-Request-Id header, echoed from your request if you
sent one and generated otherwise. The same value appears as requestId in the
error body.
Send your own to correlate a failure with your logs:
Quote that id when reporting a problem — it is what makes the request findable in the logs.
Handling errors
The SDK turns every non-2xx response into an AegisError:
There is one error class, not a hierarchy — branch on status or code. See
SDK errors for the details.