quarry
API reference

Error codes

Identify request, dataset, and payment errors and decide when to retry.

The dataset and agent HTTP APIs return application errors in this JSON format. Use error.code to handle them in client code:

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

Payment responses from x402 can use a different body format. For a 402 payment challenge, read the PAYMENT-REQUIRED header. A subscription-related 402 instead uses error.code, such as SUBSCRIPTION_REQUIRED or QUOTA_EXHAUSTED, and does not ask for a wallet signature.

Public dataset queries

StatusCodeMeaningWhat to do
400INVALID_JSONBody cannot be parsed as a JSON objectSend a JSON object
400MISSING_QUERYquery is absent, not a string, or emptyProvide a non-empty query
400QUERY_TOO_LONGquery exceeds 2000 charactersShorten the query
400INVALID_TOP_Ktop_k is not a number in the range 1–20Use an integer between 1 and 20
402—Payment is required or could not be completedRead the payment requirements and check the authorization; see Paying with x402
402SUBSCRIPTION_REQUIREDThis dataset has disabled x402Use the authenticated agent endpoint with a subscription; read the links in error.details
404NOT_FOUNDNo published dataset at this username and slugFind a dataset through Explore or MCP
409PAYOUT_NOT_CONFIGUREDCreator's payout wallet is missing or invalidThe creator must resolve this; use another dataset meanwhile
409DATASET_EMPTYDataset has no indexed contentRetry later or choose another dataset
409PAYMENT_IN_FLIGHTThe signed payment is locked, usually by a request still in progressWait for the active request's result before deciding whether to retry
429RATE_LIMITEDRequests are temporarily limitedWait for the number of seconds in Retry-After
500SEARCH_FAILEDSearch could not completeRetry with increasing delays between attempts
500PAYMENT_FAILEDPayment infrastructure failed; settlement may be uncertainCheck the payment outcome before retrying; an in-flight authorization may remain temporarily locked

Subscription and agent APIs

These statuses apply to HTTP routes under /api/agent. With MCP, a billing failure inside a tool call sets isError: true and includes the error object in its text content; the HTTP response alone does not indicate tool success.

StatusCodeWhat to do
400VALIDATION_ERRORCheck the tool schema or HTTP query fields
401UNAUTHORIZEDConnect or reconnect through OAuth using the account that owns the subscription; ordinary login tokens are not accepted
402SUBSCRIPTION_REQUIREDCheck access and complete payment for an available offer; pending Checkout is not paid access
402QUOTA_EXHAUSTEDWait for the next paid period or explicitly choose the x402 alternative, if offered
404NOT_FOUNDCheck the dataset reference and account; a retiring dataset is available only while the account has paid access
409DATASET_EMPTYThe dataset has no indexed content; the creator must resolve this
409REQUEST_IN_FLIGHTWait, then retry the identical query with the same request ID
409IDEMPOTENCY_CONFLICTUse the original parameters for a retry, or a new ID for a new query
409RESERVATION_EXPIREDRetry the identical query with the same request ID
409BILLING_IN_FLIGHTA billing operation is running; retry after a delay
409CHECKOUT_RECONCILINGStripe payment status is being checked; wait and retry the subscription request
409OFFER_UNAVAILABLEFetch the offer again; it may have changed or the dataset may be retiring
409SELLER_UNAVAILABLEThe creator cannot accept subscription payments yet
410RESULT_EXPIREDThe saved response expired; a new query needs a new ID and consumes quota
429RATE_LIMITEDRespect HTTP Retry-After, or error.details.retry_after for a quota-query tool error
500SEARCH_FAILEDSearch failed and its reservation was released; retry with the same ID
500BILLING_FAILEDThe operation's outcome may be uncertain; recheck access or retry a query with the same ID
503BILLING_UNAVAILABLESubscription payments or agent access are not configured in this environment

For SUBSCRIPTION_REQUIRED and QUOTA_EXHAUSTED from a subscription query, error.details includes the access quote and available payment options. No additional payment is made automatically. A 401 agent HTTP response includes an OAuth challenge in WWW-Authenticate.

Creator subscription settings

StatusCodeWhat to do
409STRIPE_ACCOUNT_NOT_READYComplete Subscriptions → Selling → Stripe setup, then check its status
409SUBSCRIPTION_NOT_READYConfigure an active offer and a ready Stripe account before publishing a subscription-only dataset
409DATASET_RETIRINGWait until retirement finishes before changing payment options
409PAID_ACCESS_PROTECTEDRetire the dataset and preserve its content until subscriptions close and paid access ends

See Publish your first dataset for all publication requirements.

Notes for x402 agents

  • Validation errors, missing datasets, dataset precondition failures, rate limits, and SEARCH_FAILED responses do not settle a payment.
  • Send one request at a time with a given signed payment. Concurrent requests using it can receive PAYMENT_IN_FLIGHT. If the active request failed without settlement, its authorization remains unspent and can be retried while it is still valid. A successful payment cannot be reused.
  • An initial 402 is the payment challenge. If a signed request also returns 402, check the current requirements, network, USDC balance, and authorization validity. See the FAQ.

On this page