MQuant Developers v1
Open MQuant

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_type groups codes by HTTP status. RiskException marks a risk cap breach within 422.
  • code is stable; new codes may be added. Treat an unknown code by its HTTP status.
  • message is for people and may change. Never parse it. It never repeats more than 40 characters of a value you sent.
  • request_id is also in the X-Request-Id header. Quote it to your MQuant desk contact.
  • details is present only when it has entries. For validation errors each entry has field, code and message, 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#

HTTPerror_typeRetry?
400InputExceptionNo. Fix the request.
401AuthenticationExceptionOnly timestamp_out_of_window and nonce_reused, after fixing the clock or nonce.
403PermissionExceptionNo. Change the key or the address.
404NotFoundExceptionNo.
405MethodExceptionNo.
409ConflictExceptionNo. Read the existing signal.
413, 415PayloadExceptionNo. Fix the body.
422ValidationException, RiskExceptionNo. Fix the fields or the size.
429RateLimitExceptionYes, after Retry-After.
500GeneralExceptionYes, with backoff and the same client_signal_id.
503ServiceUnavailableExceptionYes, with backoff and the same client_signal_id.

Error codes#

CodeHTTPMeaningWhat to do
invalid_json400
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_key400
InputException
A key appears twice in one object. details[0].field names it.Remove the duplicate.
invalid_number400
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_param400
InputException
A list query parameter is unknown, repeated or invalid. details names it.Use only the documented parameters, once each.
invalid_cursor400
InputException
starting_after is not a signal you can see.Use next_starting_after from the previous page.
body_not_allowed400
InputException
A GET request has a body.Send GET requests without a body, and sign the empty-body hash.
auth_headers_invalid401
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_window401
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_failed401
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_reused401
AuthenticationException
This nonce was already used with this key.Generate a fresh nonce for every request, including retries.
key_revoked401
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_expired401
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_suspended401
AuthenticationException
The desk has suspended the key.Contact your MQuant desk contact.
trader_inactive401
AuthenticationException
The trader account behind the key is not active.Contact your MQuant desk contact.
ip_not_allowed403
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_denied403
PermissionException
The key lacks the scope this endpoint needs.Use a key with signals:write to send or cancel, signals:read to read.
not_found404
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_allowed405
MethodException
Wrong HTTP method for the path. The Allow header lists GET, POST.Use the method from the reference.
idempotency_conflict409
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_cancellable409
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_large413
PayloadException
The body is over 16,384 bytes (65,536 for a batch).Send fewer items or shorter notes.
unsupported_media_type415
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_signal422
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_large422
ValidationException
More items than 10 or than your key's signals_per_second.Split the batch.
duplicate_client_signal_id422
ValidationException
Two items in one batch share a client_signal_id.Give every item its own id.
max_quantity_exceeded422
RiskException
quantity is above the key's max_quantity.Reduce the size, or ask the desk to review the cap.
max_lots_exceeded422
RiskException
lots is above the key's max_lots.Reduce the size, or ask the desk to review the cap.
max_notional_exceeded422
RiskException
price × quantity is above the key's max_notional.Reduce the size, or ask the desk to review the cap.
rate_limited429
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_blocked429
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_blocked429
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_locked429
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_error500
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_disabled503
ServiceUnavailableException
The API is switched off, for example for maintenance. GET /time still answers.Retry with backoff.
intake_paused503
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_unavailable503
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 codeMeaning
unknown_fieldA field the schema does not define, including server fields such as status.
missing_fieldA required field is absent or null.
invalid_typeWrong JSON type, for example a string for quantity, or a float or boolean for an integer.
invalid_enumNot one of the allowed values, for example "exchange": "NYSE" or a lower-case "buy".
invalid_formatDoes 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_rangeToo small, too large, too long or too short, for example quantity: 0 or a 300-character note.
forbidden_characterA control, bidirectional-override or surrogate character in a string.
invalid_symbolsymbol is not 1 to 32 characters from A-Z 0-9 & _ - after upper-casing.
segment_mismatchsegment does not match exchange.
instrument_type_not_allowedEquity on NFO, BFO or MCX, or a derivative on NSE or BSE.
product_not_allowedCNC on a derivative or NRML on equity.
quantity_xor_lotsBoth or neither of quantity and lots.
lots_not_allowed_for_equitylots on an EQ signal.
price_requiredprice missing on LIMIT or SL.
price_not_allowedprice sent on MARKET or SL-M.
trigger_price_requiredtrigger_price missing on SL or SL-M.
trigger_price_not_allowedtrigger_price sent on MARKET or LIMIT.
trigger_price_inconsistentOn SL, a BUY trigger above the price or a SELL trigger below it.
expiry_requiredexpiry missing on FUT, CE or PE.
expiry_not_allowedexpiry sent on EQ.
expiry_in_pastexpiry is before today in IST.
expiry_too_farexpiry is more than 1,830 days ahead.
strike_requiredstrike missing on CE or PE.
strike_not_allowedstrike sent on EQ or FUT.
too_many_decimalsA price or strike with more than 2 decimal places.
MQuant is the platform of Sykes & Ray Equities. Questions go to your MQuant desk contact.