Error response model
All Lerian APIs return a structured error object for every error. The format is consistent across all services:
code: A unique, stable identifier for the error. Use this field for programmatic error handling.title: A brief summary of the issue.message: Detailed, human-readable guidance for resolving the error.
Field-level error details
When an error relates to specific fields in the request payload, the response includes afields object with granular details:
Error code structure
Every error code follows a standardized format that identifies both the service and the specific error:
- PREFIX (3 letters): Identifies the service or plugin that produced the error.
- NNNN (4 digits): A unique number within that service.
Service prefixes
Midaz core uses numeric-only codes (e.g.,
0002, 0009) without a prefix. All other services include their 3-letter prefix.Number ranges
Error codes are organized into ranges that indicate the error’s origin:
This structure allows you to quickly identify whether an error comes from your request (low numbers), the service’s business logic (mid-range), or an external dependency (1000+).
Error classification
Understanding the type of error helps you decide how to respond. Lerian errors fall into three categories:
Validation errors
Errors caused by incorrect or missing input in the request. Characteristics:- HTTP status
400(Bad Request) - Include a
fieldsobject when specific fields are at fault - Always preventable by validating input before sending
fields object for specifics. Correct the input and retry.
Business logic errors
Errors caused by operations that violate domain rules or resource state constraints. Characteristics:- HTTP status
404(Not Found),409(Conflict), or422(Unprocessable Entity) - Indicate that the request is syntactically valid but cannot be processed
System errors
Errors caused by infrastructure issues, timeouts, or unexpected failures. Characteristics:- HTTP status
500(Internal Server Error),502(Bad Gateway),503(Service Unavailable), or504(Gateway Timeout) - Not caused by your input — the same request may succeed later
HTTP status codes
Lerian APIs use a focused set of HTTP status codes:
Retry guidance
Not all errors should be retried. The following table helps you decide:
Exponential backoff strategy
For retryable errors, use exponential backoff to avoid overwhelming the service:- First retry: Wait 1 second
- Second retry: Wait 2 seconds
- Third retry: Wait 4 seconds
- Maximum retries: Stop after 3–5 attempts
- Jitter: Add a small random delay (0–500ms) to each wait to prevent thundering herd
Troubleshooting by category
Missing or invalid fields (400)
Most400 errors include a fields object that tells you exactly which fields need attention.
Common causes:
- Required field omitted from the request body
- Field value does not match the expected type (e.g., string instead of UUID)
- Field value exceeds maximum length
- Unexpected extra fields in the request body
- Read the
fieldsobject in the error response - Compare your request against the API reference for that endpoint
- Verify field names use
lowerCamelCase(notsnake_case) - Verify dates use ISO 8601 format with
Zsuffix - Verify UUIDs are valid v4 format
Authentication and authorization (401/403)
Common causes:- Missing
Authorizationheader - Expired or revoked token
- Token does not grant access to the requested endpoint
- Confirm that Access Manager is enabled in your environment
- Verify the token is present in the
Authorizationheader - Request a new token if the current one has expired
- Check that the token’s scope includes the required permissions
Resource not found (404)
Common causes:- Incorrect resource ID in the URL path
- Resource was soft-deleted
- Resource belongs to a different organization or ledger
- Verify the ID format (must be a valid UUID)
- List resources to confirm the ID exists
- Check that you are using the correct
organizationIdandledgerIdpath parameters
Conflict errors (409)
Common causes:- Creating a resource with a name that already exists (e.g., duplicate ledger name, duplicate rule name)
- Attempting an operation that has already been completed (e.g., duplicate transaction)
- Read the error message to identify which field caused the conflict
- Use a different value (e.g., rename) or retrieve the existing resource instead
- For idempotent operations, verify the existing resource matches your intent
Rate limiting (429)
Common causes:- Too many requests in a short period
- Implement exponential backoff with jitter
- Reduce the frequency of API calls
- Batch operations where possible
Server and timeout errors (500/502/503/504)
Common causes:- Temporary service disruption
- High load on the platform
- Upstream dependency unavailable
- Retry with exponential backoff (1s, 2s, 4s)
- If the error persists after 3–5 retries, contact support
- Log the full error response (including
code) for support escalation
Service-specific error lists
Each Lerian service publishes a complete list of its error codes. Use these references to look up specific error codes:
Best practices
1. Use error codes for programmatic handling
Error codes are stable identifiers designed for automation. Map specific codes to resolution paths in your integration:2. Log errors with context
Include the full error response, the request that triggered it, and the timestamp. This makes support escalation faster and debugging more effective.3. Handle field-level errors
When the response includes afields object, surface those specific messages to your users rather than showing a generic error.
4. Implement circuit breakers for integrations
If you receive repeated500, 502, or 503 errors, use a circuit breaker pattern to temporarily stop calling the failing service and prevent cascading failures.

