Every question your app sends to Gridsay carries one of your organization's API keys in the x-api-key header. A secret key stays on your server. A publishable key goes in your page.
| Secret key | Publishable key | |
|---|---|---|
| Starts with | sk_gs_ | pk_gs_ |
| Lives in | Your server's environment. Never in your page, your bundle or your repository | Your page. It is meant to be seen |
| Who sends the question | A route on your server, which forwards it | Your user's browser, straight to Gridsay |
| Who checks the user | Your route, with your own sign-in | Gridsay, from the sign-in your page sends with every question |
| Allowed origins | Optional | Required: with none, every question is refused |
| Per-user limits | Yours to apply in your route | Set in the console, on Auth and limits |
| Can ask for session tokens | Yes | No |
Use a secret key when your app has a server route for the table: the MUI X Data Grid quickstart and the TanStack Table quickstart both start there. Use a publishable key when you want no route on your server: Browser keys walks through it.
Anyone who has a secret key can spend your credits, so keep it on the server and check your own sign-in in the route that uses it. A publishable key is safe in a page because it does two checks on every question: the site it comes from, and the user's sign-in. An allowed origin alone is not a sign-in: a program outside a browser can send any Origin header.
A key is not tied to one table. Keys do not sign you in to the console either: that is your own console account.
GRIDSAY_URL=https://api.gridsay.comGRIDSAY_SECRET_KEY=<your secret key>Owners and admins create, change and revoke keys. Members see the list but cannot change it. Your organization needs a running trial or plan.
Production.The full key is shown once. We keep only a hash of it, so a lost key cannot be shown again: create another.
How many keys you can have depends on your plan: up to five on Pro, secret and publishable together; no limit on Business; on Enterprise, what your contract says.
A publishable key also needs a way to identify your users before it answers anything: see Browser keys. A publishable key created in Setup starts with limits for each user; one created on API keys has none until you add them. Starter limits has the numbers.
Choose Edit beside the key to change its Name, Tier or Allowed origins, then save. A change applies from the next question. The key's value stays the same, and its type cannot change: to switch type, create a new key.
On a secret key, Allowed origins (optional) is empty by default, which allows any site.
Leave a secret key's origins empty
Allowed origins are meant for publishable keys. On a secret key, they refuse questions and session-token calls with 403 origin_not_allowed when neither Origin nor Referer is sent. Calls from your server usually carry neither. Key inspection checks the key alone. For questions and session tokens, the origin must match an entry or be http://localhost or http://127.0.0.1.
There is no rotate button. Rotating means replacing:
The new key starts with its own limit counters, and conversations started with the old key do not continue on it. On Pro, you need a free slot for the new key before you revoke the old one.
Choose Revoke, then Revoke key. It stops working at once and cannot be restored. Any secret saved for it is deleted with it. Its past questions stay in Usage, under Deleted key.
A question sent with a revoked, unknown or malformed key is refused before it reaches the model, and is not charged:
{ "ok": false, "statusCode": 401, "code": "invalid_api_key", "message": "The assistant is not available right now.", "detail": "Missing, malformed, expired, disabled or unrecognized x-api-key, or invalid stored key settings. Use an enabled key from /app/keys."}Your user sees "The assistant is not available right now." A key marked Disabled by Gridsay answers the same way. Only we can turn it back on: contact us.