Send a user's question and a description of your table; the answer is the state your table applies. The table packages make these calls for you. Read this section when you call the API yourself, or want to know exactly what they send.
Every call goes to https://api.gridsay.com. The version is in the path: /api/v1.
| Method | Path | For |
|---|---|---|
POST | /api/v1/datagrid/prompt | Questions from MUI X Data Grid and TanStack Table. See Data Grid endpoint. |
POST | /api/v1/sessions | A signed-in user's session token, minted on your server. See session tokens. |
GET | /api/v1/datagrid/key | The calling key's type, tier setting and organizationId. |
The Data Grid endpoint and the sessions endpoint also answer at /v1/datagrid/prompt and /v1/sessions. Use the /api/v1 paths in new code.
Send a key in the x-api-key header: a secret key from your server, or a publishable key from the browser together with the user's token. See Authentication.
Run this from a terminal. The key is a fake: put yours in its place, and keep it on your server. A terminal sends no Origin header: if your secret key has allowed origins, the call is refused with 403 origin_not_allowed until you add one of them with --header 'Origin: https://app.example.com' (any http://localhost origin is accepted on a secret key).
curl https://api.gridsay.com/api/v1/datagrid/prompt \ --header 'Content-Type: application/json' \ --header 'x-api-key: sk_gs_FAKE_EXAMPLE_DO_NOT_USE' \ --data-binary @- <<'JSON'{ "query": "people in Germany or France earning over 100k", "context": "[{\"field\":\"country\",\"type\":\"string\",\"allowedOperators\":[\"equals\",\"isAnyOf\"]},{\"field\":\"salary\",\"type\":\"number\",\"allowedOperators\":[\"=\",\">\",\"<\"]}]"}JSONThe answer, with HTTP 201. conversationId and the meta values are examples: they depend on your key's tier and your organization's usage.
{ "ok": true, "data": { "select": -1, "filters": [ { "column": "country", "operator": "isAnyOf", "value": ["Germany", "France"] }, { "column": "salary", "operator": ">", "value": 100000 } ], "aggregation": {}, "sorting": [], "grouping": [], "pivoting": {}, "chart": null, "conversationId": "00000000-0000-4000-8000-000000000001" }, "meta": { "tier": "fast", "usedQueries": 12, "remainingQueries": 7988, "resetAt": "2027-01-01T00:00:00.000Z" }}data is the whole state to apply, not a change list: the empty parts clear those parts of the table. meta says which tier answered and how much of the period is used.
Content-Type: application/json and a JSON body.GET /api/v1/datagrid/key and POST /api/v1/sessions answer 200. Answers and errors have a JSON body. The browser's preflight (OPTIONS) gets 204 with no body, and a body over 8 MB can be cut off by the server before the API answers, without a JSON body.ok: true. A failure has ok: false, the same status in statusCode, and a code. Branch on code, show message to your user, and keep detail for yourself. Every code is in Errors.retryAfter in the body and as a Retry-After header.detail carries the request id, which also identifies the question in your Usage log. For any other failure, keep the endpoint, the time and the code.The API accepts calls from any page, and its CORS headers name the page's origin. Whether a call is answered depends on its key: a publishable key needs the page's origin on its list and a signed-in user's token. A secret key that accepts the page's origin would be answered too, but anyone could read it from the page: never put one in browser code. See Authentication.