quarryDocs

Error codes

Every error code quarry's HTTP routes and MCP tools return, what it means, and whether to retry.

quarry's errors share one format. Handle them by error.code; the message is for people and can change:

{
  "error": {
    "code": "QUERY_TOO_LONG",
    "message": "'query' too long (max 2000 chars)",
    "details": { "field": "query", "max": 2000 }
  }
}

details is optional. Over HTTP, the error comes with the status below. Over MCP, it's the text of a tool result with isError: true, and the HTTP status is 200. Two exceptions: MCP arguments outside the documented limits get plain text starting with MCP error -32602, not JSON, and the x402 402 responses below have their own format.

Dataset routes

GET and POST on /{username}/{slug}:

StatusCodeMeaningWhat to do
400INVALID_JSONThe body isn't a JSON objectSend a JSON object
400MISSING_QUERYquery is missing, empty, or not a stringSend a non-empty query
400QUERY_TOO_LONGquery is over 2,000 charactersShorten it
400INVALID_TOP_Ktop_k isn't a number from 1 to 20Send an integer from 1 to 20
400INVALID_ACCOUNT_TOKENThe account_token is expired or was made for another question. Nothing was chargedCall ask again and send the new quarry.web_payment.body as is
402nonePayment required, or the payment failedSee Payment responses
402SUBSCRIPTION_REQUIREDThe dataset only sells subscriptionsUse a subscription; details has the contract and agent_mcp links
404NOT_FOUNDNo published dataset at this addressFind one with search or on Explore
404NO_MATCHNo passage in this dataset answers the question. Nothing was chargedRephrase the question, or try another dataset. The same signed payment can be sent again
409PAYOUT_NOT_CONFIGUREDThe seller's payout wallet isn't set upChoose another dataset for now; the seller has to fix it
409DATASET_EMPTYThe dataset has nothing to search yetTry later, or choose another dataset
409PAYMENT_IN_FLIGHTAnother request is using this signed paymentWait for its result before deciding to retry
429RATE_LIMITEDToo many requestsWait for the seconds in Retry-After: see Limits
500SEARCH_FAILEDThe search didn't completeRetry after a delay; you weren't charged
500PAYMENT_FAILEDThe payment service failed; settlement may have gone throughDon't sign a new payment yet. After 90 seconds, send the same signed payment again: if it already settled, it's refused as used

Payment responses

A paid POST can answer 402 in three ways. Read the headers, not only the body:

CaseBodyHeaders
No payment attached"error": "payment_required", shown belowPAYMENT-REQUIRED: the requirements, base64 JSON
The payment was refused at verification{}PAYMENT-REQUIRED: the requirements, with the reason in error
Settlement failed{}PAYMENT-RESPONSE: "success": false, with errorReason

The body of the first 402, before any payment:

{
  "error": "payment_required",
  "hint": "Payment requirements are in the PAYMENT-REQUIRED response header (base64 JSON). …",
  "contract": "https://quarry.market/alice/market-outlook",
  "terms": "https://quarry.market/terms"
}

Neither refusal charges you, and the signed payment stays unspent. The x402 library behind the route can also answer 502 or 500 with { "error": "…" } when the facilitator fails: retry after a delay.

When a payment keeps failing

  • Network: sign for the network in accepts. A payment for Base can't pay on Base Sepolia, or the reverse.
  • Balance: the wallet needs at least amount of the USDC contract in accepts. An unfunded wallet is refused at verification, and error names the balance or a reverted transfer.
  • Freshness: sign a new payment for each question. A payment that already settled, or has expired, is refused.
  • Price: if the price changed, sign for the requirements of the latest 402.
  • Format: sign the payment the x402 client makes for an exact USDC requirement, an EIP-3009 authorization. Other formats, such as Permit2, are refused at verification with unsupported_payment_payload.
  • Spend cap: the x402 client refuses to sign over $1 by default: see Paying with x402.

Subscription and agent APIs

The routes under /api/agent, and query_dataset on the sign-in address. ask uses the same codes, except that a used-up month falls back to a payment request instead of QUOTA_EXHAUSTED:

StatusCodeWhat to do
400VALIDATION_ERRORCheck the fields against Ask over HTTP
401UNAUTHORIZEDSend a valid API key or OAuth token; a regular quarry login token isn't accepted. The response has a WWW-Authenticate challenge
402SUBSCRIPTION_REQUIREDNo paid subscription for this dataset. A pending Checkout isn't paid access yet
402QUOTA_EXHAUSTEDNo questions left this month. Wait for the renewal or pay per question with x402, if the dataset offers it
404NOT_FOUNDCheck the dataset. A dataset the seller stopped selling stays available only to its subscribers
404NO_MATCHNo passage answers the question, and no question was used. Rephrase it, or try another dataset
409DATASET_EMPTYThe dataset has nothing to search yet
409REQUEST_IN_FLIGHTThis request ID is still running. Wait, then retry with the same ID
409IDEMPOTENCY_CONFLICTThe ID was used for a different question. Use the original fields to retry, or a new ID
409RESERVATION_EXPIREDRetry the same question with the same ID
409OFFER_UNAVAILABLEFetch the offer again with quote_access; it changed or the dataset is being retired
409SELLER_UNAVAILABLEThe seller can't take subscription payments yet
409CHECKOUT_RECONCILINGquarry is checking a Stripe payment. Wait and try again
409BILLING_IN_FLIGHTAnother billing operation is running. Retry after a delay
410RESULT_EXPIREDThe saved answer is older than 24 hours. A new question needs a new ID and uses a question
429RATE_LIMITEDWait for Retry-After, or details.retry_after in a tool result
500SEARCH_FAILEDThe search failed and no question was used. Retry with the same ID
500BILLING_FAILEDThe outcome is uncertain. Check your access, or retry with the same ID
503BILLING_UNAVAILABLESubscriptions aren't available on this deployment

For SUBSCRIPTION_REQUIRED and QUOTA_EXHAUSTED on POST /api/agent/query, details holds the quote_access result with the other ways to pay. Nothing is ever bought for you.

MCP tool results

Tool errors come as isError: true with the format above. Besides the subscription codes, ask and the other tools can return:

CodeMeaning
NOT_FOUNDNo published dataset at username/slug
NO_MATCHNo passage answers the question. Nothing was charged and no question was used
RATE_LIMITEDToo many calls; details.retry_after gives the wait (in the message only for an x402 payment)
SEARCH_FAILEDThe search didn't complete; nothing was charged
SUBSCRIPTION_REQUIREDThe dataset only sells subscriptions; the result also carries the quarry hints
PAYMENT_UNAVAILABLEPaying per question is down for now; subscriptions still work
PAYOUT_NOT_CONFIGURED, DATASET_EMPTYAs for the dataset routes
PAYMENT_IN_FLIGHTThe signed payment is in use by another call
PAYMENT_FAILEDThe payment service failed and settlement may have gone through. Wait 90 seconds, then send the same signed payment again
UNAUTHORIZEDAn account tool needs a signed-in account. On the free address, an anonymous call gets an HTTP 401 challenge instead of a tool result
REQUEST_FAILEDAn unexpected error; retry after a delay

An ask without payment isn't an error code: it's the PaymentRequired result described in the MCP server reference.

On this page

View as Markdown