# AI agent API

Set up dimmi AI agents, knowledge sources, procedures in plain English, backend actions, action connections, provider keys, and usage via REST.

## Action calls

- `GET /ai/action-calls` - List AI action calls: Lists the action calls the agents made, newest first, including those waiting for a teammate. Returns a page of calls with their state, action, conversation and summary, with next_cursor for more.
- `GET /ai/action-calls/{call}` - Get an AI action call: Reads one call: what the agent asked to do, who agreed, and how it went. Returns the call with its state, timings and, for those allowed, its input.
- `PATCH /ai/action-calls/{call}` - Approve or decline an AI action call: Decides a call waiting for the team. Approving runs it in the workspace's system at once; declining has the agent tell the customer. Show the person what the call does and decide only as they say. Returns the call in its new state.

## Action connections

- `GET /ai/action-connections` - List action connections: Lists the connections to the workspace's own systems that AI actions call: an HTTP API or an MCP server, each with its address and credential. Secrets never come back. Returns every connection with its kind, base url, auth type, status, last error and action count.
- `POST /ai/action-connections` - Add an action connection: Connects one of the workspace's own systems so actions can call it. Nothing runs until an action on it is published. Only store a credential the person gave you for this. Returns the connection, the secret hidden.
- `POST /ai/action-connections/{connection}/tests` - Check an action connection: Sends one request to the connection to see whether dimmi can reach it and sign in. For an MCP server it lists the tools. Returns how the check went: status, reason, HTTP status, latency and the MCP tool count.
- `POST /ai/action-connections/{connection}/tool-syncs` - Import MCP tools as actions: Reads an MCP server connection's tools and creates a draft action for each one that has none. Drafts start as writes that ask the customer to confirm; nothing is live until published. Returns the draft actions created, how many tools already had one, and the tools skipped with why.
- `GET /ai/action-connections/{connection}` - Get an action connection: Reads one connection to a workspace system. The secret never comes back, only a hint. Returns the connection with its status, last success and last error.
- `PATCH /ai/action-connections/{connection}` - Change an action connection: Changes a connection's address, credential, headers or status. Every published action on it uses the change at once. A new token, username or password replaces the stored secret. Returns the connection as it now is.
- `DELETE /ai/action-connections/{connection}` - Remove an action connection: Deletes a connection and its secret. Refused while actions use it unless force is set, which also deletes those actions and cancels their calls still waiting.

## Actions

- `GET /ai/actions` - List AI actions: Lists the actions the agents can take in the workspace's own systems, such as looking up an order or issuing a refund, by name. Returns every action with its status, side effect, who must agree, and its live version.
- `GET /ai/actions/{action}/versions` - List an action's versions: Lists the published versions of an action, newest first. Each is frozen once published. Returns every version with its number, definition, note and who published it.
- `POST /ai/actions` - Draft an AI action: Drafts an action on a connection: the request it sends, what the model fills in and who must agree. A draft never runs for customers until published. Returns the draft action with any warnings.
- `POST /ai/actions/{action}/tests` - Test an AI action: Tries the working copy with sample input and a stand-in customer. mode=dry_run (default) renders the request and sends nothing. mode=live sends it to the real system; a live write changes a real account, so run it only when the person asks. Returns the result: rendered request, response, what the model would read and any validation errors.
- `POST /ai/actions/{action}/publications` - Publish an AI action: Freezes the action's working copy as a new version and makes it live: the agents can take it in customer conversations at once. Test it first and publish only when the person agrees. Returns the new version with its number.
- `GET /ai/actions/{action}` - Get an AI action: Reads one action's working copy: its request, input schema, response fields and agreement rules. Returns the action with has_unpublished_changes and any warnings.
- `PATCH /ai/actions/{action}` - Change an AI action: Edits the working copy, restores a version with restore_version_id, or switches a published action with status=disabled or published, which changes what customers get at once. Returns the action as it now is.
- `DELETE /ai/actions/{action}` - Delete an AI action: Deletes an action so no agent can take it any more. Its past calls stay. To stop it for now, set status=disabled with PATCH /ai/actions/{action} instead.

## Agent templates

- `GET /ai/agent-templates` - List AI agent templates: Lists what a new agent can start from, such as support or sales, with its starting guidance. Returns the templates with their key, name and the guidance a new agent starts with.

## Agents

- `GET /ai/agents` - List AI agents: Lists the workspace's AI agents: what each handles, whether it is live, and which is default. Returns the agents with their name, description, status and whether a draft waits to be published.
- `GET /ai/agents/{agent}/versions` - List an AI agent's versions: Lists every published version of an agent, newest first, with who published it and why. Returns the versions with their number, note and publish time.
- `GET /ai/agents/{agent}/simulations` - List an AI agent's simulations: Lists the agent's saved simulations and how each has gone lately: passing, flaky or failing over its recent runs. Returns the simulations with their messages, checks, last result and recent history.
- `GET /ai/agents/{agent}/simulations/{simulation}/runs` - List a simulation's past runs: Lists the latest runs of one simulation, newest first, to see whether it passes steadily or only sometimes. Returns the runs with their verdict, when they ran and what was said.
- `POST /ai/agents` - Create an AI agent: Creates an agent, from a template or empty. It starts switched off, as a draft: customers meet it only once it is published and placed somewhere. Returns the new agent with its draft.
- `POST /ai/agents/{agent}/preview` - Preview an AI agent turn: Sends one customer message to the agent's draft or live version and returns its reply. Nothing reaches a customer, and actions answer with their saved test result, never your systems. Every turn runs real models and spends the workspace's AI budget. Returns the agent's reply, what it did on the way, and whether it handed over.
- `POST /ai/agents/{agent}/simulations` - Save an AI agent simulation: Saves a conversation the agent must keep getting right: who the customer is, what they write, and the checks that say whether the agent did what it should. Returns the saved simulation.
- `POST /ai/agents/{agent}/publications` - Publish an AI agent: Makes the agent's draft live: from now on customers meet the agent as the draft describes it. Run its simulations first. Returns the agent as published, with its new version number.
- `POST /ai/agents/{agent}/simulations/run` - Run an AI agent's simulations: Replays the agent's saved simulations, all of them or the ones named, against its draft or its live version. A simulated customer plays each one and a judge reads the result. Every run uses real models and is tallied as simulation spend. Returns each simulation with its verdict, the reason for every written check, and the conversation.
- `POST /ai/agents/{agent}/versions/{version}/restore` - Restore an AI agent version: Copies a published version into the agent's draft. Customers see no change until the draft is published again. Returns the agent with the restored draft.
- `POST /ai/agents/{agent}/simulations/from-conversation` - Save a conversation as a simulation: Turns a real conversation into a simulation of the agent, with a scenario written from what the customer said. Returns the saved simulation.
- `GET /ai/agents/{agent}` - Get an AI agent: Reads one agent: its guidance, tone, channels, models, handover rules, where it is placed, and the draft a teammate is working on beside the version that is live. Returns the agent with its live definition and its draft, when it has one.
- `GET /ai/agents/{agent}/versions/{version}` - Get an AI agent version: Reads one published version of an agent as it was. Returns the version with its full definition.
- `GET /ai/agents/{agent}/simulations/{simulation}` - Get an AI agent simulation: Reads one saved simulation of an agent, with its last result turn by turn. Returns the simulation with its scenario, messages, checks and last result.
- `PATCH /ai/agents/{agent}` - Edit an AI agent's draft: Changes the agent's draft: guidance, tone, models, knowledge, handover, transfers or placement. Customers see no change until the draft is published. Returns the agent with the draft as saved.
- `PATCH /ai/agents/{agent}/simulations/{simulation}` - Edit an AI agent simulation: Changes a saved simulation's name, scenario, messages, customer or checks. Returns the simulation as saved.
- `DELETE /ai/agents/{agent}` - Archive an AI agent: Archives an agent that is not the default: it is switched off and leaves the list, while its conversations, versions and history stay. It is refused with agent_in_use while anything still relies on the agent; the error lists each tie. Returns nothing.
- `DELETE /ai/agents/{agent}/publications` - Switch an AI agent off: Stops the agent taking conversations. Its draft, versions and simulations are kept, and it can be published again. Returns the agent, now off.
- `DELETE /ai/agents/{agent}/simulations/{simulation}` - Delete an AI agent simulation: Deletes a saved simulation and its past runs. Returns nothing.

## Conversation attributes

- `GET /ai/conversation-attributes` - List AI conversation attributes: Lists the facts the AI reads off each conversation, active and archived. Returns the attributes with their key, type, options and status.
- `POST /ai/conversation-attributes` - Add an AI conversation attribute: Adds a fact the AI reads off each conversation and checks again as the customer writes. Workflows can start when it changes and branch on its value. Returns the attribute.
- `PATCH /ai/conversation-attributes/{attribute}` - Edit an AI conversation attribute: Changes an attribute's label, description or options, or archives it. Its key and type stay. Returns the attribute as saved.

## Keys

- `GET /ai/keys` - List AI provider keys: Lists the AI provider connections the agents answer with. Secrets never come back, only a hint. Returns every key with its provider, status, the models it offers and when it was last checked.
- `POST /ai/keys` - Add an AI provider key: Connects an AI provider with the workspace's own API key. dimmi checks the key with the provider as it saves; a key the provider refuses is not kept. Only add a key the person gave you for this. Returns the key with its status and the models it offers, the secret hidden.
- `POST /ai/keys/{key}/test` - Check an AI provider key: Checks a provider key with the provider again and stores the fresh status. Returns the key with its status, a reason when it fails, and the models it offers.
- `PATCH /ai/keys/{key}` - Change an AI provider key: Renames a provider key, moves its endpoint or rotates its secret. A new secret or endpoint is checked again at once, and the agents switch to it on their next answer. Returns the key with its fresh status.
- `DELETE /ai/keys/{key}` - Remove an AI provider key: Deletes a provider key and its secret. Refused while an agent or the shared settings still answer with it: point them at another key with PATCH /ai/agents/{agent} or PATCH /ai/settings first.

## Placements

- `GET /ai/placements` - List where AI agents can be placed: Lists everywhere an agent can take new conversations, channel connections, Slack channels and inboxes, with the agent placed at each now. Returns the places with their kind and the agent there, null where the default agent answers.

## Settings

- `GET /ai/settings` - Get shared AI settings: Reads what every agent shares: the answer and fallback models an agent uses until it picks its own, the classifier, and the monthly spend cap. Returns the shared models and the spend cap, null when there is none.
- `PATCH /ai/settings` - Change shared AI settings: Changes the models every agent falls back on, or the workspace's monthly spend cap. Returns the settings as saved.

## Usage

- `GET /ai/usage` - Get AI agent usage: Reads one month of the AI agent's work: what it spent, tokens, how many conversations it answered, did not know or handed over, day by day and by model. Months are counted in UTC. Operator's own spend is in GET /operator/usage. Returns the month's cost in micro-dollars, counts by outcome, daily series, spend by model and the cap.

## Knowledge

- `GET /knowledge/sources` - List knowledge sources: Lists the workspace's knowledge sources and how each one's syncing goes. Returns every source with its type, mode, targets, schedule, status, counts and last sync.
- `GET /knowledge/source-types` - List knowledge source types: Lists the tools a knowledge source can be added from, with the settings each needs, the modes it supports, what it can feed and how often it may sync. Returns every source type with its settings schema and abilities.
- `GET /knowledge/sources/{source}/syncs` - List a knowledge source's syncs: Lists a source's latest syncs and what each read, changed or failed on. Returns the syncs with their trigger, status, stats and timing.
- `GET /knowledge/sources/{source}/documents` - List a knowledge source's documents: Lists the documents a source read, by status or words in the title or path. Returns a page of documents with their title, path, status and error.
- `POST /knowledge/sources` - Add a knowledge source: Connects a tool as a knowledge source. Its settings are checked against the real service before it is saved, so a wrong key fails at once. Only use credentials the person gave you for this. Returns the source.
- `POST /knowledge/uploads` - Upload knowledge files: Uploads a .zip of Markdown files, or one .md file, of at most 50 MB for a knowledge source to read. It needs a multipart form with the file in the field named file, and the settings:write ability. Pass the key it returns in the settings of the source you then create. Returns the upload's key and file name.
- `POST /knowledge/sources/{source}/syncs` - Sync a knowledge source: Starts reading a source again now, so the agents answer from what it holds today. Returns the sync that started.
- `POST /knowledge/sources/{source}/imports` - Turn a source into articles: Turns a synced source's documents into articles of a help center, published unless the document was a draft. A document imported before updates its article instead. Returns nothing once the import is queued.
- `POST /knowledge/sources/{source}/documents/{document}/syncs` - Read a document again: Reads one document of a source again now, without walking the whole source. Returns the sync that reads it.
- `POST /knowledge/sources/{source}/documents/{document}/exclusion` - Set a document aside: Leaves one document out of the knowledge for good: the agents stop answering from it, and it stays out through every later sync until let back in. Returns nothing once it is set aside.
- `GET /knowledge/usage` - Get knowledge usage: Reads what the workspace's knowledge cost this month, per source and kind of work. Returns the month's start, its total cost in micro-dollars and a line per source and kind.
- `GET /knowledge/settings` - Get knowledge settings: Reads the embedding model knowledge search uses, and one being built to replace it. Returns the active model, its provider key and the progress of a model being built.
- `GET /knowledge/sources/{source}` - Get a knowledge source: Reads one source. Secrets are never sent back; secrets_set names the ones stored. Returns the source with its settings, patterns, schedule, status, counts and last sync.
- `PATCH /knowledge/settings` - Change the embedding model: Picks the model knowledge search uses. It is checked with one tiny embedding, then built in the background while searches stay on the old one, and switched in once it covers everything. Building spends on the provider key. Returns the settings with the model being built.
- `PATCH /knowledge/sources/{source}` - Change a knowledge source: Changes a source's name, settings, patterns, targets or schedule. A change of what it reads starts a sync at once. Type and mode never change. Returns the source as it now is.
- `DELETE /knowledge/sources/{source}` - Remove a knowledge source: Removes a source with every document it read; the agents stop answering from them. Returns nothing once it is removed.
- `DELETE /knowledge/sources/{source}/syncs/{run}` - Cancel a knowledge source sync: Stops a running sync. What it already read stays. Returns the sync, now stopped.
- `DELETE /knowledge/sources/{source}/documents/{document}/exclusion` - Let a document back in: Lets a set-aside document back into the knowledge and reads it again. Returns the sync that reads it again.

## Procedures

- `GET /procedures` - List procedures: Lists the procedures, the step-by-step playbooks the AI agent follows for kinds of requests. Returns every procedure with its status and how many conversations used it in 30 days.
- `GET /procedures/{procedure}/versions` - List a procedure's versions: Lists every published version of a procedure, newest first, with who published it and why. Returns the versions with their number, note and publish time.
- `GET /procedures/{procedure}/test-cases` - List a procedure's simulations: Lists the saved simulations of a procedure and how each last went. Returns the simulations with their messages, checks and last result.
- `POST /procedures` - Create a procedure: Creates an empty draft procedure. The agent does not follow it until published. Returns the draft procedure.
- `POST /procedures/{procedure}/simulate` - Preview a procedure turn: Sends one customer message to the AI agent as it would follow this procedure, and returns its reply. Nothing reaches a customer and actions answer with their saved test result, never your systems. Every turn runs real models and spends the workspace's AI budget. Returns the agent's reply, the actions it called, the procedure's state to send with the next turn.
- `POST /procedures/{procedure}/test-cases` - Save a procedure simulation: Saves a chat as a simulation: an AI-played customer replays it against the procedure, on the date it was saved, and the checks say whether the agent did what it should. Returns the saved simulation.
- `POST /procedures/{procedure}/publications` - Publish a procedure: Makes the working copy live: the AI agent follows it with customers from the next message. Every action it takes must exist and be published. Returns the procedure, published.
- `POST /procedures/{procedure}/test-cases/run` - Run procedure simulations: Runs a procedure's saved simulations against its working copy and waits for the verdicts. Each run calls real models for the agent, the customer and the checks, and spends the workspace's AI budget. A working copy with problems to fix is not run. Returns each simulation with its result: passed, failed or an error, and every check's verdict.
- `POST /procedures/{procedure}/versions/{version}/restore` - Restore a procedure version: Copies a published version into the working copy. Customers see no change until it is published again. Returns the procedure with the restored working copy.
- `GET /procedures/{procedure}` - Get a procedure: Reads one procedure's working copy and whether it differs from the live one. Returns the procedure with its definition, status and lock_version.
- `GET /procedures/{procedure}/metrics` - Get a procedure's metrics: Reads how a procedure did in real conversations: how often it ran, finished and handed over. Returns the counts, rates, a daily series and where conversations left the procedure.
- `GET /procedures/{procedure}/versions/{version}` - Get a procedure version: Reads one published version of a procedure as it was. Returns the version with its full definition.
- `GET /procedures/{procedure}/test-cases/{test_case}` - Get a procedure simulation: Reads one saved simulation of a procedure and its last result. Returns the simulation with its messages, checks, date and last result turn by turn.
- `PATCH /procedures/{procedure}` - Edit a procedure: Saves the name or the working copy of a procedure. Customers see no change until it is published. Returns the procedure as saved, with its new lock_version.
- `PATCH /procedures/{procedure}/test-cases/{test_case}` - Edit a procedure simulation: Changes a saved simulation's name, messages, customer or checks. Returns the simulation as saved.
- `DELETE /procedures/{procedure}` - Delete a procedure: Deletes a procedure. The agent stops following it at once if it was live.
- `DELETE /procedures/{procedure}/publications` - Unpublish a procedure: Takes a procedure out of the AI agent's hands at once. The working copy stays. Returns the procedure, unpublished.
- `DELETE /procedures/{procedure}/test-cases/{test_case}` - Delete a procedure simulation: Deletes a saved simulation and its last result.

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
