Skip to main content

AI agent chats

Enterprise feature

Embedding is an Enterprise feature that Mitzu support switches on for your organisation. See Embedded analytics for setup, and send the authentication headers with every call.

Method and pathWhat it does
GET /projects/{workspace_id}/embed/conversationsThe user's chats this API key started in the workspace, newest first: {"items": [{"id", "title", "created_at", "started_through_api", "turn_count"}], "truncated"}. It lists at most 200; truncated is true when there are more
POST /projects/{workspace_id}/embed/conversationsStart a chat: {"question": "..."}. Returns 202 with {"id", "turn": {"index", "status"}}
GET /projects/{workspace_id}/embed/conversations/{id}The chat with all turns, and source: api for a chat started through the API, agent for a scheduled agent run's chat
POST /projects/{workspace_id}/embed/conversations/{id}/messagesFollow-up: {"message": "..."}
GET /projects/{workspace_id}/embed/conversations/{id}/turns/{index}?wait_seconds=20One turn, waiting up to 20 s while it runs (at most two waiting calls per API key, fewer when the server is busy; others answer at once)
POST /projects/{workspace_id}/embed/conversations/{id}/cancelStop the running turn

A turn has status running, awaiting_answer (the agent asks the user to choose; answer with a follow-up), done, cancelled or failed, and blocks. A follow-up sent while another one for the same chat is being accepted returns 409 busy. Only the last turn can be awaiting_answer: once a follow-up answers it, the turn is done and keeps its question block.

  • {"type": "text", "markdown": "..."}: links to pages of the Mitzu app are removed, their text stays
  • {"type": "step", "title": "...", "status": "running" | "done" | "error" | "cancelled"}
  • {"type": "chart", "title": "<the insight's title>", "data": <insight data>, "definition": "..."}: data is shaped like insight data. Pass definition as start to POST .../explore-links to open the chart in the explore editor
  • {"type": "question", "text": "...", "options": ["...", "..."]}: also asks the user to confirm a save, with the confirm and cancel labels as options; reply with the chosen option as a follow-up. Sending the cancel label cancels the save, like the Cancel button in Mitzu
  • {"type": "asset", "kind": "insight" | "dashboard" | "segment" | "annotation", "id": "...", "name": "...", "action": "created" | "updated", "date": "YYYY-MM-DD"}, right after the step that saved it. date is only on annotations. segment ids are cohort ids, and every id opens through the Analytics API

Chats are the user's own Mitzu chats; they also see them in the Mitzu app. The API reads and continues only chats started through the API; a chat started in the Mitzu app returns 404. The agent sees what the user can see in the workspace. Asking it needs an Editor licence and the Member role in the workspace, as in the app; Viewers get 403 forbidden. These users can also ask the agent to save a chart as an insight, create a dashboard or add charts to one, save a segment or add an annotation; the saved assets belong to that user. As in the app, the agent asks first before saving a segment or an annotation or overwriting something; a new insight or dashboard it saves when the user asked for it. The agent changes nothing else in Mitzu from an API chat. It answers as it does in the app, including who created an asset. Questions use your organisation's AI credits; when they run out, the call returns 402 ai_credits_exhausted. A second message while a turn runs returns 409 busy.

Each run of an agent made through the API has a conversation_id. That chat opens through the same endpoints for every user who can read the agent's runs, but it isn't in the chat list. Only the agent's owner and editors can continue it or cancel a turn (403 for others), and follow-ups run like API chats.