Skip to main content

Error Handling

All Lampay API responses -- whether successful or not -- follow a consistent envelope format. This page documents the response structure, HTTP status code conventions, and the complete error code catalog organized by domain.

Response Envelope

Every response from the Lampay API is wrapped in a standard envelope with metadata fields.

Successful Response

200Success
{
"version": "1.3.0",
"timestamp": 1709337600000,
"success": true,
"code": "2000",
"message": "SUCCESS",
"data": {
"transferId": "txn_789xyz",
"status": "COMPLETED",
"amount": "100.00",
"currency": "USD"
}
}

Error Response

400Error
{
"version": "1.3.0",
"timestamp": 1709337600000,
"success": false,
"code": "T1007",
"message": "INVALID_AMOUNT",
"data": null
}

Envelope Fields

FieldTypeDescription
versionstringAPI version (e.g., 1.3.0)
timestamplongResponse timestamp in epoch milliseconds
successbooleantrue for successful operations, false for errors
codestringMachine-readable result code. 2xxx = success, domain-prefixed codes = error
messagestringHuman-readable result description
dataobject / nullResponse payload on success; always null on error
Programmatic error handling

Always check the success field first. When success is false, use the code field for programmatic handling (e.g., retry logic, user-facing messages). The message field is informational and may change between API versions -- do not parse it programmatically.


HTTP Status Codes

The Lampay API uses standard HTTP status codes. The table below lists all codes you may encounter:

CodeMeaningWhen Returned
200OKRequest succeeded, response body contains the result
201CreatedA new resource was created successfully
204No ContentRequest succeeded, no response body (e.g., DELETE operations)
400Bad RequestValidation error, invalid parameters, or business rule violation
401UnauthorizedMissing or invalid authentication (bad API key, signature mismatch, timestamp expired)
403ForbiddenAuthentication succeeded but the caller lacks permission for this operation
404Not FoundThe requested resource does not exist
409ConflictResource already exists or the operation conflicts with current state
429Too Many RequestsRate limit exceeded -- wait and retry
500Internal Server ErrorUnexpected server error -- contact support if persistent

Error Code Catalog

Error codes use a domain prefix followed by a numeric identifier. The prefix tells you which module generated the error; the full code uniquely identifies the error condition.

S -- System / Infrastructure

General system-level errors that can occur on any endpoint.

CodeNameHTTPDescription
S001INTERNAL_ERROR500Unexpected internal error. Contact support if this persists.
S002SERVICE_UNAVAILABLE503A dependent service is unavailable. Retry after a brief delay.
S003TIMEOUT504The operation timed out. The request may or may not have been processed.
S004INVALID_REQUEST400The request is malformed (e.g., invalid JSON syntax).
S005UNAUTHORIZED401Authentication is required but was not provided.
S006FORBIDDEN403Access denied. The caller does not have the required role or permission.
S007NOT_FOUND404The requested resource was not found.
S011VALIDATION_ERROR400One or more request fields failed validation.
S012INVALID_PARAMETER400A parameter value is invalid (wrong type, out of range, etc.).
S013MISSING_PARAMETER400A required parameter is missing from the request.
S031DATA_NOT_FOUND404The requested data record was not found in the database.
S032DATA_ALREADY_EXISTS409A record with the same unique key already exists.
S034CONCURRENT_MODIFICATION409Optimistic lock conflict. Another operation modified this resource concurrently. Retry.

W -- Wallet

Errors from wallet account and balance operations.

CodeNameHTTPDescription
W1001ACCOUNT_NOT_FOUND404The wallet account was not found.
W1002ACCOUNT_INACTIVE400The wallet account is not active. Activate it before performing operations.
W1003ACCOUNT_FROZEN400The wallet account is frozen. Contact an administrator.
W1004ACCOUNT_ALREADY_EXISTS409A wallet account with this identity already exists.
W3001INSUFFICIENT_BALANCE400The wallet does not have sufficient balance for this operation.
W3003INSUFFICIENT_AVAILABLE400The available balance (excluding holds) is insufficient.
W3005OPTIMISTIC_LOCK_CONFLICT409A concurrent modification was detected on the wallet balance. Retry the operation.
W5005CURRENCY_NOT_SUPPORTED400The specified currency is not supported by this wallet.
W9004MISSING_WORKSPACE_CONTEXT401The workspace context is missing. Ensure the API key is associated with a workspace.

T -- Transfer

Errors from transfer creation and processing.

CodeNameHTTPDescription
T1001SOURCE_WALLET_NOT_FOUND404The source wallet was not found.
T1002TARGET_WALLET_NOT_FOUND404The target wallet was not found.
T1005CURRENCY_MISMATCH400The source and target wallets use different currencies.
T1006SAME_WALLET_TRANSFER400Cannot transfer funds to the same wallet.
T1007INVALID_AMOUNT400The transfer amount must be positive.
T1008INSUFFICIENT_BALANCE400The source wallet does not have sufficient balance.
T1020ORDER_NOT_FOUND404The transfer order was not found.
T1023DUPLICATE_REQUEST409A transfer with this idempotency key has already been processed.
T1040EXECUTION_FAILED500The transfer execution failed. The funds were not moved.
T1044TARIFF_NOT_CONFIGURED400The wallet tariff (fee schedule) is not configured. Contact an administrator.

GA -- Gateway Auth

Errors from the API gateway authentication pipeline. See HMAC Authentication for the full validation pipeline.

CodeNameHTTPDescription
GA2001API_KEY_REQUIRED401The X-Api-Key header is missing.
GA2002SIGNATURE_REQUIRED401The X-Signature header is missing.
GA2011API_KEY_INVALID401The API key is invalid or was not found.
GA2012SIGNATURE_INVALID401Signature verification failed.
GA2013TIMESTAMP_EXPIRED401The request timestamp is outside the 60-second window.
GA2021API_KEY_DISABLED403The API key has been disabled.
GA2022IP_NOT_ALLOWED403The client IP is not in the whitelist.
GA2024SCOPE_DENIED403The API key lacks the required scope.
GA2032WORKSPACE_NOT_FOUND404The workspace was not found.
GA2034WORKSPACE_NOT_MEMBER403The user is not a member of the workspace.

Error Handling Best Practices

Retry strategy

For 5xx errors and 429 (rate limit), implement exponential backoff with jitter. Start with a 1-second delay, double on each retry, and add random jitter to avoid thundering herd. Set a maximum of 3-5 retries.

Idempotency

For POST operations that create resources, use an idempotency key. If a request fails with a network error and you retry, the idempotency key prevents duplicate creation. A T1023 (DUPLICATE_REQUEST) response means your original request was processed successfully.

User-facing messages

Map error codes to user-friendly messages in your application. Do not display raw error codes or the message field to end users -- they are intended for developers. Build a translation layer that converts codes like W3001 into messages like "Insufficient funds to complete this transfer."

Logging

Log the full response envelope (including code, message, and timestamp) for every error. The timestamp field helps correlate client-side errors with server-side logs when working with Lampay support.