Skip to content

HTTP Return Codes

This document outlines the standardized HTTP response format, including HTTP status codes and error codes, used across the Habittrade REST and WebSocket API. These codes help developers and automated systems properly interpret responses, debug issues, and handle retry logic appropriately.


✅ 2XX Success

CodeMeaningDescription
200 OKSuccessRequest was processed successfully.
201 CreatedResource CreatedUsed for POST operations where a new object is created (e.g., an order).
204 No ContentSuccess, No BodySuccessful request, but no content is returned (e.g., successful DELETE).

⚠️ 4XX Client Errors (Your Side)

These codes indicate a problem with the request sent by the client.

CodeMeaningDescription
400 Bad RequestInvalid RequestMalformed request syntax or missing parameters.
401 UnauthorizedAuth FailureMissing or invalid authentication headers (e.g., signature, API key).
403 ForbiddenWAF Limit ViolationRequest blocked due to Web Application Firewall rules or IP blacklisting.
404 Not FoundResource Not FoundThe requested endpoint or object does not exist.
409 ConflictPartial SuccessReturned during cancelReplace: cancel fails but new order is accepted.
418 IP BannedBannedIP is temporarily auto-banned due to repeated 429 rate limit violations.
429 Too Many RequestsRate Limit ExceededRequest rate exceeded. Includes retry delay in Retry-After header.

🧱 5XX Server Errors (Habittrade Side)

These codes indicate an internal error on the Habittrade platform. They should not be treated as final failures. You should treat the order state as unknown and recheck via GET /orders/{id} or equivalent.

CodeMeaningDescription
500 Internal Server ErrorServer FaultGeneral error on the backend. Retry or confirm order state manually.
502 Bad GatewayUpstream ErrorOur backend or matching engine may be temporarily unavailable.
503 Service UnavailableDowntimeServer is under heavy load or in maintenance mode. Retry with backoff.
504 Gateway TimeoutTimeoutThe server did not receive a timely response from an upstream component.

🚧 Retry & Fallback Best Practices

ScenarioRecommendation
429 or 418Back off exponentially. Respect Retry-After header.
5XXRetry after 1-3 seconds. Use GET /orders/{id} to confirm state.
409Treat as partial success. You must check both order IDs.
Frequent 403Check if your IP is blocked by WAF. Contact support.

🚨 Error Codes

When an API request fails, the system returns a structured error message in the HTTP response body, which contains the following key fields:

  • code: Error code, please see the table below
  • message: Short error description message

Example:

json
{
  "code": 10010008,
  "message": "Signature verification failed"
}
Http StatusError codeMessageDescription
2XX0SuccessfulThe request was processed successfully without any errors.
40510010000Method Not AllowedThe HTTP method used in the request is not allowed, or used wrong ContentType
40010010001Invalid argument(s)One or more arguments provided in the request are invalid or missing.
40010010002The connection was not accepted because it is not a WebSocket requestThe connection attempt was rejected because it did not adhere to the WebSocket protocol requirements.
40010010004Authenticate failedAuthentication failed for an unspecified reason. Please check your credentials and Authentication process.
40110010005Missing required headersRequired authentication headers are missing from the request. Please check the necessary request headers in the Authentication process
40110010006Invalid timestampThe timestamp provided in the request is invalid or falls outside the acceptable time range.
40110010007Invalid API KeyThe API key provided is invalid or does not exist.
40110010008Signature verification failedThe signature provided does not match the expected signature for the request. Please check the Authentication process to ensure that each step complies with the rules.
40410010011Resource not foundTThe requested resource does not exist, or the request path is incorrect.
50010010012Internal server errorAn unexpected error occurred on the server while processing the request.
50010010013Internal server error, wrong http statusAn unexpected error occurred while processing the request on the server, resulting in an abnormal HTTP status being returned.
40110010015The client's IP address is not in the whitelistThe IP whitelist has been enabled, and the IP address currently being called is not in the whitelist.
42910010017Too many requestsRequests are too frequent or exceed the allocated entitlement quota.

🧪 Testing in UAT

In the UAT environment (https://api-uat.habittrade.com), certain error responses may be simulated for stress-testing your client error-handling logic. Refer to the testing section for details on how to trigger each error intentionally.