API Errors¶
The INDstocks API uses conventional HTTP response codes to indicate the success or failure of a request. - 2xx codes indicate success. - 4xx codes indicate a client-side error (e.g., a malformed request, invalid authentication, or bad parameters). - 5xx codes indicate a server-side error.
In addition to the HTTP status code, all failed requests will return a JSON body with the following structure:
Error Response Format¶
JSON{
"status": "error",
"message": "A human-readable error message providing details about the error.",
"error_type": "TokenException"
}
¶
{
"status": "error",
"message": "A human-readable error message providing details about the error.",
"error_type": "TokenException"
}
General API Errors¶
These are common errors you may encounter across different API endpoints.
| Error Type | HTTP Status | Description |
|---|---|---|
InputException | 400 Bad Request | The request is invalid. This could be due to malformed JSON, missing parameters, or incorrect data types. The message field will have specifics. |
TokenException | 403 Forbidden | The provided access_token is invalid, expired, or has been revoked. The user must re-authenticate. |
UserException | 403 Forbidden | The authenticated user does not have permission to perform this action, possibly due to account status or missing segment activation. |
NotFoundException | 404 Not Found | The requested endpoint or resource (e.g., a specific order ID) could not be found. |
MethodNotAllowedException | 405 Method Not Allowed | An incorrect HTTP method was used for the endpoint (e.g., using GET when POST is required). |
DataException | 400 Bad Request | The request for market or historical data contained invalid parameters, such as an invalid timeframe or an incorrect instrument token. |
NetworkException | 503 Service Unavailable | A temporary issue reaching an upstream service, like an exchange. It is safe to retry the request after a short delay. |
GeneralException | 500 Internal Server Error | An unexpected error occurred on our servers. If you encounter this consistently, please report it. |
ServiceUnavailableException | 503 Service Unavailable | The API is temporarily down for maintenance or is overloaded. Please try again after a short while. |
GatewayTimeoutException | 504 Gateway Timeout | A timeout occurred while communicating with an upstream service (e.g., an exchange). It is safe to retry the request after a short delay. |
Order-Specific Errors¶
When an order is rejected, it typically returns an OrderException (400 Bad Request) with one of the following messages from our Risk Management System (RMS).
| Message | Description |
|---|---|
RMS: Margin exceeds ... | The order requires more margin than is available in the account. |
RMS: Rule: Check ... | A custom risk rule was triggered, preventing the order. |
RMS: Blocked for ... | The account or security is blocked for trading by the RMS team for surveillance reasons. |
The instrument is not tradable. | The specified security is not available for trading in the requested segment. |
The quantity is not a multiple of the lot size. | For F&O instruments, the order quantity must be a multiple of the lot size. |
The price is out of the circuit limit. | The order price is outside the security's daily upper or lower circuit limit. |
Order price must be a multiple of the tick size. | The order price is not a valid multiple of the instrument's minimum price movement (tick size). |
Market orders are blocked for this instrument. | Market orders are disabled for this security, often due to low liquidity. Use a limit order instead. |
The order quantity exceeds the freeze limit. | The order quantity is larger than the maximum allowed for a single order by the exchange. The order must be broken into smaller chunks. |
Position could not be found. | An attempt was made to modify or cancel an order that does not exist or has already been completed. |
The order is already pending... | The order has already been sent to the exchange and is awaiting confirmation, so it cannot be modified at this time. |