Skip to main content

Response Codes

Response Format​

All API responses follow a consistent format:

{
"version": null,
"statusCode": 200,
"messages": [
"Processed successfully"
],
"result": {
// Response data
}
}

HTTP Status Codes​

Success Codes (2xx)​

CodeDescriptionUsage
200OKRequest succeeded
201CreatedResource successfully created
204No ContentRequest succeeded with no response body

Client Error Codes (4xx)​

CodeDescriptionCommon CausesResolution
400Bad RequestInvalid inputCheck request format and parameters
401UnauthorizedInvalid/missing tokenRefresh authentication token
403ForbiddenInsufficient permissionsCheck access rights
404Not FoundResource doesn't existVerify resource ID
409ConflictResource conflictCheck existing resources
429Too Many RequestsRate limit exceededImplement backoff strategy

Server Error Codes (5xx)​

CodeDescriptionAction
500Internal Server ErrorContact support
502Bad GatewayRetry request
503Service UnavailableCheck service status
504Gateway TimeoutRetry with backoff

Business Error Codes​

Authentication Errors (AUTH)​

CodeMessageCauseResolution
AUTH001Invalid credentialsWrong appId/appSecretCheck credentials
AUTH002Token expiredJWT token expiredRequest new token
AUTH003Invalid token formatMalformed JWTCheck token format
AUTH004Missing tokenNo Authorization headerInclude token

Validation Errors (VAL)​

CodeMessageCauseResolution
VAL001Missing required fieldRequired field not providedInclude field
VAL002Invalid field formatWrong data formatCheck format
VAL003Invalid field lengthField too long/shortAdjust length
VAL004Invalid enum valueValue not in allowed setCheck valid values

Business Logic Errors (BUS)​

CodeMessageCauseResolution
BUS001Invalid state transitionInvalid workflow stepCheck workflow
BUS002Duplicate entityEntity already existsCheck existing
BUS003Entity not foundInvalid IDVerify ID
BUS004Operation not allowedBusiness rule violationCheck rules

Document Errors (DOC)​

CodeMessageCauseResolution
DOC001Invalid document typeUnsupported formatCheck formats
DOC002Document expiredDocument out of dateProvide current
DOC003Poor image qualityLow resolution/blurImprove quality
DOC004Missing documentRequired doc not foundUpload document

Error Response Examples​

Validation Error​

{
"version": null,
"statusCode": 400,
"messages": [
"VAL001: Required field 'email' is missing"
],
"result": null
}

Authentication Error​

{
"version": null,
"statusCode": 401,
"messages": [
"AUTH002: Token has expired"
],
"result": null
}

Business Logic Error​

{
"version": null,
"statusCode": 409,
"messages": [
"BUS002: Customer with email already exists"
],
"result": null
}

Error Handling Best Practices​

  1. Check Status Code First
if (response.statusCode >= 400) {
handleError(response);
}
  1. Parse Error Messages
function parseErrorCode(message: string): string {
const match = message.match(/^([A-Z]+\d+):/);
return match ? match[1] : 'UNKNOWN';
}
  1. Implement Retry Logic
async function retryRequest(fn: Function, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (!isRetryableError(error) || i === maxRetries - 1) {
throw error;
}
await delay(Math.pow(2, i) * 1000);
}
}
}
  1. Handle Rate Limits
function handleRateLimit(response) {
if (response.statusCode === 429) {
const retryAfter = response.headers['retry-after'];
return new Promise(resolve => {
setTimeout(resolve, (parseInt(retryAfter) || 60) * 1000);
});
}
}