---
title: "Healthcare"
description: "The business associate agreement an eligible team signs, and the guardrails it unlocks: protected health information replaced in everything an agent or a system is given, held or refused on the way out, and custom guardrails. Every operation answers 404 until the deployment switches the capability on."
url: https://doorman.fyi/docs/reference/healthcare
markdown: https://doorman.fyi/docs/reference/healthcare.md
area: "API reference"
section: "API reference"
---

# Healthcare

The business associate agreement an eligible team signs, and the guardrails it unlocks: protected health information replaced in everything an agent or a system is given, held or refused on the way out, and custom guardrails. Every operation answers 404 until the deployment switches the capability on.

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

## Read the agreement's standing

`GET /v1/baa`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

Where the account stands with the business associate agreement: whether it may sign (an organization whose Teams subscription pays for it, or an account on the enterprise plan), whether someone has, and whether guardrails apply.

OAuth: not available to delegated app tokens.

Also available as [`client.baa.get`](https://doorman.fyi/docs/sdk/reference/healthcare.md#baa-get) in TypeScript and [`client.baa.get`](https://doorman.fyi/docs/python/reference/healthcare.md#baa-get) in Python.

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

Answers `200`: The account's standing.

**Response 200: Baa**
Where the account stands with the business associate agreement, and whether it may sign.
- `status` ("not_signed" | "active" | "reacceptance_required" | "terminated"): `not_signed`: nobody signed. `active`: the current text is signed. `reacceptance_required`: an earlier text is signed and the current one is not; guardrails keep applying. `terminated`: a person ended it, and guardrails no longer apply.
- `eligible` (boolean): Whether the account may sign and change guardrails now: an organization whose Teams subscription pays for it, or an account on the enterprise plan.
- `requirement` ("plan_required" | "not_signed" | "reacceptance_required" | null): What stands between the account and changing guardrails; null when nothing does.
- `inForce` (boolean): Whether guardrails apply to the account's mail now. They go on applying when the plan lapses, and stop only when a person ends the agreement.
- `version` (string): The version of the current text.
- `documentSha256` (string): The SHA-256 of the current text.
- `agreement` (BaaAgreement | null): The most recent record; null when nobody ever signed.

Example 200 response:
```json
{
  "status": "not_signed",
  "eligible": true,
  "requirement": "not_signed",
  "inForce": false,
  "version": "2026-11-draft",
  "documentSha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "agreement": null
}
```

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s "https://api.doorman.fyi/v1/baa" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/baa", {
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.get(
    "https://api.doorman.fyi/v1/baa",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Read the agreement

`GET /v1/baa/document`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

The current text of the business associate agreement with its version and its SHA-256. A signature names both, so what is signed is what was read.

OAuth: not available to delegated app tokens.

Also available as [`client.baa.document`](https://doorman.fyi/docs/sdk/reference/healthcare.md#baa-document) in TypeScript and [`client.baa.document`](https://doorman.fyi/docs/python/reference/healthcare.md#baa-document) in Python.

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

Answers `200`: The text.

**Response 200: BaaDocument**
The current text of the business associate agreement, exactly as a signer is shown it.
- `version` (string)
- `sha256` (string): The SHA-256 of `text` as UTF-8. Signing names it, so what is signed is what was read.
- `title` (string)
- `text` (string): The agreement, as plain text.
- `placeholder` (boolean): True while the text is a draft that counsel has not approved. A deployment that serves a placeholder is not offering a binding agreement.

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s "https://api.doorman.fyi/v1/baa/document" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/baa/document", {
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.get(
    "https://api.doorman.fyi/v1/baa/document",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Sign the agreement

`POST /v1/baa/sign`

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

A signed-in person signs the current text for their organization: their name, their title, the legal entity, and their name typed again as the signature. The record keeps the version and the hash of the text, the time, the signer and the address the request came from. An account that is not eligible answers 403 `baa_required`. A `version` or `documentSha256` that is not the current text's answers 400 `validation_error`: read the document again. Signing the text that is already signed changes nothing. Guardrails apply from this moment with their defaults. Recorded in the audit log.

OAuth: not available to delegated app tokens.

Also available as [`client.baa.sign`](https://doorman.fyi/docs/sdk/reference/healthcare.md#baa-sign) in TypeScript and [`client.baa.sign`](https://doorman.fyi/docs/python/reference/healthcare.md#baa-sign) in Python.

Organizations: a member's console session needs `compliance:manage`. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Request body (application/json): SignBaa**
A signature on the current text. `version` and `documentSha256` name what was read; `signature` is the signer's name typed again.
- `version` (string)
- `documentSha256` (string)
- `name` (string): The signer's full name.
- `title` (string): The signer's title at the entity.
- `entity` (string): The legal entity the signer signs for and has authority to bind.
- `signature` (string): The signer's name, typed as their signature. It must equal `name`.
- `accept` (true): The signer's statement that they read the text and may bind the entity.

Answers `200`: The account's standing, with the record.

**Response 200: Baa**
Where the account stands with the business associate agreement, and whether it may sign.
- `status` ("not_signed" | "active" | "reacceptance_required" | "terminated"): `not_signed`: nobody signed. `active`: the current text is signed. `reacceptance_required`: an earlier text is signed and the current one is not; guardrails keep applying. `terminated`: a person ended it, and guardrails no longer apply.
- `eligible` (boolean): Whether the account may sign and change guardrails now: an organization whose Teams subscription pays for it, or an account on the enterprise plan.
- `requirement` ("plan_required" | "not_signed" | "reacceptance_required" | null): What stands between the account and changing guardrails; null when nothing does.
- `inForce` (boolean): Whether guardrails apply to the account's mail now. They go on applying when the plan lapses, and stop only when a person ends the agreement.
- `version` (string): The version of the current text.
- `documentSha256` (string): The SHA-256 of the current text.
- `agreement` (BaaAgreement | null): The most recent record; null when nobody ever signed.

Example 200 response:
```json
{
  "status": "not_signed",
  "eligible": true,
  "requirement": "not_signed",
  "inForce": false,
  "version": "2026-11-draft",
  "documentSha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "agreement": null
}
```

**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 | `baa_required` | Changing healthcare guardrails needs a business associate agreement in force. `baa` says what is missing: `plan_required` when the account is not an organization on the Teams plan or on the enterprise plan, `not_signed` when nobody signed, `reacceptance_required` when the agreement's text changed since. Someone who may manage compliance signs it in the console. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X POST "https://api.doorman.fyi/v1/baa/sign" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "version": "2026-11-draft",
    "documentSha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
    "name": "Dana Ortiz",
    "title": "Privacy Officer",
    "entity": "Acme Health, Inc.",
    "signature": "Dana Ortiz",
    "accept": true
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/baa/sign", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "version": "2026-11-draft",
    "documentSha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
    "name": "Dana Ortiz",
    "title": "Privacy Officer",
    "entity": "Acme Health, Inc.",
    "signature": "Dana Ortiz",
    "accept": true
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.post(
    "https://api.doorman.fyi/v1/baa/sign",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "version": "2026-11-draft",
        "documentSha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
        "name": "Dana Ortiz",
        "title": "Privacy Officer",
        "entity": "Acme Health, Inc.",
        "signature": "Dana Ortiz",
        "accept": True,
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## End the agreement

`POST /v1/baa/terminate`

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

Ends the agreement. Guardrails stop applying at once: keys, apps, webhooks and the stream are given mail as it arrived. The record is kept. An account with no agreement that stands answers 404. Recorded in the audit log.

OAuth: not available to delegated app tokens.

Also available as [`client.baa.terminate`](https://doorman.fyi/docs/sdk/reference/healthcare.md#baa-terminate) in TypeScript and [`client.baa.terminate`](https://doorman.fyi/docs/python/reference/healthcare.md#baa-terminate) in Python.

Organizations: a member's console session needs `compliance:manage`. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Request body (application/json): TerminateBaa**
Ends the agreement. From then on guardrails no longer apply and agents read mail as it arrived.
- `confirm` ("terminate"): The word `terminate`, so that nothing ends an agreement by accident.

Answers `200`: The account's standing.

**Response 200: Baa**
Where the account stands with the business associate agreement, and whether it may sign.
- `status` ("not_signed" | "active" | "reacceptance_required" | "terminated"): `not_signed`: nobody signed. `active`: the current text is signed. `reacceptance_required`: an earlier text is signed and the current one is not; guardrails keep applying. `terminated`: a person ended it, and guardrails no longer apply.
- `eligible` (boolean): Whether the account may sign and change guardrails now: an organization whose Teams subscription pays for it, or an account on the enterprise plan.
- `requirement` ("plan_required" | "not_signed" | "reacceptance_required" | null): What stands between the account and changing guardrails; null when nothing does.
- `inForce` (boolean): Whether guardrails apply to the account's mail now. They go on applying when the plan lapses, and stop only when a person ends the agreement.
- `version` (string): The version of the current text.
- `documentSha256` (string): The SHA-256 of the current text.
- `agreement` (BaaAgreement | null): The most recent record; null when nobody ever signed.

Example 200 response:
```json
{
  "status": "not_signed",
  "eligible": true,
  "requirement": "not_signed",
  "inForce": false,
  "version": "2026-11-draft",
  "documentSha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "agreement": null
}
```

**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 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X POST "https://api.doorman.fyi/v1/baa/terminate" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "confirm": "terminate"
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/baa/terminate", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "confirm": "terminate"
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.post(
    "https://api.doorman.fyi/v1/baa/terminate",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "confirm": "terminate",
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Read the guardrails

`GET /v1/guardrails`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

The account's built-in guardrails: whether they apply, which of the 14 kinds they look for, and what they do to mail that arrives and to what agents send. An account that never chose has every kind on, redacts inbound and holds outbound.

OAuth: not available to delegated app tokens.

Also available as [`client.guardrails.get`](https://doorman.fyi/docs/sdk/reference/healthcare.md#guardrails-get) in TypeScript and [`client.guardrails.get`](https://doorman.fyi/docs/python/reference/healthcare.md#guardrails-get) in Python.

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

Answers `200`: The account's guardrails.

**Response 200: GuardrailSettings**
The guardrails as they apply to the account or to one inbox, and whether they are in force.
- `scope` ("account" | "inbox")
- `inboxId` (string | null): The inbox the settings are for; null for the account's.
- `inherited` (boolean): Inbox scope: true while the inbox has no guardrails of its own and follows the account's. Always false for the account.
- `policy` (GuardrailPolicy)
- `inForce` (boolean): Whether these guardrails apply to mail now: the account has an agreement that stands, and `policy.enabled` is true.
- `baa` ("not_signed" | "active" | "reacceptance_required" | "terminated")
- `updatedAt` (string (date-time) | null): When the guardrails were last changed; null while they are the defaults.

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s "https://api.doorman.fyi/v1/guardrails" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/guardrails", {
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.get(
    "https://api.doorman.fyi/v1/guardrails",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Change the guardrails

`PATCH /v1/guardrails`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

Changes single values; fields left out stay as they are. Every inbox without guardrails of its own follows the account's. It needs an agreement in force and an eligible account (403 `baa_required`). A change that takes protection away needs a console session unless the account allows its account keys to (403 `session_required`); one that adds protection does not. Recorded in the audit log.

OAuth: not available to delegated app tokens.

Also available as [`client.guardrails.update`](https://doorman.fyi/docs/sdk/reference/healthcare.md#guardrails-update) in TypeScript and [`client.guardrails.update`](https://doorman.fyi/docs/python/reference/healthcare.md#guardrails-update) in Python.

Organizations: a member's console session needs `compliance:manage`. API keys and app tokens are not held to member permissions. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Request body (application/json): UpdateGuardrailPolicy**
Changes to the guardrails. Fields left out stay as they are; `entities` changes the kinds it names and leaves the others. A change that takes protection away needs a console session unless the account allows its account keys to.
- `enabled` (boolean, optional): Whether the guardrails apply at all. Off: nothing is detected, redacted, held or refused.
- `inbound` ("off" | "redact" | "hold", optional): What the built-in detectors do to mail that arrives. `redact`: each finding is replaced in everything a key, an app, a webhook, the stream or a model is given, and the original, its HTML and affected attachments are refused to them. `hold`: the message waits for the owner as held mail does. `off`: nothing.
- `outbound` ("off" | "hold" | "block", optional): What the built-in detectors do to a send by a key or an app. `block`: refused with 403 `risk_blocked` and the guard `guardrail`. `hold`: it waits for the owner as a held send. `off`: nothing. A person sending from the console is never refused.
- `entities` (object of boolean, optional): The kinds to switch on or off.

Answers `200`: The guardrails as they are now.

**Response 200: GuardrailSettings**
The guardrails as they apply to the account or to one inbox, and whether they are in force.
- `scope` ("account" | "inbox")
- `inboxId` (string | null): The inbox the settings are for; null for the account's.
- `inherited` (boolean): Inbox scope: true while the inbox has no guardrails of its own and follows the account's. Always false for the account.
- `policy` (GuardrailPolicy)
- `inForce` (boolean): Whether these guardrails apply to mail now: the account has an agreement that stands, and `policy.enabled` is true.
- `baa` ("not_signed" | "active" | "reacceptance_required" | "terminated")
- `updatedAt` (string (date-time) | null): When the guardrails were last changed; null while they are the defaults.

**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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `baa_required` | Changing healthcare guardrails needs a business associate agreement in force. `baa` says what is missing: `plan_required` when the account is not an organization on the Teams plan or on the enterprise plan, `not_signed` when nobody signed, `reacceptance_required` when the agreement's text changed since. Someone who may manage compliance signs it in the console. |
| 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 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X PATCH "https://api.doorman.fyi/v1/guardrails" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "outbound": "block"
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/guardrails", {
  method: "PATCH",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "outbound": "block"
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.patch(
    "https://api.doorman.fyi/v1/guardrails",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "outbound": "block",
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Read an inbox's guardrails

`GET /v1/inboxes/{inboxId}/guardrails`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

The guardrails in force for one inbox: its own when it has them, the account's otherwise (`inherited` says which).

OAuth: not available to delegated app tokens.

Also available as [`client.inboxes.guardrails.get`](https://doorman.fyi/docs/sdk/reference/healthcare.md#inboxes-guardrails-get) in TypeScript and [`client.inboxes.guardrails.get`](https://doorman.fyi/docs/python/reference/healthcare.md#inboxes-guardrails-get) in Python.

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 |
| --- | --- | --- | --- | --- |
| `inboxId` | path | `string` | yes | The inbox. Example: `inb_01jc4q7w9k2m5n8p3r6t1v4x7z`. |

Answers `200`: The inbox's guardrails.

**Response 200: GuardrailSettings**
The guardrails as they apply to the account or to one inbox, and whether they are in force.
- `scope` ("account" | "inbox")
- `inboxId` (string | null): The inbox the settings are for; null for the account's.
- `inherited` (boolean): Inbox scope: true while the inbox has no guardrails of its own and follows the account's. Always false for the account.
- `policy` (GuardrailPolicy)
- `inForce` (boolean): Whether these guardrails apply to mail now: the account has an agreement that stands, and `policy.enabled` is true.
- `baa` ("not_signed" | "active" | "reacceptance_required" | "terminated")
- `updatedAt` (string (date-time) | null): When the guardrails were last changed; null while they are the defaults.

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s "https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails", {
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.get(
    "https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Give an inbox its own guardrails

`PATCH /v1/inboxes/{inboxId}/guardrails`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

Starts from the guardrails in force for the inbox and applies the change; from then on the inbox no longer follows the account's. It needs an agreement in force and an eligible account (403 `baa_required`). A change that takes protection away needs a console session unless the account allows its account keys to (403 `session_required`); one that adds protection does not. Recorded in the audit log.

OAuth: not available to delegated app tokens.

Also available as [`client.inboxes.guardrails.update`](https://doorman.fyi/docs/sdk/reference/healthcare.md#inboxes-guardrails-update) in TypeScript and [`client.inboxes.guardrails.update`](https://doorman.fyi/docs/python/reference/healthcare.md#inboxes-guardrails-update) in Python.

Organizations: a member's console session needs `compliance:manage`. API keys and app tokens are not held to member permissions. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `inboxId` | path | `string` | yes | The inbox. Example: `inb_01jc4q7w9k2m5n8p3r6t1v4x7z`. |

**Request body (application/json): UpdateGuardrailPolicy**
Changes to the guardrails. Fields left out stay as they are; `entities` changes the kinds it names and leaves the others. A change that takes protection away needs a console session unless the account allows its account keys to.
- `enabled` (boolean, optional): Whether the guardrails apply at all. Off: nothing is detected, redacted, held or refused.
- `inbound` ("off" | "redact" | "hold", optional): What the built-in detectors do to mail that arrives. `redact`: each finding is replaced in everything a key, an app, a webhook, the stream or a model is given, and the original, its HTML and affected attachments are refused to them. `hold`: the message waits for the owner as held mail does. `off`: nothing.
- `outbound` ("off" | "hold" | "block", optional): What the built-in detectors do to a send by a key or an app. `block`: refused with 403 `risk_blocked` and the guard `guardrail`. `hold`: it waits for the owner as a held send. `off`: nothing. A person sending from the console is never refused.
- `entities` (object of boolean, optional): The kinds to switch on or off.

Answers `200`: The inbox's guardrails as they are now.

**Response 200: GuardrailSettings**
The guardrails as they apply to the account or to one inbox, and whether they are in force.
- `scope` ("account" | "inbox")
- `inboxId` (string | null): The inbox the settings are for; null for the account's.
- `inherited` (boolean): Inbox scope: true while the inbox has no guardrails of its own and follows the account's. Always false for the account.
- `policy` (GuardrailPolicy)
- `inForce` (boolean): Whether these guardrails apply to mail now: the account has an agreement that stands, and `policy.enabled` is true.
- `baa` ("not_signed" | "active" | "reacceptance_required" | "terminated")
- `updatedAt` (string (date-time) | null): When the guardrails were last changed; null while they are the defaults.

**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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `baa_required` | Changing healthcare guardrails needs a business associate agreement in force. `baa` says what is missing: `plan_required` when the account is not an organization on the Teams plan or on the enterprise plan, `not_signed` when nobody signed, `reacceptance_required` when the agreement's text changed since. Someone who may manage compliance signs it in the console. |
| 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 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X PATCH "https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "outbound": "block"
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails", {
  method: "PATCH",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "outbound": "block"
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.patch(
    "https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "outbound": "block",
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Return an inbox to the account's guardrails

`DELETE /v1/inboxes/{inboxId}/guardrails`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

Removes the inbox's own guardrails, so it follows the account's again. It needs an agreement in force and an eligible account (403 `baa_required`). A change that takes protection away needs a console session unless the account allows its account keys to (403 `session_required`); one that adds protection does not. Recorded in the audit log.

OAuth: not available to delegated app tokens.

Also available as [`client.inboxes.guardrails.reset`](https://doorman.fyi/docs/sdk/reference/healthcare.md#inboxes-guardrails-reset) in TypeScript and [`client.inboxes.guardrails.reset`](https://doorman.fyi/docs/python/reference/healthcare.md#inboxes-guardrails-reset) in Python.

Organizations: a member's console session needs `compliance:manage`. API keys and app tokens are not held to member permissions. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `inboxId` | path | `string` | yes | The inbox. Example: `inb_01jc4q7w9k2m5n8p3r6t1v4x7z`. |

Answers `204`: The inbox follows the account's guardrails.

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `baa_required` | Changing healthcare guardrails needs a business associate agreement in force. `baa` says what is missing: `plan_required` when the account is not an organization on the Teams plan or on the enterprise plan, `not_signed` when nobody signed, `reacceptance_required` when the agreement's text changed since. Someone who may manage compliance signs it in the console. |
| 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 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X DELETE "https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails", {
  method: "DELETE",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
// 204: nothing to read.
```

Python:
```python
import os
import requests

response = requests.delete(
    "https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/guardrails",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
# 204: nothing to read.
```

## List custom guardrails

`GET /v1/guardrails/rules`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

The account's custom guardrails, oldest first: the terms and patterns of its own that are redacted, held or refused beside the built-in kinds. What each one matches (`value`) is shown to a caller that may change guardrails and is null for everyone else, since it is what the guardrail keeps from agents.

OAuth: not available to delegated app tokens.

Also available as [`client.guardrails.rules.list`](https://doorman.fyi/docs/sdk/reference/healthcare.md#guardrails-rules-list) in TypeScript and [`client.guardrails.rules.list`](https://doorman.fyi/docs/python/reference/healthcare.md#guardrails-rules-list) in Python.

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 |
| --- | --- | --- | --- | --- |
| `inboxId` | query | `string` | no | Only the guardrails that apply to this inbox alone. Omit for every guardrail of the account. Example: `inb_01jc4q7w9k2m5n8p3r6t1v4x7z`. |

Answers `200`: The guardrails.

**Response 200: GuardrailRuleList**
The account's custom guardrails, oldest first.
- `data` (GuardrailRule[])

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 400 | `validation_error` | A field is missing or invalid; the message names it. |
| 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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s "https://api.doorman.fyi/v1/guardrails/rules" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/guardrails/rules", {
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.get(
    "https://api.doorman.fyi/v1/guardrails/rules",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Write a custom guardrail

`POST /v1/guardrails/rules`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

A term or a pattern of the account's own, for the whole account or one inbox. A term is matched whole and without regard to case. A pattern is a mask and not a regular expression: `#` is a digit, `@` a letter, `*` either, any other character itself, and `{n}` or `{n,m}` a count, so `MRN-#{6,10}` is `MRN-` and six to ten digits. Each part takes as many characters as it can, so a part whose length varies cannot be followed by one that could take the same characters. A match is reported as the kind `custom`. An account holds at most 50. It needs an agreement in force and an eligible account (403 `baa_required`). Recorded in the audit log by name, never by what it matches.

OAuth: not available to delegated app tokens.

Also available as [`client.guardrails.rules.create`](https://doorman.fyi/docs/sdk/reference/healthcare.md#guardrails-rules-create) in TypeScript and [`client.guardrails.rules.create`](https://doorman.fyi/docs/python/reference/healthcare.md#guardrails-rules-create) in Python.

Organizations: a member's console session needs `compliance:manage`. API keys and app tokens are not held to member permissions. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Request body (application/json): CreateGuardrailRule**
A custom guardrail: a term or a pattern of your own, with what a match does in each direction, for the whole account or one inbox.
- `name` (string): A label, at most 80 characters. It appears in the console and the audit log, so it should not itself be sensitive. Example: `Study participant ids`
- `kind` ("term" | "pattern"): `term`: a word or phrase, matched whole and without regard to case. `pattern`: a mask, where `#` is a digit, `@` a letter, `*` either, any other character itself, and `{n}` or `{n,m}` a count, as in `MRN-#{6,10}`. A pattern is not a regular expression.
- `value` (string): The term or the pattern. Example: `PT-#{6}`
- `inbound` ("off" | "redact" | "hold", optional): What a match does to mail that arrives. Defaults to `redact`.
- `outbound` ("off" | "hold" | "block", optional): What a match does to a send by a key or an app. Defaults to `off`.
- `enabled` (boolean, optional): Whether the guardrail applies. Defaults to true.
- `inboxId` (string, optional): Apply to this inbox only. Omit for every inbox of the account. Example: `inb_01jc4q7w9k2m5n8p3r6t1v4x7z`

Answers `201`: The guardrail.

**Response 201: GuardrailRule**
A custom guardrail: what it matches, what a match does, and where it applies.
- `id` (string): A custom guardrail's identifier. Example: `grd_01jc5f1a2b3c4d5e6f7g8h9j0k`
- `name` (string)
- `kind` ("term" | "pattern")
- `value` (string | null): The term or the pattern, for a caller that may change guardrails: a signed-in person who holds `compliance:manage`, or an account key where the account lets its keys manage security. Null for every other caller: what a guardrail matches is what it keeps from agents, so a key an agent holds is not told it.
- `inbound` ("off" | "redact" | "hold")
- `outbound` ("off" | "hold" | "block")
- `enabled` (boolean)
- `inboxId` (string | null): The inbox the guardrail applies to; null for the whole account.
- `createdAt` (string (date-time)) Example: `2026-11-05T10:05:00.000Z`
- `updatedAt` (string (date-time)) Example: `2026-11-05T10:05:00.000Z`

Example 201 response:
```json
{
  "id": "grd_01jc5f1a2b3c4d5e6f7g8h9j0k",
  "name": "Study participant ids",
  "kind": "pattern",
  "value": "PT-#{6}",
  "inbound": "redact",
  "outbound": "block",
  "enabled": true,
  "inboxId": null,
  "createdAt": "2026-11-05T10:05:00.000Z",
  "updatedAt": "2026-11-05T10:05:00.000Z"
}
```

**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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `baa_required` | Changing healthcare guardrails needs a business associate agreement in force. `baa` says what is missing: `plan_required` when the account is not an organization on the Teams plan or on the enterprise plan, `not_signed` when nobody signed, `reacceptance_required` when the agreement's text changed since. Someone who may manage compliance signs it in the console. |
| 403 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 409 | `limit_reached` | The abuse ceiling for inboxes, custom domains, keys, endpoints, services, relying parties, the services an address signs in to, the sends an inbox has waiting for its owner or the invitations an organization has open; delete, revoke or decide one first. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X POST "https://api.doorman.fyi/v1/guardrails/rules" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "name": "Study participant ids",
    "kind": "pattern",
    "value": "PT-#{6}",
    "inbound": "redact",
    "outbound": "block"
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/guardrails/rules", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "name": "Study participant ids",
    "kind": "pattern",
    "value": "PT-#{6}",
    "inbound": "redact",
    "outbound": "block"
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.post(
    "https://api.doorman.fyi/v1/guardrails/rules",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "name": "Study participant ids",
        "kind": "pattern",
        "value": "PT-#{6}",
        "inbound": "redact",
        "outbound": "block",
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Change a custom guardrail

`PATCH /v1/guardrails/rules/{guardrailId}`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

Changes its name, what a match does or whether it applies. What it matches cannot be changed. It needs an agreement in force and an eligible account (403 `baa_required`). A change that takes protection away needs a console session unless the account allows its account keys to (403 `session_required`); one that adds protection does not. Recorded in the audit log.

OAuth: not available to delegated app tokens.

Also available as [`client.guardrails.rules.update`](https://doorman.fyi/docs/sdk/reference/healthcare.md#guardrails-rules-update) in TypeScript and [`client.guardrails.rules.update`](https://doorman.fyi/docs/python/reference/healthcare.md#guardrails-rules-update) in Python.

Organizations: a member's console session needs `compliance:manage`. API keys and app tokens are not held to member permissions. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `guardrailId` | path | `string` | yes | The custom guardrail. Example: `grd_01jc5f1a2b3c4d5e6f7g8h9j0k`. |

**Request body (application/json): UpdateGuardrailRule**
Changes to a custom guardrail. What it matches cannot be changed: remove it and write another. Switching it off or lowering an action takes protection away and needs a console session unless the account allows its account keys to.
- `name` (string, optional): A label, at most 80 characters. It appears in the console and the audit log, so it should not itself be sensitive. Example: `Study participant ids`
- `inbound` ("off" | "redact" | "hold", optional): What a match does to mail that arrives. Defaults to `redact`.
- `outbound` ("off" | "hold" | "block", optional): What a match does to a send by a key or an app. Defaults to `off`.
- `enabled` (boolean, optional): Whether the guardrail applies. Defaults to true.

Answers `200`: The guardrail as it is now.

**Response 200: GuardrailRule**
A custom guardrail: what it matches, what a match does, and where it applies.
- `id` (string): A custom guardrail's identifier. Example: `grd_01jc5f1a2b3c4d5e6f7g8h9j0k`
- `name` (string)
- `kind` ("term" | "pattern")
- `value` (string | null): The term or the pattern, for a caller that may change guardrails: a signed-in person who holds `compliance:manage`, or an account key where the account lets its keys manage security. Null for every other caller: what a guardrail matches is what it keeps from agents, so a key an agent holds is not told it.
- `inbound` ("off" | "redact" | "hold")
- `outbound` ("off" | "hold" | "block")
- `enabled` (boolean)
- `inboxId` (string | null): The inbox the guardrail applies to; null for the whole account.
- `createdAt` (string (date-time)) Example: `2026-11-05T10:05:00.000Z`
- `updatedAt` (string (date-time)) Example: `2026-11-05T10:05:00.000Z`

Example 200 response:
```json
{
  "id": "grd_01jc5f1a2b3c4d5e6f7g8h9j0k",
  "name": "Study participant ids",
  "kind": "pattern",
  "value": "PT-#{6}",
  "inbound": "redact",
  "outbound": "block",
  "enabled": true,
  "inboxId": null,
  "createdAt": "2026-11-05T10:05:00.000Z",
  "updatedAt": "2026-11-05T10:05:00.000Z"
}
```

**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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `baa_required` | Changing healthcare guardrails needs a business associate agreement in force. `baa` says what is missing: `plan_required` when the account is not an organization on the Teams plan or on the enterprise plan, `not_signed` when nobody signed, `reacceptance_required` when the agreement's text changed since. Someone who may manage compliance signs it in the console. |
| 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 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X PATCH "https://api.doorman.fyi/v1/guardrails/rules/grd_01jc5f1a2b3c4d5e6f7g8h9j0k" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "outbound": "hold"
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/guardrails/rules/grd_01jc5f1a2b3c4d5e6f7g8h9j0k", {
  method: "PATCH",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "outbound": "hold"
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.patch(
    "https://api.doorman.fyi/v1/guardrails/rules/grd_01jc5f1a2b3c4d5e6f7g8h9j0k",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "outbound": "hold",
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Remove a custom guardrail

`DELETE /v1/guardrails/rules/{guardrailId}`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

What it matched is no longer redacted, held or refused, in mail that already arrived too. It needs an agreement in force and an eligible account (403 `baa_required`). Removing one takes protection away, so it needs a console session unless the account allows its account keys to (403 `session_required`). Recorded in the audit log.

OAuth: not available to delegated app tokens.

Also available as [`client.guardrails.rules.delete`](https://doorman.fyi/docs/sdk/reference/healthcare.md#guardrails-rules-delete) in TypeScript and [`client.guardrails.rules.delete`](https://doorman.fyi/docs/python/reference/healthcare.md#guardrails-rules-delete) in Python.

Organizations: a member's console session needs `compliance:manage`. API keys and app tokens are not held to member permissions. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `guardrailId` | path | `string` | yes | The custom guardrail. Example: `grd_01jc5f1a2b3c4d5e6f7g8h9j0k`. |

Answers `204`: Removed.

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `baa_required` | Changing healthcare guardrails needs a business associate agreement in force. `baa` says what is missing: `plan_required` when the account is not an organization on the Teams plan or on the enterprise plan, `not_signed` when nobody signed, `reacceptance_required` when the agreement's text changed since. Someone who may manage compliance signs it in the console. |
| 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 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X DELETE "https://api.doorman.fyi/v1/guardrails/rules/grd_01jc5f1a2b3c4d5e6f7g8h9j0k" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/guardrails/rules/grd_01jc5f1a2b3c4d5e6f7g8h9j0k", {
  method: "DELETE",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
// 204: nothing to read.
```

Python:
```python
import os
import requests

response = requests.delete(
    "https://api.doorman.fyi/v1/guardrails/rules/grd_01jc5f1a2b3c4d5e6f7g8h9j0k",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
# 204: nothing to read.
```

## Preview what the guardrails do to a text

`POST /v1/guardrails/preview`

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`.

Runs the guardrails in force, or a draft of them, over a text of your own and answers what an agent would be given, what was found and what would happen. It works before an agreement is signed, so a team can see what it would get. Nothing is stored, sent or changed, and no model is called.

OAuth: not available to delegated app tokens.

Also available as [`client.guardrails.preview`](https://doorman.fyi/docs/sdk/reference/healthcare.md#guardrails-preview) in TypeScript and [`client.guardrails.preview`](https://doorman.fyi/docs/python/reference/healthcare.md#guardrails-preview) in Python.

Organizations: a member's console session needs `compliance:manage`. API keys and app tokens are not held to member permissions. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Request body (application/json): GuardrailPreviewRequest**
Text to run the guardrails over. Nothing is stored or sent. Give `policy` or `rule` to try a change before making it.
- `text` (string)
- `subject` (string, optional)
- `direction` ("inbound" | "outbound", optional): Whether the text is mail that arrives or a send by an agent. Defaults to `inbound`.
- `inboxId` (string, optional): Evaluate as this inbox: its guardrails and its custom guardrails. Defaults to the account's. Example: `inb_01jc4q7w9k2m5n8p3r6t1v4x7z`
- `policy` (UpdateGuardrailPolicy, optional): A draft, applied over the guardrails in force.
- `rule` (object, optional): A custom guardrail to try beside the ones that exist.
  - `kind` ("term" | "pattern"): `term`: a word or phrase, matched whole and without regard to case. `pattern`: a mask, where `#` is a digit, `@` a letter, `*` either, any other character itself, and `{n}` or `{n,m}` a count, as in `MRN-#{6,10}`. A pattern is not a regular expression.
  - `value` (string): The term or the pattern. Example: `PT-#{6}`
  - `inbound` ("off" | "redact" | "hold", optional): What a match does to mail that arrives. Defaults to `redact`.
  - `outbound` ("off" | "hold" | "block", optional): What a match does to a send by a key or an app. Defaults to `off`.

Answers `200`: The redacted text, the findings and the action.

**Response 200: GuardrailPreview**
What the guardrails do with the text: what an agent would be given, what was found, and what would happen to the message. The preview applies the guardrails as if an agreement were in force, whatever the account's standing.
- `text` (string): The text with every finding replaced.
- `subject` (string | null): The subject with every finding replaced; null when none was given.
- `redaction` (Redaction)
- `action` ("none" | "redact" | "hold" | "block"): The strictest thing a match asks for in this direction: `none` when nothing matched or everything that matched is off.

Example 200 response:
```json
{
  "text": "Patient: [REDACTED:PATIENT_NAME], DOB [REDACTED:DATE_OF_BIRTH], SSN [REDACTED:SSN].",
  "subject": null,
  "redaction": {
    "applied": true,
    "entities": [
      {
        "type": "ssn",
        "count": 1
      },
      {
        "type": "date_of_birth",
        "count": 1
      },
      {
        "type": "patient_name",
        "count": 1
      }
    ]
  },
  "action": "redact"
}
```

**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 | `forbidden` | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 403 | `insufficient_scope` | The app's token lacks a required scope, or the operation cannot be delegated. |
| 403 | `account_suspended` | The account is suspended. |
| 403 | `account_deleted` | The account was deleted. |
| 403 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s -X POST "https://api.doorman.fyi/v1/guardrails/preview" \
  -H "authorization: Bearer $DOORMAN_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "text": "Patient: Sam Rivera, DOB 04/12/1984, SSN 536-22-8726."
  }'
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/guardrails/preview", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
    "content-type": "application/json",
  },
  redirect: "manual", credentials: "omit",
  body: JSON.stringify({
    "text": "Patient: Sam Rivera, DOB 04/12/1984, SSN 536-22-8726."
  }),
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.post(
    "https://api.doorman.fyi/v1/guardrails/preview",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    json={
        "text": "Patient: Sam Rivera, DOB 04/12/1984, SSN 536-22-8726.",
    },
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Read a message as it arrived

`GET /v1/messages/{messageId}/original`

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

The message without the placeholders the guardrails put in everything else: for a signed-in person who holds `phi:read`, and for nobody else. `redaction.applied` is false and `redaction.entities` says what the guardrails found. Every read of a message that carries findings is recorded in the audit log by the message's id. Every other read of a message, by a person too, carries the placeholders. The same permission opens the original message, its HTML body and its attachments to a person where the guardrails refuse them to keys and apps.

OAuth: not available to delegated app tokens.

Also available as [`client.messages.original`](https://doorman.fyi/docs/sdk/reference/healthcare.md#messages-original) in TypeScript and [`client.messages.original`](https://doorman.fyi/docs/python/reference/healthcare.md#messages-original) in Python.

Organizations: a member's console session needs `phi:read` and `mail:read`. See [Roles and permissions](https://doorman.fyi/docs/organizations.md#roles).

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `messageId` | path | `string` | yes | The message. Example: `msg_01jc5a6g7h8j9k0m1n2p3q4r5s`. |

Answers `200`: The message as it arrived.

**Response 200: Message**
One message, inbound or outbound, with its text, headers, classification and attachments.
- `id` (string): A message identifier. Example: `msg_01jc5a6g7h8j9k0m1n2p3q4r5s`
- `inboxId` (string): An inbox identifier. Example: `inb_01jc4q7w9k2m5n8p3r6t1v4x7z`
- `threadId` (string): A thread identifier. Example: `thr_01jc5a1b2c3d4e5f6g7h8j9k0m`
- `direction` ("inbound" | "outbound")
- `rfcMessageId` (string | null): The Message-ID header of inbound mail; null for mail this API sent. Example: `<a1b2c3@example.com>`
- `inReplyTo` (string | null): The In-Reply-To header, when the message is a reply.
- `references` (string[]): The References chain, oldest first.
- `from` (NamedAddress)
- `to` (NamedAddress[])
- `cc` (NamedAddress[])
- `bcc` (NamedAddress[]): Only outbound mail carries blind copies.
- `replyTo` (string | null): The Reply-To address, when one was given.
- `deliveryRole` ("to" | "cc" | "bcc" | null): How the inbox received the message: as a to, cc or bcc recipient. Null for outbound mail.
- `subject` (string) Example: `Invoice 2847`
- `text` (string | null): The plain-text body, or text derived from the HTML when there was none.
- `hasHtml` (boolean): Whether an HTML body is stored; read it at /v1/messages/{messageId}/html.
- `rawUrl` (string | null): Where to download the original message/rfc822; null for outbound mail.
- `sizeBytes` (integer)
- `category` ("personal" | "automated" | "marketing" | "bounce" | "spam" | "malicious"): What kind of mail this is; ordinary outbound mail is personal and rule-generated mail is automated.
- `autoReplyable` (boolean): False for anything an agent should not answer on its own.
- `verdict` ("clean" | "unverified" | "suspicious" | null): From the authentication results; null for outbound mail.
- `spamScore` (number | null): How likely the message is junk, from 0 to 1, when it was assessed; null otherwise.
- `authentication` (AuthenticationResults | null)
- `service` (MessageService | null, optional): The outside service the message came from, for the inbox's passport; null for any other mail and for outbound mail. Older deployments omit it.
- `risk` (RiskAssessment | null, optional): Doorman's assessment of an inbound message (ADR-019). Null for outbound mail and for mail that was not assessed. Older deployments omit it.
- `redaction` (Redaction, optional): What the account's healthcare guardrails found in the message (ADR-027), and whether `subject`, `text` and the attachments' `parsedText` carry placeholders in place of it. Absent where no guardrail applies.
- `occurredAt` (string (date-time)): When the message arrived or was sent. Example: `2026-11-05T10:05:00.000Z`
- `attachments` (Attachment[])

Example 200 response:
```json
{
  "id": "msg_01jc5a6g7h8j9k0m1n2p3q4r5s",
  "inboxId": "inb_01jc4q7w9k2m5n8p3r6t1v4x7z",
  "threadId": "thr_01jc5a1b2c3d4e5f6g7h8j9k0m",
  "direction": "inbound",
  "rfcMessageId": "<a1b2c3@example.com>",
  "inReplyTo": null,
  "references": [],
  "from": {
    "address": "sam@example.com",
    "name": "Sam Rivera"
  },
  "to": [
    {
      "address": "concierge@doorman.example",
      "name": null
    }
  ],
  "cc": [],
  "bcc": [],
  "replyTo": null,
  "deliveryRole": "to",
  "subject": "Invoice 2847",
  "text": "Hi, invoice 2847 is attached.",
  "hasHtml": true,
  "rawUrl": "https://api.doorman.example/v1/messages/msg_01jc5a6g7h8j9k0m1n2p3q4r5s/raw",
  "sizeBytes": 48120,
  "category": "personal",
  "autoReplyable": true,
  "verdict": "clean",
  "spamScore": 0.02,
  "authentication": {
    "spf": "pass",
    "dkim": "pass",
    "dmarc": "pass"
  },
  "risk": {
    "score": 6,
    "level": "low",
    "labels": [],
    "reasons": [],
    "sender": {
      "standing": "known",
      "authenticated": true
    },
    "action": "delivered",
    "analysis": "full",
    "review": null
  },
  "occurredAt": "2026-11-05T10:05:00.000Z",
  "attachments": [
    {
      "filename": "invoice.pdf",
      "contentType": "application/pdf",
      "sizeBytes": 45000,
      "url": "https://api.doorman.example/v1/attachments/msg_01jc5a6g7h8j9k0m1n2p3q4r5s/invoice.pdf",
      "parsedText": "Invoice 2847. Line 3: Setup fee, billed twice. Total 1,480.",
      "extractionMethod": "pdf"
    }
  ]
}
```

**Errors**

| Status | Error | Meaning |
| --- | --- | --- |
| 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 | `permission_denied` | The signed-in member's role in the organization lacks a permission the operation needs; `permission` names it. An admin of the organization can do it, or change the member's role. |
| 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. |
| 404 | `not_found` | No such resource for this caller, or no such route. |
| 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. |
| 500 | `internal_error` | Something went wrong on the server. |

curl:
```sh
curl -s "https://api.doorman.fyi/v1/messages/msg_01jc5a6g7h8j9k0m1n2p3q4r5s/original" \
  -H "authorization: Bearer $DOORMAN_API_KEY"
```

TypeScript:
```ts
const response = await fetch("https://api.doorman.fyi/v1/messages/msg_01jc5a6g7h8j9k0m1n2p3q4r5s/original", {
  headers: {
    authorization: `Bearer ${process.env.DOORMAN_API_KEY}`,
  },
  redirect: "manual", credentials: "omit",
});
if (!response.ok) throw new Error(`The API answered ${response.status}.`);
const result = await response.json();
```

Python:
```python
import os
import requests

response = requests.get(
    "https://api.doorman.fyi/v1/messages/msg_01jc5a6g7h8j9k0m1n2p3q4r5s/original",
    headers={"authorization": f"Bearer {os.environ['DOORMAN_API_KEY']}"},
    allow_redirects=False, timeout=30,
)
response.raise_for_status()
result = response.json()
```
