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
| Prefix | Service |
|---|---|
| AUT | Access Manager (authentication) |
| IDE | Access Manager (identity) |
| CRM | CRM |
| FEE | Fees Engine |
| PIX | PIX |
| BTF | Bank Transfer (TED) |
| TPL | Reporter |
| TRC | Tracer |
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:| Range | Category | Description |
|---|---|---|
0001–0099 | System and middleware | Authentication, authorization, headers, rate limiting |
0100–0999 | Service-specific | Validation, business logic, and domain errors within the plugin |
1000–1999 | External integration | Errors originating from external providers or upstream services |
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:
| Code | Meaning | Category |
|---|---|---|
400 | Bad Request | Validation error — fix the request |
401 | Unauthorized | Missing or invalid authentication credentials |
403 | Forbidden | Valid credentials but insufficient permissions |
404 | Not Found | The requested resource does not exist |
409 | Conflict | The operation conflicts with the current resource state |
422 | Unprocessable Entity | Valid syntax but violates business rules |
429 | Too Many Requests | Rate limit exceeded — wait and retry |
500 | Internal Server Error | Unexpected server failure — retry later |
502 | Bad Gateway | Upstream service returned an invalid response |
503 | Service Unavailable | Service temporarily unavailable — retry later |
504 | Gateway Timeout | Request timed out — retry later |
Retry guidance
Not all errors should be retried. The following table helps you decide:
| Error type | Retryable | Recommended action |
|---|---|---|
400 validation errors | No | Fix the request payload |
401 / 403 auth errors | No | Check credentials and permissions |
404 not found | No | Verify the resource ID |
409 conflicts | Sometimes | Check current state, then retry if the conflict is resolved |
422 business logic | No | Adjust the operation to comply with business rules |
429 rate limit | Yes | Wait for the retry window, then retry |
500 internal errors | Yes | Retry with exponential backoff |
502 / 503 / 504 | Yes | Retry with exponential backoff |
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:
| Service | Error list |
|---|---|
| Midaz | Midaz error list |
| Access Manager | Access Manager error list |
| CRM | CRM error list |
| Fees Engine | Fees Engine error list |
| PIX | PIX error list |
| Bank Transfer (TED) | TED error list |
| Reporter | Reporter error list |
| Tracer | Tracer error list |
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.

