Errors
Every error has the same shape, a stable machine-readable code and a request id. Branch on code, show message to people, and log request_id.
The error envelope#
422 Unprocessable Entity
{
"status": "error",
"error_type": "ValidationException",
"code": "invalid_signal",
"message": "Signal failed validation.",
"request_id": "req_5d1c0e9f3a7b4c2d8e6f1a0b",
"details": [
{"field": "price", "code": "price_required", "message": "price is required for LIMIT and SL orders."},
{"field": "product", "code": "product_not_allowed", "message": "CNC is for EQ only and NRML is for FUT, CE and PE only."}
]
}error_typegroups codes by HTTP status.RiskExceptionmarks a risk cap breach within422.codeis stable; new codes may be added. Treat an unknown code by its HTTP status.messageis for people and may change. Never parse it. It never repeats more than 40 characters of a value you sent.request_idis also in theX-Request-Idheader. Quote it to your MQuant desk contact.detailsis present only when it has entries. For validation errors each entry hasfield,codeandmessage, and, in a batch,index.
In a batch, field is prefixed with the item's position, and index gives it as a number:
422 from POST /api/v1/signals/batch
{
"status": "error",
"error_type": "ValidationException",
"code": "invalid_signal",
"message": "Signal failed validation.",
"request_id": "req_0a9b8c7d6e5f4a3b2c1d0e9f",
"details": [
{"index": 1, "field": "items[1].trigger_price", "code": "trigger_price_required", "message": "trigger_price is required for SL and SL-M orders."}
]
}HTTP statuses#
| HTTP | error_type | Retry? |
|---|---|---|
| 400 | InputException | No. Fix the request. |
| 401 | AuthenticationException | Only timestamp_out_of_window and nonce_reused, after fixing the clock or nonce. |
| 403 | PermissionException | No. Change the key or the address. |
| 404 | NotFoundException | No. |
| 405 | MethodException | No. |
| 409 | ConflictException | No. Read the existing signal. |
| 413, 415 | PayloadException | No. Fix the body. |
| 422 | ValidationException, RiskException | No. Fix the fields or the size. |
| 429 | RateLimitException | Yes, after Retry-After. |
| 500 | GeneralException | Yes, with backoff and the same client_signal_id. |
| 503 | ServiceUnavailableException | Yes, with backoff and the same client_signal_id. |
Error codes#
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
invalid_json | 400 InputException | The body is not UTF-8, not valid JSON, not a single object, or nested more than 4 levels. Also sent when Content-Length is not a number. | Fix the body. Build it with a JSON library, not by string concatenation. |
duplicate_json_key | 400 InputException | A key appears twice in one object. details[0].field names it. | Remove the duplicate. |
invalid_number | 400 InputException | NaN, Infinity, an exponent such as 1e3, or an integer longer than 15 digits. | Send plain numbers, or decimal strings for prices. |
invalid_query_param | 400 InputException | A list query parameter is unknown, repeated or invalid. details names it. | Use only the documented parameters, once each. |
invalid_cursor | 400 InputException | starting_after is not a signal you can see. | Use next_starting_after from the previous page. |
body_not_allowed | 400 InputException | A GET request has a body. | Send GET requests without a body, and sign the empty-body hash. |
auth_headers_invalid | 401 AuthenticationException | An X-MQ- header is missing, repeated or malformed. Common cause: a timestamp in seconds instead of milliseconds. | Check the four headers against the formats. |
timestamp_out_of_window | 401 AuthenticationException | The timestamp is more than 5,000 ms behind or 1,000 ms ahead of the server. The message includes the server time. | Sync your clock (NTP), or offset it with GET /api/v1/time, then retry with a new timestamp. |
auth_failed | 401 AuthenticationException | The signature does not verify: unknown or revoked key id, wrong secret, or a body, path or header that differs from what was signed. Deliberately the same response for every cause. | Compare your signing with the worked example. Do not retry in a loop: 20 failures in 15 minutes lock your IP. |
nonce_reused | 401 AuthenticationException | This nonce was already used with this key. | Generate a fresh nonce for every request, including retries. |
key_revoked | 401 AuthenticationException | Reserved. Revoking a key erases its secret, so requests from a revoked key get auth_failed instead. | Ask the desk for a new key. |
key_expired | 401 AuthenticationException | The key is past expires_at. | Ask the desk for a new key. Watch expires_at in GET /me to renew in time. |
key_suspended | 401 AuthenticationException | The desk has suspended the key. | Contact your MQuant desk contact. |
trader_inactive | 401 AuthenticationException | The trader account behind the key is not active. | Contact your MQuant desk contact. |
ip_not_allowed | 403 PermissionException | The request came from an address not on the key's allowlist. The message shows the address MQuant saw. | Send from an allowlisted address, or ask the desk to update the allowlist. |
scope_denied | 403 PermissionException | The key lacks the scope this endpoint needs. | Use a key with signals:write to send or cancel, signals:read to read. |
not_found | 404 NotFoundException | No such signal for this key's trader and mode, or no such path. Paths with a trailing slash are not found. | Check the id and the mode of the key. Remove trailing slashes. |
method_not_allowed | 405 MethodException | Wrong HTTP method for the path. The Allow header lists GET, POST. | Use the method from the reference. |
idempotency_conflict | 409 ConflictException | This client_signal_id was already used on this key for a different signal. details gives existing_signal_id. | For a new decision use a new id. For a retry, resend the original body unchanged. |
signal_not_cancellable | 409 ConflictException | The signal is already cancelled or rejected, or changed while being cancelled. | Read the signal to see its status. Retry only if the message asks you to. |
payload_too_large | 413 PayloadException | The body is over 16,384 bytes (65,536 for a batch). | Send fewer items or shorter notes. |
unsupported_media_type | 415 PayloadException | The body is not sent as application/json (charset utf-8 only), or it is compressed. | Set Content-Type: application/json and do not compress the body. |
invalid_signal | 422 ValidationException | One or more fields failed validation. details lists every problem, with index for batch items. | Fix each field listed. The id is not used up, so resend with the same client_signal_id. |
batch_too_large | 422 ValidationException | More items than 10 or than your key's signals_per_second. | Split the batch. |
duplicate_client_signal_id | 422 ValidationException | Two items in one batch share a client_signal_id. | Give every item its own id. |
max_quantity_exceeded | 422 RiskException | quantity is above the key's max_quantity. | Reduce the size, or ask the desk to review the cap. |
max_lots_exceeded | 422 RiskException | lots is above the key's max_lots. | Reduce the size, or ask the desk to review the cap. |
max_notional_exceeded | 422 RiskException | price × quantity is above the key's max_notional. | Reduce the size, or ask the desk to review the cap. |
rate_limited | 429 RateLimitException | A rate limit was hit: per key, per trader, desk-wide or per IP. | Wait Retry-After seconds, then retry. See Rate limits. |
key_temporarily_blocked | 429 RateLimitException | The key hit its limits repeatedly and is blocked for a while. | Stop sending until Retry-After has passed, then slow down. Only the desk can lift a block early. |
ip_temporarily_blocked | 429 RateLimitException | Your address hit the per-IP limit repeatedly and is blocked for a while. | Wait Retry-After seconds and reduce your request rate. |
auth_locked | 429 RateLimitException | 20 auth_failed responses from your address within 15 minutes. Your address is locked for 15 minutes; your key is not. | Fix the signing first. Then wait Retry-After seconds. |
internal_error | 500 GeneralException | Something failed inside MQuant. | Retry with backoff using the same client_signal_id. If it persists, send the request_id to the desk. |
api_disabled | 503 ServiceUnavailableException | The API is switched off, for example for maintenance. GET /time still answers. | Retry with backoff. |
intake_paused | 503 ServiceUnavailableException | The desk has paused new signals. Reads, dry runs and cancels still work. | Hold new signals or retry later. GET /me shows intake_paused. |
dependency_unavailable | 503 ServiceUnavailableException | MQuant cannot verify or count requests right now and refuses rather than guessing. | Retry with backoff using the same client_signal_id. |
Field detail codes#
These appear in details[].code of 422 invalid_signal. One response lists every problem found, so fix them all before resending.
| Detail code | Meaning |
|---|---|
unknown_field | A field the schema does not define, including server fields such as status. |
missing_field | A required field is absent or null. |
invalid_type | Wrong JSON type, for example a string for quantity, or a float or boolean for an integer. |
invalid_enum | Not one of the allowed values, for example "exchange": "NYSE" or a lower-case "buy". |
invalid_format | Does not match the pattern, for example a client_signal_id with a space, an expiry that is not a real YYYY-MM-DD date, or a malformed decimal string. |
out_of_range | Too small, too large, too long or too short, for example quantity: 0 or a 300-character note. |
forbidden_character | A control, bidirectional-override or surrogate character in a string. |
invalid_symbol | symbol is not 1 to 32 characters from A-Z 0-9 & _ - after upper-casing. |
segment_mismatch | segment does not match exchange. |
instrument_type_not_allowed | Equity on NFO, BFO or MCX, or a derivative on NSE or BSE. |
product_not_allowed | CNC on a derivative or NRML on equity. |
quantity_xor_lots | Both or neither of quantity and lots. |
lots_not_allowed_for_equity | lots on an EQ signal. |
price_required | price missing on LIMIT or SL. |
price_not_allowed | price sent on MARKET or SL-M. |
trigger_price_required | trigger_price missing on SL or SL-M. |
trigger_price_not_allowed | trigger_price sent on MARKET or LIMIT. |
trigger_price_inconsistent | On SL, a BUY trigger above the price or a SELL trigger below it. |
expiry_required | expiry missing on FUT, CE or PE. |
expiry_not_allowed | expiry sent on EQ. |
expiry_in_past | expiry is before today in IST. |
expiry_too_far | expiry is more than 1,830 days ahead. |
strike_required | strike missing on CE or PE. |
strike_not_allowed | strike sent on EQ or FUT. |
too_many_decimals | A price or strike with more than 2 decimal places. |