Error envelope
Errors come back as a NestJS error object.message is an array of field-level messages instead of
a string. Handle both shapes.
Status codes
A Retry it with backoff. Every other status returns all three fields.
500 is the one response that does not carry an error field — NestJS’s default handler
returns only statusCode and message:Reading a 403
403 covers three different situations, separated only by the message.
Endpoints that report failure in the body
Two endpoints return a success status with a failure payload. Branch on the body, not the status code.POST /domains — duplicate domains
POST /domains — duplicate domains
A domain already registered by another account returns
201 with domainId: null and an
error string. Check domainId before treating the call as a success.POST /domains/{id}/verify — DNS not ready
POST /domains/{id}/verify — DNS not ready
A failed CNAME check returns
200 with verified: false and the cnameTarget to publish.
Branch on verified.Handling errors
5xx responses and network timeouts with exponential backoff and jitter. Never retry a 4xx
— the request itself is the problem.