
# Query the warehouse

The same SQL you would run against a database connection runs over HTTPS through one endpoint. Your credential resolves server-side to your own tenant database on a read-only connection, so the isolation is structural: there is no way to query someone else's data, and no way to write.

## The endpoint

```
curl -X POST https://mcp.mixshift.io/api/query \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT COUNT(*) AS rows FROM mws_orders WHERE PurchaseDate >= ?", "params": ["2026-07-01"]}'
```

Success returns `{ "ok": true, "rows": [...], "rowCount": n, "durationMs": n }`. Failures return `{ "ok": false, "kind": "...", "friendly": "..." }`; branch on `kind`, and show `friendly` to humans.

Parameters can be positional (`?` with a `params` array) or named. Pass `queryTimeoutMs` to raise the statement timeout up to the ceiling.

## Discover the schema

- `GET /api/tables` lists your tables.
- `GET /api/table/[name]` describes one: columns and types.

AI tools connected over MCP get the same two as tools, which is why they can find their way around your schema unprompted.

## The limits, and how to live with them

- Results cap at **50,000 rows** or **10 MB** per response, whichever hits first, and a query can run at most **120 seconds** (60 by default).
- For bigger pulls, paginate with `LIMIT`/`OFFSET` or chunk by date window. The error kinds (`too_many_rows`, `response_too_large`) tell you which cap you hit.

## Migrating from direct MySQL access

If you used to query the warehouse over a direct MySQL connection with database credentials and IP allowlists, this endpoint is the replacement: the same SQL, without passwords to rotate or allowlists to maintain. Point your existing queries at `/api/query` and swap the connection for a Bearer token.

## Related

- [Get access](/knowledge-base/builder-platform/getting-started/get-access)
- [Use the /v1 data endpoints](/knowledge-base/builder-platform/how-to/use-the-v1-endpoints) (pre-shaped alternatives to raw SQL)
- [Limits and guardrails](/knowledge-base/builder-platform/reference/limits-and-guardrails)