Security
Where each of your two keys may live, what protects it, and a checklist before you go live.
Daneshyar has three kinds of credential. Each one is safe in one place only.
Server keys and browser keys
Use this table to decide where each one goes:
| Where you send it | Who uses it | Rule |
|---|---|---|
X-API-Key | Your server, calling the REST API (/v1). | Secret. Keep it in a server environment variable or a secret manager. Never send it to a browser. |
data-api-key | The widget on your public pages. | Public. Anyone can read it. It is a separate widget key (pk_…) that can only ask questions. |
Authorization: Bearer | The Daneshyar console, after you sign in. | Handled by the console. It does not work with /v1, and you never need to copy it. |
Securing the widget key
Another website cannot use it: the browser and our server both check your allowed domains. A script outside a browser can still pretend to be your site, so do these four things:
- Know the limits that protect you: questions are rate-limited per visitor and per app, a question can be at most 2,000 characters, and every answer is paid from your wallet. Turn the widget on only for the workspace you embed.
- Upload only documents you would be happy to publish. Never put patient records or private files in it.
- Add only your real sites to the allowed domains. Every other site is blocked by default.
- Never put the secret key (sk_…) in a snippet or any front-end code. If a widget key is misused, press Regenerate for the widget key.
What allowed domains protect
Allowed domains are checked twice. The browser enforces a frame-ancestors rule on the widget page, and our server checks every question against the list. All sites are blocked by default: an empty list allows none.
- It does stop: another website showing your widget to its visitors, or calling the widget API from its pages, and so spending your wallet.
- It does not fully stop: a script outside a browser (for example curl) that copies the widget key and fakes the page address. No public key can prevent that. The rate limits — per visitor and per app — cap what it can cost you.
How to write entries: Allowed domains.
Rate limits
The widget has three limits: 20 questions an hour per IP address, 500 a day per app, and 60 loads an hour per IP address. Details are in Limits and costs.
The REST API (/v1) limits only uploads (60 an hour) and retries (30 an hour); other calls have no limit yet. If you put it behind your own endpoint, add your own limit there, per user, so one person cannot use all your credits.
CORS
CORS is a browser rule. It decides which websites may call an API from JavaScript.
- The widget does not need CORS from you. It runs on Daneshyar's own site, inside the iframe.
- Calling
/v1from your own website's JavaScript is blocked by CORS. That is on purpose: call it from your server. - If your site sends a Content-Security-Policy, allow the widget's site in
script-srcandframe-src, or the browser blocks the script and the iframe.
Rotating and revoking a keyOn the roadmap: Soon
Open the app page in the console. Each key — widget and secret — has its own Regenerate and Delete buttons. The old key stops working at once.
Checklist before you go live
- Your secret key (sk_…) is only in server environment variables, and not in Git or any front-end code.
- The widget uses its own app, which holds only public documents.
- The allowed domains list has your real sites only, and no leftover test domains.
- Your own chat endpoint, if you have one, has a rate limit and sends one external_user_id per user.
- Your site's Content-Security-Policy allows the widget's script and iframe.
- You know who to contact if a key leaks.