Skip to main content

API Guidelines

Complete reference for API response formats, status codes, and error handling.

Status Codes

CodeDescriptionError Code Constant
200SuccessOKAY
403Unauthorized - Invalid credentials or tokenUNAUTHORIZED
407Access DeniedACCESS_DENIED
435Insufficient Parameters - Missing required fieldsINSUFFICIENT_PARAMS
436Validation Error - Invalid parameter formatVALIDATION
437Not Found - Resource not foundNOT_FOUND
500Server Fault - Internal server errorSERVER_FAULT

Error Response Format

{
statusCode: number; // One of the status codes listed above
data: {
} // Empty object for error responses
message: string; // Error message or error code constant
}

Error Code Constants

The API uses the following error code constants in the message field:

  • OKAY - Request succeeded
  • UNAUTHORIZED - Authentication failed or invalid credentials
  • ACCESS_DENIED - User does not have permission to access the resource
  • INSUFFICIENT_PARAMS - Missing required parameters
  • ENTRY_NOT_FOUND - Requested resource not found
  • SERVER_FAULT - Internal server error

Example Error Responses

Insufficient Parameters (435)

{
statusCode: 435;
data: {
}
message: "Missing required fields: client_id, client_secret, fingerprint, user";
}

Unauthorized (403)

{
statusCode: 403;
data: {
}
message: "Invalid client credentials";
}

Validation Error (436)

{
statusCode: 436;
data: {
}
message: "1. Invalid email format in user.email, 2. Date must be in YYYY-MM-DD format in user.date_of_birth";
}

Not Found (437)

{
statusCode: 437;
data: {
}
message: "ENTRY_NOT_FOUND";
}

Server Fault (500)

{
statusCode: 500;
data: {
}
message: "SERVER_FAULT";
}

Token Format

All tokens are JWT (JSON Web Tokens) signed with a secret key. Tokens contain:

  • Header: Algorithm and token type
  • Payload: User information and claims
  • Signature: Cryptographic signature

Security Considerations

  1. HTTPS Only: Always use HTTPS in production
  2. Token Storage: Store tokens securely (not in localStorage for web)
  3. Client Credentials: Use client credentials for server-to-server auth