GaurGaur docs

Query endpoint

Reference for the contract query endpoint at POST /v1/api/{consumer_slug}/query.

Runs a structured query against a contract and returns governed, paginated rows. This is the REST query API. For a guided walkthrough, see Querying contracts.

Request

POST /v1/api/{consumer_slug}/query
Authorization: Bearer <api_key>
Content-Type: application/json

Path parameters

ParameterTypeDescription
consumer_slugstringThe slug of the consumer to query. The API key must authorize this consumer.

Body

FieldTypeRequiredDescription
contract_namestringYesThe contract to query. Must be linked to the consumer.
queryobjectYesThe query specification. See Query schema.
contextobjectNoKey-value pairs for the contract's row-level security.
{
  "contract_name": "product_performance",
  "query": {
    "dimensions": [
      { "name": "ordered_at", "time_grain": "month" },
      { "name": "category" }
    ],
    "measures": ["revenue_usd", "cogs_ratio"],
    "filters": [{ "field": "category", "operator": "eq", "value": "jaffle" }],
    "sorts": [{ "field": "ordered_at", "direction": "asc" }],
    "limit": 100,
    "offset": 0
  },
  "context": { "store_id": "STR-008" }
}

The query object is documented field by field in the Query schema reference.

Response

200 OK with this body:

{
  "data": {
    "pagination": {
      "items": [
        { "ordered_at": "2026-04-01T00:00:00", "category": "jaffle", "revenue_usd": 84210.50, "cogs_ratio": 0.42 }
      ],
      "total_items":   12,
      "page":          1,
      "limit":         100,
      "total_pages":   1,
      "has_next_page": false,
      "has_prev_page": false
    },
    "execution_time_ms": 42
  },
  "message": null
}

Response fields

FieldTypeDescription
data.pagination.itemsarrayThe result rows. Each object is keyed by the requested dimensions and measures.
data.pagination.total_itemsintegerTotal rows across all pages.
data.pagination.pageintegerThe current page number, starting at 1.
data.pagination.limitintegerThe page size actually applied.
data.pagination.total_pagesintegerTotal number of pages.
data.pagination.has_next_pagebooleanWhether a page follows this one.
data.pagination.has_prev_pagebooleanWhether a page precedes this one.
data.execution_time_msintegerQuery execution time in milliseconds.
messagestring | nullOptional informational message.

Pagination

limit and offset in the query control paging. Gaur clamps limit to 10,000 rows; requests above that succeed but return 10,000 rows with pagination.limit: 10000 in the response. Always read data.pagination.limit to see the size that applied, and data.pagination.has_next_page to know whether to keep paging. See Pagination.

Status codes

StatusMeaning
200Success.
400Invalid input, or the query failed validation against the contract.
401Missing or invalid API key.
403The API key does not authorize this consumer, or the contract is not linked to it.
404The named contract was not found.
500Internal server error.

Error bodies follow the shape { "message": string, "code": string, "errors": string[] | null }. Branch on code, not on message.

Example

curl -X POST https://<base-url>/v1/api/jaffle-public/query \
  -H "Authorization: Bearer gaur_***************" \
  -H "Content-Type: application/json" \
  -d '{
    "contract_name": "product_performance",
    "query": { "measures": ["revenue_usd"], "limit": 1 }
  }'

On this page