# For AI agents

[Guide index](../v1.md) · [Developer API](api.md) · [API reference](api-reference.md)

This page is for an AI assistant acting for a Determesh customer with the customer's API key. Read it, and the [Developer API](api.md), before making any call.

## What you can do

A key does what the panel's pages do, limited to the **sections and folders** it was issued with. With the right sections you can:

- **Chat:** send messages as a user (`POST /v1/messages`) and read the replies (`GET /v1/threads/...`), for example to test the assistant.
- **Set up and change things:** the company's settings, channels, resources and methods, documents, notes, code, database connections, access rules, identities and their attributes, sub users, keys and webhooks.
- **Look things up:** threads, emails, requests, the audit log, billing and usage.

You can never: pay or set a plan yourself (with the Billing section you can send a billing request, `POST /v1/companies/{companyId}/billing/requests`, but only when the person asks for it; our accounts team arranges the payment), change a login's own email, password or authenticator, or delete the company. Those are the person's, in the panel.

If a call answers 403 `section_not_granted`, or 404 for something that should exist, the key lacks that section or folder. Tell the person which section or folder you need; they issue a new key with it (a key's access cannot be changed after it is issued).

## Rules for acting

1. **Ask before every change.** Say exactly what you will create, change or delete, and wait for a yes. Reading is fine without asking.
2. **Never delete without an explicit instruction for that thing.** Deleting a resource deletes everything under it.
3. **Keep secrets secret.** Do not echo API keys, signing secrets, passwords, database logins or resource headers back in full, and never put them in a summary, note or message.
4. **Sign every request** as the Developer API page says. Use a new nonce each time and the current time.
5. **Respect the limits:** 120 calls a minute per key. On 429, wait and retry. On 503 `maintenance`, retry in a minute.
6. **Check your work.** After a change, read it back (GET) and, where it matters, try it: send a test message through the Chat section and read the reply and the thread.
7. **Do not guess at features.** If this guide does not say something can be done, it cannot; suggest the person write to hi@determesh.com.
8. **Money:** prices change. Read them from Billing (`GET /v1/companies/{companyId}/billing`) or https://determesh.com/#pricing, never from memory. Point out what a change will cost (more channels or storage than the plan includes, a more expensive AI model) before making it.

## Getting oriented

1. Find the company's id: the person can copy it from the panel's address (`/c/<companyId>/...`).
2. `GET /v1/companies/{companyId}` (any key): name and summary.
3. `GET .../config` (settings) and `GET .../ai` (AI choice) work with any key. With the matching sections: `GET .../resources` (the tree), `GET .../access-rules`, `GET .../channels`, `GET .../billing`.
4. Compare with the setup checklist in [Getting started](getting-started.md) and tell the person what is missing.

## Common jobs, in order

**Set up a help-centre assistant** (Company settings, Resources, Access rules, Channels):
1. `PATCH .../companies/{companyId}` with a clear summary of what the service is for.
2. `PATCH .../config` with a fallback statement and block text.
3. `PUT .../ai` with the AI model and embedding provider the person chose (show them the options from `GET .../ai` with prices and locations first).
4. `POST .../resources` a folder with a summary; upload documents with `PUT .../resources/{folderId}/documents?name=...` (raw file body); wait until each is `READY` (`GET .../resources/{folderId}/documents`).
5. `POST .../access-rules`: the folder and everything inside, READ, no conditions.
6. Channels: a Telegram bot needs a token from @BotFather that the person gives you; a mailbox needs its IMAP and SMTP details; a website widget needs the sites it runs on (`POST .../widgets`), and the person's developer then signs visitors' tokens on their server ([Website widget](widget.md)); or issue a Chat key for their app.
7. Test with `POST /v1/messages` and read the reply.

**Connect an API** (Resources, Access rules): create the API resource (base URL, headers the person gives you), add a method per endpoint with clear "what it does" text and parameters, test each with the method's test call, then add the rules.

**Connect a database**: create the database resource and save the connection. Either add one SQL statement per method with `:name` parameters (a login with only the rights the methods need; read methods cannot change data), or choose free read access, where the assistant writes its own read queries and the login must not be able to write. Test, add rules.

**Give staff private data safely**: set attributes on identities (from the person's HR list), add a verifier resource and either a verification group or a rule with "Also verified by", then rules by attribute. Test with `GET .../identities/{identityId}/tools/search?q=...` ("what they can reach").

**Investigate a bad answer**: read the thread (`GET .../threads/{threadId}`): which resources were asked, what they returned, any access refusals, and the score. The usual fixes are a clearer resource summary, a missing rule, or a document that was not readable. See [FAQ and troubleshooting](troubleshooting.md).

## Talking to the person

- Explain in plain words what you did and what it changed.
- When something needs the panel (payments, their own sign-in details, deleting the company, issuing a key with more access), give them the exact steps from the panel pages of this guide.
- Their contact for anything else: hi@determesh.com, answered within 48 hours.
