---
title: "Assistant"
description: "Ask Doorman, the console's assistant. Console sessions only."
url: https://doorman.fyi/docs/reference/assistant
markdown: https://doorman.fyi/docs/reference/assistant.md
area: "API reference"
section: "API reference"
---

# Assistant

Ask Doorman, the console's assistant. Console sessions only.

Source: https://doorman.fyi/docs/reference/assistant

## Ask Doorman

`POST /v1/assistant/chat`

Access `session`: a console session only; an API key gets 403 `session_required`.

One turn of the console's assistant. The answer is a `text/event-stream` of named events (see AssistantEvent): text deltas, the read tools that ran, a proposal the person must confirm (which ends the turn), done, or error. Read tools run with the session's account; mutations never run here, they come back as proposals the console runs after confirmation.

OAuth: not available to delegated app tokens.

Organizations: every member's console session may call it. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `x-doorman-domain-proposals` | header | `"1"` | no | The browser confirms it preserves domainId when running inbox proposals. Without this capability, a domain-targeted proposal ends with console_update_required instead of a proposal. |
| `x-doorman-console-mode` | header | `"simple" \| "developer"` | no | The console the person is in. With `simple` the assistant speaks the simple console's plain words (an address, a conversation), keeps keys, webhooks and the other developer tools out of its answers unless the person asks for them, and follows the three setup steps: choose the address, connect the agent, send a test email. Without the header, or with any other value, it answers as the developer console's assistant. |

**Request body (application/json): AssistantChatRequest**
One turn of Ask Doorman: the transcript so far and where in the console the person is.
- `messages` (AssistantMessage[]): At most 40 messages; the last one must come from the person or be a tool result.
- `context` (object)
  - `page` (string): The console path the person is on. Example: `/console/inboxes`
  - `inboxId` (string, optional): The inbox the page is about, when there is one.
  - `stage` (AssistantStage, optional)

Answers `200` as `text/event-stream`: The turn, as server-sent events.

**Events in the stream: AssistantEvent**
One of:

(inline)
- `event` ("text")
- `data` (object)
  - `delta` (string)

(inline)
- `event` ("tool")
- `data` (object)
  - `name` ("list_inboxes" | "get_inbox" | "list_threads" | "list_domains" | "get_domain" | "list_services" | "get_overview" | "get_usage_and_plan" | "list_keys" | "get_webhooks" | "get_metrics_summary" | "docs_lookup" | "read_message" | "get_security" | "list_senders" | "list_held")
  - `summary` (string)

(inline)
- `event` ("proposal")
- `data` (AssistantProposal)

(inline)
- `event` ("stage")
- `data` (AssistantStageCue)

(inline)
- `event` ("done")
- `data` (object)

(inline)
- `event` ("error")
- `data` (object)
  - `code` (string)
  - `message` (string)

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 400 | `validation_error` | A field is missing or invalid; the message names it. |
| 400 | `invalid_json` | The request body is not JSON. |
| 401 | `unauthorized` | The credential was missing, malformed, revoked or belongs to an inactive account. |
| 401 | `session_invalid` | The console session token could not be verified. |
| 401 | `session_expired` | The console session token has expired. |
| 401 | `session_claims_missing` | The session token does not carry a verified email address. |
| 403 | `session_required` | Account keys, developer apps, relying parties, installations, consent, approving a sign-in and the assistant require a console session. So does loosening the security policy, trusting a sender, releasing held mail, allowing a sign-in, letting agents sign in to new services alone or telling a service who owns an agent, unless the account allows its account keys to. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `member_deactivated` | The signed-in person's access to the organization was deactivated, or they were removed from it. It holds from their next request, whatever their session token says. An admin of the organization can let a deactivated member in again. |
| 409 | `account_mismatch` | The request named another account in `x-doorman-account` than the one its credential acts for, as happens when the console's organization was switched in another tab. Reload and try again. |
| 429 | `rate_limit_exceeded` | A per-inbox or per-account rate limit; `Retry-After` and `resetsAt` say when to try again. |
| 500 | `internal_error` | Something went wrong on the server. |
| 503 | `assistant_unavailable` | The assistant is not configured for this deployment. |

curl:
```sh
curl -s -X POST "https://api.doorman.fyi/v1/assistant/chat" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "How many threads are unread?"
      }
    ],
    "context": {
      "page": "/console/inboxes",
      "inboxId": "inb_01jc4q7w9k2m5n8p3r6t1v4x7z"
    }
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/assistant/chat", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "messages": [
      {
        "role": "user",
        "content": "How many threads are unread?"
      }
    ],
    "context": {
      "page": "/console/inboxes",
      "inboxId": "inb_01jc4q7w9k2m5n8p3r6t1v4x7z"
    }
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const text = await response.text();
```

Python:
```python
import os
import requests

response = requests.post(
    "https://api.doorman.fyi/v1/assistant/chat",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "messages": [{
            "role": "user",
            "content": "How many threads are unread?",
        }],
        "context": {
            "page": "/console/inboxes",
            "inboxId": "inb_01jc4q7w9k2m5n8p3r6t1v4x7z",
        },
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
text = response.text
```
