Error Response Format
All error responses follow a consistent JSON structure:Fields
Machine-readable error code (e.g.,
VALIDATION_ERROR, NOT_FOUND)Human-readable error description
Additional error context (validation errors, field-specific issues)
Error Codes
The API uses standard HTTP status codes along with application-specific error codes.400 Bad Request
Code:VALIDATION_ERROR
Request validation failed. The details field contains information about which fields failed validation.
Example:
- Missing required fields
- Invalid field types or formats
- Value out of acceptable range
- Invalid query parameters
401 Unauthorized
Code:UNAUTHORIZED
Authentication failed or is required.
Example:
- Missing
Authorizationheader - Invalid API key
- Deactivated merchant account
404 Not Found
Code:NOT_FOUND
The requested resource does not exist.
Example:
- Name not registered
- Proposal/transaction ID not found
- Payment request not found
- Merchant address not registered
409 Conflict
Code:CONFLICT
The request conflicts with existing data.
Example:
- Duplicate merchant hostname
- Name already registered (on-chain conflict)
500 Internal Server Error
Code:INTERNAL_ERROR or SUI_ERROR
An unexpected server error occurred.
Example:
- Database connection failure
- Sui RPC error
- On-chain transaction failure
- Service unavailability
Error Classes
The backend defines the following error classes (seeerrors/index.ts:1-47):
AppError
Base error class for all application errors.NotFoundError
Status: 404Code:
NOT_FOUND
Used when a requested resource does not exist.
ValidationError
Status: 400Code:
VALIDATION_ERROR
Used when request validation fails (invalid input).
AuthError
Status: 401Code:
UNAUTHORIZED
Used when authentication fails or is missing.
ConflictError
Status: 409Code:
CONFLICT
Used when the request conflicts with existing data.
SuiError
Status: 500Code:
SUI_ERROR
Used when Sui blockchain operations fail.
Domain-Specific Errors
Expired Proposals
When fetching an expired proposal via/intents/:txId:
Status: 400 Bad Request
Cancelled Proposals
Status:400 Bad Request
Expired Payment Requests
Status:400 Bad Request
Invalid Payment Request Status
Status:400 Bad Request
Handling Errors
Client-Side Error Handling
Validation Error Details
Validation errors include adetails field with the validation failure information from Zod:
Best Practices
Always check the HTTP status code first, then inspect the error code
Use the
details field for field-level validation errorsLog full error responses for debugging but show user-friendly messages to end users
Implement retry logic for
SUI_ERROR and INTERNAL_ERROR (transient failures)