{
  "openapi": "3.1.0",
  "info": {
    "title": "Supportress API",
    "version": "1",
    "description": "The REST API and intake API of a Supportress organization. Every call goes to your organization's own address. Errors are always `{ \"error\": { \"code\", \"message\" } }`. The guide is at https://supportress.app/docs/api."
  },
  "servers": [
    {
      "url": "https://{organization}.supportress.app/api/v1",
      "description": "Your organization",
      "variables": {
        "organization": {
          "default": "desk",
          "description": "Your organization's address, the part before .supportress.app."
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Webhooks",
      "description": "Organization admins can register up to ten endpoints. Verify Supportress-Signature by computing HMAC-SHA256 over the timestamp, a dot, and the raw body. Reject timestamps older than five minutes and compare the candidate signatures in constant time. Use Supportress-Event-Id to ignore duplicate deliveries. Delivery order is not guaranteed."
    },
    {
      "name": "Intake",
      "description": "Your own app or site files tickets with a team's intake key."
    },
    {
      "name": "Teams",
      "description": "What the desk supports. Each desk names them its own way."
    },
    {
      "name": "Tickets",
      "description": "Reading, opening, changing, merging and linking tickets."
    },
    {
      "name": "Chats",
      "description": "Reading chat conversations, their transcripts and handler history."
    },
    {
      "name": "Views",
      "description": "Saved views: named ticket filters, a person's own or shared with the desk."
    },
    {
      "name": "Messages",
      "description": "Replies, internal notes, files and drafts."
    },
    {
      "name": "Macros",
      "description": "Saved replies with field changes."
    },
    {
      "name": "Automations",
      "description": "Triggers (run when a ticket is created or changed) and automations (run on a clock)."
    },
    {
      "name": "Knowledge base",
      "description": "Help articles in Markdown per team, with categories and history (SUPT-51). AI agents' keys read only."
    },
    {
      "name": "Customers",
      "description": "The people who write in."
    },
    {
      "name": "Mail domains",
      "description": "Receiving support mail on your own domain."
    },
    {
      "name": "Throwaway mail",
      "description": "Temporary mailboxes for testing sign-in and other flows."
    },
    {
      "name": "Spam",
      "description": "The spam check, and the block and allow lists."
    },
    {
      "name": "Alerts",
      "description": "Email alerts for new tickets and customer replies."
    },
    {
      "name": "AI",
      "description": "AI triage, reply prediction and AI spend."
    },
    {
      "name": "Configuration",
      "description": "Support as prompt: propose typed configuration changes from plain words with a 30-day dry-run, apply as one undoable config event, and read current safe config."
    },
    {
      "name": "Dev issues",
      "description": "Filing and following bugs in your dev tracker."
    },
    {
      "name": "Reference",
      "description": "This description."
    }
  ],
  "security": [
    {
      "token": []
    }
  ],
  "paths": {
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook endpoints",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "{ webhooks }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWebhook",
        "tags": [
          "Webhooks"
        ],
        "summary": "Register a webhook and return its signing secret once",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Public HTTPS receiver URL."
                  },
                  "events": {
                    "type": "array",
                    "description": "Ticket events to deliver. Defaults to all ticket events on creation.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "teams": {
                    "type": "array",
                    "description": "Team IDs or slugs. An empty list includes every team.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional endpoint description."
                  },
                  "paused": {
                    "type": "boolean",
                    "description": "Whether regular delivery is paused."
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ webhook, secret }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}": {
      "get": {
        "operationId": "getWebhook",
        "tags": [
          "Webhooks"
        ],
        "summary": "Read a webhook endpoint",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ webhook }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateWebhook",
        "tags": [
          "Webhooks"
        ],
        "summary": "Update, pause or rotate a webhook",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Public HTTPS receiver URL."
                  },
                  "events": {
                    "type": "array",
                    "description": "Ticket events to deliver. Defaults to all ticket events on creation.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "teams": {
                    "type": "array",
                    "description": "Team IDs or slugs. An empty list includes every team.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional endpoint description."
                  },
                  "paused": {
                    "type": "boolean",
                    "description": "Whether regular delivery is paused."
                  },
                  "rotateSecret": {
                    "type": "boolean",
                    "description": "Generate and return a new signing secret once. The previous key signs for 24 hours."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ webhook, secret? }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteWebhook",
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete a webhook and its deliveries",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ deleted: true }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}/ping": {
      "post": {
        "operationId": "pingWebhook",
        "tags": [
          "Webhooks"
        ],
        "summary": "Queue a test delivery",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "{ eventId }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}/deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "tags": [
          "Webhooks"
        ],
        "summary": "List recent delivery attempts",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum attempts to return, from 1 to 100. Defaults to 50.",
            "schema": {
              "type": "integer",
              "description": "Maximum attempts to return, from 1 to 100. Defaults to 50."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ deliveries }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/scripts": {
      "get": {
        "operationId": "listChatScripts",
        "tags": [
          "Chats"
        ],
        "summary": "List a team's scripts",
        "description": "Requires a current organization admin. Returns up to 200 drafts, published and archived scripts.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ scripts }`, including graph, revision and publishedVersion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createChatScript",
        "tags": [
          "Chats"
        ],
        "summary": "Create a draft script",
        "description": "Requires a current organization admin and write token. Graphs are data; publishing validates every path. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "A short name."
                  },
                  "graph": {
                    "type": "object",
                    "description": "A graph: start, attributes and typed steps."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The draft script with revision 1.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/scripts/recipient": {
      "post": {
        "operationId": "requestChatScriptRecipient",
        "tags": [
          "Chats"
        ],
        "summary": "Request confirmation of a script forwarding address",
        "description": "Requires a current organization admin. Only the address owner can confirm, by following the link in the verification email. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "type": "string",
                    "description": "A forwarding email address."
                  }
                },
                "required": [
                  "address"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ address, confirmed }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/scripts/{id}": {
      "get": {
        "operationId": "getChatScript",
        "tags": [
          "Chats"
        ],
        "summary": "Read a script",
        "description": "Requires a current organization admin. Scoped to this team and organization.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The script, including editable graph, revision and publishedVersion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "editChatScript",
        "tags": [
          "Chats"
        ],
        "summary": "Edit a script draft",
        "description": "Edits never change an existing published version. Requires a current organization admin. A stale revision returns 409 script_changed. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedRevision": {
                    "type": "integer",
                    "description": "The revision last read."
                  },
                  "name": {
                    "type": "string",
                    "description": "A short name."
                  },
                  "graph": {
                    "type": "object",
                    "description": "The whole replacement graph."
                  },
                  "status": {
                    "type": "string",
                    "description": "draft or archived."
                  }
                },
                "required": [
                  "expectedRevision"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The script with a new revision.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "archiveChatScript",
        "tags": [
          "Chats"
        ],
        "summary": "Archive a script",
        "description": "Requires a current organization admin. Stops new chats selecting it; retains versions for running chats. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedRevision": {
                    "type": "integer",
                    "description": "The revision last read."
                  }
                },
                "required": [
                  "expectedRevision"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The archived script.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/scripts/{id}/validate": {
      "post": {
        "operationId": "validateChatScript",
        "tags": [
          "Chats"
        ],
        "summary": "Check every script path",
        "description": "Requires a current organization admin. Reports malformed steps, missing endpoints, unreachable steps, missing nobody edges, ask-free loops and undeclared attributes. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "graph": {
                    "type": "object",
                    "description": "Optional graph to check instead of the saved draft."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ valid, errors }`, with actionable messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/scripts/{id}/publish": {
      "post": {
        "operationId": "publishChatScript",
        "tags": [
          "Chats"
        ],
        "summary": "Publish a new script version or roll back",
        "description": "Requires a current organization admin. Existing chats stay pinned. Supply version to publish a copy of an earlier version. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedRevision": {
                    "type": "integer",
                    "description": "The revision last read."
                  },
                  "version": {
                    "type": "integer",
                    "description": "An earlier published version to restore; omit to publish the draft."
                  }
                },
                "required": [
                  "expectedRevision"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The script with its new publishedVersion and revision.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/script-proposals": {
      "post": {
        "operationId": "proposeChatScript",
        "tags": [
          "Chats"
        ],
        "summary": "Draft a script from plain words",
        "description": "Requires a current organization admin and write token. The AI answers only with the engine's step types, checked by the script validator. Returns the graph, a plain read-back, a flow to draw, a diff against the script it refines, and questions for facts it was not given. Changes nothing until applied. AI agent keys are refused. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "words": {
                    "type": "string",
                    "description": "What the chat should do, or what to change."
                  },
                  "script": {
                    "type": "string",
                    "description": "A saved script id to change."
                  },
                  "proposal": {
                    "type": "string",
                    "description": "An earlier proposal id to continue, for example to answer its questions."
                  }
                },
                "required": [
                  "words"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The proposal: `id` (spp_...), `graph`, `errors`, `questions`, `warnings`, `diff`, `readBack`, `flow`, `words`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/script-proposals/{id}": {
      "get": {
        "operationId": "getChatScriptProposal",
        "tags": [
          "Chats"
        ],
        "summary": "Read a script proposal",
        "description": "Requires a current organization admin. Only the person who proposed it can read it.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The proposal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/script-proposals/{id}/apply": {
      "post": {
        "operationId": "applyChatScriptProposal",
        "tags": [
          "Chats"
        ],
        "summary": "Save a proposal as a draft script",
        "description": "Requires the admin who made the proposal. Refuses one with open questions, failing checks, already applied, expired, or whose script changed since. Saves a draft only; publishing is separate. The words are kept with the script and each version. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ applied, proposalId, script }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/scripts/{id}/versions": {
      "get": {
        "operationId": "chatScriptVersions",
        "tags": [
          "Chats"
        ],
        "summary": "Read a script's publication history",
        "description": "Requires a current organization admin. Published snapshots never change.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ versions }`, newest first, each with version, graph and createdAt.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/intake": {
      "post": {
        "operationId": "createIntakeTicket",
        "tags": [
          "Intake"
        ],
        "summary": "File a ticket from your own app or site",
        "description": "Call it from your server, never a browser, with the team's intake key (`spk_...`). The ticket opens on the key's team. When the team's auto-reply is on, the customer gets a confirmation email with the private link. Limited to 120 calls a minute per key.",
        "security": [
          {
            "intakeKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "description": "The customer's email."
                  },
                  "name": {
                    "type": "string",
                    "description": "The customer's name."
                  },
                  "subject": {
                    "type": "string",
                    "description": "What the ticket is about."
                  },
                  "body": {
                    "type": "string",
                    "description": "The customer's message."
                  },
                  "format": {
                    "type": "string",
                    "description": "How `body` is written.",
                    "enum": [
                      "text",
                      "markdown"
                    ]
                  },
                  "externalUserId": {
                    "type": "string",
                    "description": "Your app's id for the customer, up to 200 characters."
                  },
                  "metadata": {
                    "type": "object",
                    "description": "Context shown beside the ticket, such as plan or app version. Up to 4,000 characters as JSON."
                  }
                },
                "required": [
                  "email",
                  "subject",
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`{ number, status, portalUrl }`. Show the customer `portalUrl`: their private page for the ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams": {
      "get": {
        "operationId": "listTeams",
        "tags": [
          "Teams"
        ],
        "summary": "List teams",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "description": "`1` adds removed teams.",
            "schema": {
              "type": "string",
              "description": "`1` adds removed teams.",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ word: { one, many }, teams }`. `word` is what this desk calls a team.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTeam",
        "tags": [
          "Teams"
        ],
        "summary": "Add a team",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "The team's name."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Made from the name when left out."
                  },
                  "color": {
                    "type": "string",
                    "description": "A free one when left out.",
                    "enum": [
                      "blue",
                      "teal",
                      "amber",
                      "violet",
                      "rose",
                      "orange"
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The team.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Team"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}": {
      "patch": {
        "operationId": "updateTeam",
        "tags": [
          "Teams"
        ],
        "summary": "Change a team",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "A new name."
                  },
                  "slug": {
                    "type": "string",
                    "description": "A new slug. The old one keeps working."
                  },
                  "color": {
                    "type": "string",
                    "description": "A new color.",
                    "enum": [
                      "blue",
                      "teal",
                      "amber",
                      "violet",
                      "rose",
                      "orange"
                    ]
                  },
                  "supportEmail": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The support address that forwards here, or null."
                  },
                  "senderName": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The name replies come from."
                  },
                  "autoReply": {
                    "type": "boolean",
                    "description": "Confirm new tickets by email."
                  },
                  "autoReplyText": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The confirmation's words; `{name}`, `{team}` and `{number}` are filled in. Null uses the default."
                  },
                  "solvedEmail": {
                    "type": "boolean",
                    "description": "Email the customer when a ticket is solved."
                  },
                  "csat": {
                    "type": "boolean",
                    "description": "Ask the customer how it went when a ticket is solved: once, in its first solved email and in the portal."
                  },
                  "signature": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Plain text that signs the team's mail, up to 1,000 characters."
                  },
                  "customerMcp": {
                    "type": "boolean",
                    "description": "Let the team's customers connect their own AI assistant."
                  },
                  "chatAllowedOrigins": {
                    "type": "array",
                    "description": "Origins allowed to start a chat widget conversation for this team (e.g. `https://shop.example` or `https://*.partner.example`).",
                    "items": {
                      "type": "string"
                    }
                  },
                  "contextUrl": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "An https address Supportress POSTs a ticket's customer to, signed, when an agent opens the ticket (SUPT-28). Empty or null turns it off."
                  },
                  "chatFallback": {
                    "type": "string",
                    "description": "What happens when a visitor asks for a live agent and nobody is present or out of hours (`ticket`, `email` or `bot`).",
                    "enum": [
                      "ticket",
                      "email",
                      "bot"
                    ]
                  },
                  "chatFallbackEmail": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Target address for the `email` chat fallback, or null to use the team's support address."
                  },
                  "chatRequireEmail": {
                    "type": "boolean",
                    "description": "Ask chat visitors for an email address before connecting them to a live agent."
                  },
                  "archived": {
                    "type": "boolean",
                    "description": "`false` brings a removed team back."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The team.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Team"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTeam",
        "tags": [
          "Teams"
        ],
        "summary": "Remove a team",
        "description": "Deleted when it has no tickets, archived otherwise. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted, archived }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sla-policies": {
      "get": {
        "operationId": "listSlaPolicies",
        "tags": [
          "Teams"
        ],
        "summary": "List SLA policies",
        "description": "Every team's SLA policy (SUPT-43). Teams with none are left out.",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ policies }`, by team name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/assignment": {
      "get": {
        "operationId": "getTeamAssignment",
        "tags": [
          "Teams"
        ],
        "summary": "Read a team's assignment settings",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ rule, cap, members }`. Empty members means everyone.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setTeamAssignment",
        "tags": [
          "Teams"
        ],
        "summary": "Set a team's assignment settings",
        "description": "Admin only. Omitted fields stay as they are. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rule": {
                    "type": "string",
                    "description": "Manual is the default.",
                    "enum": [
                      "manual",
                      "round_robin"
                    ]
                  },
                  "cap": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Maximum open tickets across the desk per assignee. Null turns the cap off."
                  },
                  "members": {
                    "type": "array",
                    "description": "Member email addresses. An empty list means everyone.",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The saved assignment settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/sla": {
      "get": {
        "operationId": "getSlaPolicy",
        "tags": [
          "Teams"
        ],
        "summary": "Read a team's SLA policy",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ policy }`: null when the team has none, so its tickets have no SLA.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setSlaPolicy",
        "tags": [
          "Teams"
        ],
        "summary": "Set a team's SLA policy",
        "description": "Makes or changes the team's policy. Only the fields sent change; a new one starts on Monday to Friday, 9 to 5, UTC, with pending stopping the clock, and needs at least one target. Each ticket's `sla` is worked out from it whenever the ticket is read, so a change applies to every ticket of the team at once. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "timezone": {
                    "type": "string",
                    "description": "A time zone name, such as America/New_York."
                  },
                  "businessHours": {
                    "type": "boolean",
                    "description": "`true`: the clocks run in business hours only. `false`: round the clock."
                  },
                  "hours": {
                    "type": "object",
                    "description": "By day (`sunday` to `saturday`): `null` for closed, or `{ start: \"09:00\", end: \"17:00\" }` on a 24-hour clock (`24:00` for midnight at the end). A day left out keeps its hours."
                  },
                  "holidays": {
                    "type": "array",
                    "description": "Dates the team is closed, as YYYY-MM-DD in its time zone. Up to 100.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "pauseOnPending": {
                    "type": "boolean",
                    "description": "`true`: a pending ticket (waiting on the customer) stops its clocks. Solved and closed always stop them."
                  },
                  "targets": {
                    "type": "object",
                    "description": "By priority (`urgent`, `high`, `normal`, `low`): `{ firstResponse, resolution }`, each minutes of SLA time (1 to 129,600) or null for none."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ policy }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteSlaPolicy",
        "tags": [
          "Teams"
        ],
        "summary": "Remove a team's SLA policy",
        "description": "Its tickets have no SLA from then on. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/widget": {
      "get": {
        "operationId": "getChatWidget",
        "tags": [
          "Teams"
        ],
        "summary": "Read a team's chat widget settings",
        "description": "A team's chat widget (SUPT-107): on or off, its look, the sites allowed to load it, who answers first, the fallback when nobody is there and the chat's hours. A team that never set one has it off.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ widget }`: the settings, plus `install`: `{ tag, api, developerEmail: { subject, body } }`, the one-line tag to paste, a JS API snippet and a note to send a developer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "setChatWidget",
        "tags": [
          "Teams"
        ],
        "summary": "Change a team's chat widget settings",
        "description": "Only the fields sent change. Turning the widget on needs a `fallback` for when nobody is there, since a person can always be away. A site that is not in `allowedOrigins` cannot start a chat, and cannot frame the panel. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "description": "Whether the widget runs."
                  },
                  "accent": {
                    "type": "string",
                    "description": "A `#rrggbb` color, or null for the team's color."
                  },
                  "position": {
                    "type": "string",
                    "description": "`right` or `left`."
                  },
                  "greeting": {
                    "type": "string",
                    "description": "The line shown when the panel opens (up to 280 characters), or null."
                  },
                  "name": {
                    "type": "string",
                    "description": "The name shown in the panel (up to 60 characters), or null for the team's name."
                  },
                  "avatar": {
                    "type": "string",
                    "description": "An `https://` image address, or null."
                  },
                  "allowedOrigins": {
                    "type": "array",
                    "description": "The whole list of sites that may load the widget, as `https://shop.example` or `https://*.partner.example`. Include the scheme and omit paths. Up to 50.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "entry": {
                    "type": "string",
                    "description": "Who answers first: `bot` or `agent`. `script` is refused (`scripts_not_available`) until the script engine ships."
                  },
                  "expected": {
                    "type": "object",
                    "description": "Optional: the values you last read for the fields you change. If one changed since, the patch is refused with 409 `widget_changed`."
                  },
                  "fallback": {
                    "type": "string",
                    "description": "When nobody is there: `ticket` (ask for an email, then open a ticket), `email` (forward to `fallbackEmail`) or `bot`."
                  },
                  "fallbackEmail": {
                    "type": "string",
                    "description": "The address to forward to when `fallback` is `email`."
                  },
                  "hoursSource": {
                    "type": "string",
                    "description": "`always`, `sla` (the team's SLA business hours) or `custom` (`timezone` and `hours`)."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "A time zone name, such as America/New_York, for custom hours."
                  },
                  "hours": {
                    "type": "object",
                    "description": "By day (`sunday` to `saturday`): `null` for closed, or `{ start: \"09:00\", end: \"17:00\" }`. A day left out keeps its hours."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ widget }`, as read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets": {
      "get": {
        "operationId": "listTickets",
        "tags": [
          "Tickets"
        ],
        "summary": "List tickets",
        "description": "Newest activity first. Spam is left out unless `spam=1`.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "A comma list of statuses, or `all`. Default `new,open,pending`.",
            "schema": {
              "type": "string",
              "description": "A comma list of statuses, or `all`. Default `new,open,pending`."
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "A team's slug.",
            "schema": {
              "type": "string",
              "description": "A team's slug."
            }
          },
          {
            "name": "myTeams",
            "in": "query",
            "required": false,
            "description": "`1`: only teams you work, including teams open to everyone.",
            "schema": {
              "type": "string",
              "description": "`1`: only teams you work, including teams open to everyone.",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "assignee",
            "in": "query",
            "required": false,
            "description": "`me`, `none` or an email.",
            "schema": {
              "type": "string",
              "description": "`me`, `none` or an email."
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "description": "A priority, or a comma list of them.",
            "schema": {
              "type": "string",
              "description": "A priority, or a comma list of them."
            }
          },
          {
            "name": "tags",
            "in": "query",
            "required": false,
            "description": "A comma list of tags: tickets with every one.",
            "schema": {
              "type": "string",
              "description": "A comma list of tags: tickets with every one."
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "description": "A comma list of doors tickets came in by: `api`, `portal`, `agent`, `mcp`, `email`, `chat`.",
            "schema": {
              "type": "string",
              "description": "A comma list of doors tickets came in by: `api`, `portal`, `agent`, `mcp`, `email`, `chat`."
            }
          },
          {
            "name": "aiAgent",
            "in": "query",
            "required": false,
            "description": "Only tickets assigned to this AI agent.",
            "schema": {
              "type": "string",
              "description": "Only tickets assigned to this AI agent."
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "The order. Default `recent`.",
            "schema": {
              "type": "string",
              "description": "The order. Default `recent`.",
              "enum": [
                "recent",
                "oldest",
                "newest",
                "priority"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Words, a customer's email or a ticket number.",
            "schema": {
              "type": "string",
              "description": "Words, a customer's email or a ticket number."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to answer.",
            "schema": {
              "type": "integer",
              "description": "How many to answer."
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "The page cursor: the last ticket's activity time and id from the page before.",
            "schema": {
              "type": "string",
              "description": "The page cursor: the last ticket's activity time and id from the page before."
            }
          },
          {
            "name": "spam",
            "in": "query",
            "required": false,
            "description": "`1`: only tickets in Spam.",
            "schema": {
              "type": "string",
              "description": "`1`: only tickets in Spam.",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "approval",
            "in": "query",
            "required": false,
            "description": "`1`: only tickets with an AI agent's reply waiting for approval.",
            "schema": {
              "type": "string",
              "description": "`1`: only tickets with an AI agent's reply waiting for approval.",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ tickets }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Open a ticket",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "team": {
                    "type": "string",
                    "description": "The team's slug or id."
                  },
                  "email": {
                    "type": "string",
                    "description": "The customer's email."
                  },
                  "name": {
                    "type": "string",
                    "description": "The customer's name."
                  },
                  "subject": {
                    "type": "string",
                    "description": "What it is about."
                  },
                  "body": {
                    "type": "string",
                    "description": "The first message."
                  },
                  "format": {
                    "type": "string",
                    "description": "How `body` is written.",
                    "enum": [
                      "text",
                      "markdown"
                    ]
                  },
                  "priority": {
                    "type": "string",
                    "description": "Its priority.",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "urgent"
                    ]
                  },
                  "tags": {
                    "type": "array",
                    "description": "Tags.",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "team",
                  "email",
                  "subject",
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`{ ticket, portalUrl }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/export": {
      "get": {
        "operationId": "exportTicketsCsv",
        "tags": [
          "Tickets"
        ],
        "summary": "Export tickets as CSV",
        "description": "Streams every matching ticket as RFC 4180 CSV with core fields and custom metadata columns (`metadata.<key>`). Takes the same filters as `GET /tickets`, plus optional `from` and `to` UTC creation dates and `excludeMerged=1`.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "A comma list of statuses, or `all`. Default `new,open,pending`.",
            "schema": {
              "type": "string",
              "description": "A comma list of statuses, or `all`. Default `new,open,pending`."
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "A team's slug.",
            "schema": {
              "type": "string",
              "description": "A team's slug."
            }
          },
          {
            "name": "myTeams",
            "in": "query",
            "required": false,
            "description": "`1`: only teams you work, including teams open to everyone.",
            "schema": {
              "type": "string",
              "description": "`1`: only teams you work, including teams open to everyone.",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "assignee",
            "in": "query",
            "required": false,
            "description": "`me`, `none` or an email.",
            "schema": {
              "type": "string",
              "description": "`me`, `none` or an email."
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "description": "A priority, or a comma list of them.",
            "schema": {
              "type": "string",
              "description": "A priority, or a comma list of them."
            }
          },
          {
            "name": "tags",
            "in": "query",
            "required": false,
            "description": "A comma list of tags: tickets with every one.",
            "schema": {
              "type": "string",
              "description": "A comma list of tags: tickets with every one."
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "description": "A comma list of doors tickets came in by: `api`, `portal`, `agent`, `mcp`, `email`, `chat`.",
            "schema": {
              "type": "string",
              "description": "A comma list of doors tickets came in by: `api`, `portal`, `agent`, `mcp`, `email`, `chat`."
            }
          },
          {
            "name": "aiAgent",
            "in": "query",
            "required": false,
            "description": "Only tickets assigned to this AI agent.",
            "schema": {
              "type": "string",
              "description": "Only tickets assigned to this AI agent."
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "The order. Default `recent`.",
            "schema": {
              "type": "string",
              "description": "The order. Default `recent`.",
              "enum": [
                "recent",
                "oldest",
                "newest",
                "priority"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Words, a customer's email or a ticket number.",
            "schema": {
              "type": "string",
              "description": "Words, a customer's email or a ticket number."
            }
          },
          {
            "name": "spam",
            "in": "query",
            "required": false,
            "description": "`1`: only tickets in Spam.",
            "schema": {
              "type": "string",
              "description": "`1`: only tickets in Spam.",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "approval",
            "in": "query",
            "required": false,
            "description": "`1`: only tickets with an AI agent's reply waiting for approval.",
            "schema": {
              "type": "string",
              "description": "`1`: only tickets with an AI agent's reply waiting for approval.",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "UTC creation date lower bound (`YYYY-MM-DD`, inclusive).",
            "schema": {
              "type": "string",
              "description": "UTC creation date lower bound (`YYYY-MM-DD`, inclusive)."
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "UTC creation date upper bound (`YYYY-MM-DD`, inclusive).",
            "schema": {
              "type": "string",
              "description": "UTC creation date upper bound (`YYYY-MM-DD`, inclusive)."
            }
          },
          {
            "name": "excludeMerged",
            "in": "query",
            "required": false,
            "description": "`1`: leave out tickets merged into another ticket.",
            "schema": {
              "type": "string",
              "description": "`1`: leave out tickets merged into another ticket.",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A streamed `text/csv; charset=utf-8` file.",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/bulk": {
      "post": {
        "operationId": "bulkUpdateTickets",
        "tags": [
          "Tickets"
        ],
        "summary": "Change many tickets at once",
        "description": "Send `tickets` (up to 50) or `view` (a filter, changed 50 at a time: send it again with `view.before` set to `next` while `next` is not null). `changes: { delete: true }` alone deletes tickets in Spam; `changes: { mergeInto }` alone merges up to 20 tickets into one. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tickets": {
                    "type": "array",
                    "description": "Ticket numbers or ids.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "view": {
                    "type": "object",
                    "description": "A filter: `status`, `team`, `assignee`, `priority`, `q`, `spam`, `approval`, `before`."
                  },
                  "changes": {
                    "type": "object",
                    "description": "Any of `status`, `priority`, `assignee`, `addTags`, `removeTags`, `spam`, `blockSender`, `macro`; or `delete` or `mergeInto` alone."
                  }
                },
                "required": [
                  "changes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ updated, unchanged, failed: [{ ticket, code, message }], next }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ticket-fields": {
      "get": {
        "operationId": "listTicketFields",
        "tags": [
          "Tickets"
        ],
        "summary": "List ticket fields",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ fields }` in definition order, including archived fields. Dropdown options include stable id, label and archived; only live option ids may be set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTicketField",
        "tags": [
          "Tickets"
        ],
        "summary": "Create a ticket field (admins only)",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "description": "Renamable label, up to 120 characters."
                  },
                  "type": {
                    "type": "string",
                    "description": "Immutable type.",
                    "enum": [
                      "text",
                      "number",
                      "dropdown",
                      "checkbox",
                      "date"
                    ]
                  },
                  "options": {
                    "type": "array",
                    "description": "Dropdown options: objects with label. Stable ids are generated.",
                    "items": {
                      "type": "object"
                    }
                  },
                  "teamIds": {
                    "type": "array",
                    "description": "This desk's team ids or slugs; [] applies to every team.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "requiredToSolve": {
                    "type": "boolean",
                    "description": "Refuse agent solves while empty."
                  },
                  "aiMayFill": {
                    "type": "boolean",
                    "description": "AI may fill; false by default."
                  },
                  "helpText": {
                    "type": "string",
                    "description": "Help text, up to 500 characters."
                  },
                  "position": {
                    "type": "integer",
                    "description": "Order, lowest first."
                  }
                },
                "required": [
                  "label",
                  "type"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The field definition; at most 50 active fields per desk.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ticket-fields/{id}": {
      "patch": {
        "operationId": "updateTicketField",
        "tags": [
          "Tickets"
        ],
        "summary": "Change a ticket field (admins only)",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "description": "New label."
                  },
                  "options": {
                    "type": "array",
                    "description": "Dropdown options with existing id and new label, or no id to add. Omitted options are archived.",
                    "items": {
                      "type": "object"
                    }
                  },
                  "teamIds": {
                    "type": "array",
                    "description": "Team ids or slugs; [] for all.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "requiredToSolve": {
                    "type": "boolean",
                    "description": "Required to solve."
                  },
                  "aiMayFill": {
                    "type": "boolean",
                    "description": "AI may fill."
                  },
                  "helpText": {
                    "type": "string",
                    "description": "Help text."
                  },
                  "position": {
                    "type": "integer",
                    "description": "Order, lowest first."
                  },
                  "archived": {
                    "type": "boolean",
                    "description": "Archive or restore, never delete."
                  },
                  "version": {
                    "type": "integer",
                    "description": "Version last read, to refuse stale edits (409)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The current definition. Type cannot change.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}": {
      "get": {
        "operationId": "getTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Get a ticket",
        "description": "With its messages, events, emails, files, dev issues, drafts, links, summary and the customer's other tickets.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Change a ticket",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fields": {
                    "type": "object",
                    "description": "Values keyed by stable ticket field id. null clears; dropdowns use live option ids from GET /ticket-fields. AI keys may fill only aiMayFill fields."
                  },
                  "team": {
                    "type": "string",
                    "description": "Move the ticket to this team slug or id."
                  },
                  "status": {
                    "type": "string",
                    "description": "The new status.",
                    "enum": [
                      "new",
                      "open",
                      "pending",
                      "solved",
                      "closed"
                    ]
                  },
                  "priority": {
                    "type": "string",
                    "description": "The new priority.",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "urgent"
                    ]
                  },
                  "assignee": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "An agent's or AI agent's email, `me`, or null to unassign."
                  },
                  "tags": {
                    "type": "array",
                    "description": "The whole set of tags.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "subject": {
                    "type": "string",
                    "description": "A new subject."
                  },
                  "spam": {
                    "type": "boolean",
                    "description": "True moves the ticket to Spam; false takes it out."
                  },
                  "blockSender": {
                    "type": "string",
                    "description": "Block the ticket's customer in the same step: their `address` or their `domain`.",
                    "enum": [
                      "address",
                      "domain"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      },
      "delete": {
        "operationId": "deleteTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Delete a ticket in Spam for good",
        "description": "A ticket not in Spam is 409 `not_spam`. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted: 1 }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/context": {
      "get": {
        "operationId": "getCustomerContext",
        "tags": [
          "Tickets"
        ],
        "summary": "Fresh customer context from the team's app",
        "description": "SUPT-28. When the ticket's team has a context callback (`contextUrl`), Supportress POSTs the customer to it, signed with the team's identity secret, and answers with what the app sent back. The app has 3 seconds; a slow or failing app is `status: \"failed\"` with a `reason`, never an error.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ status: \"off\" }`, `{ status: \"ok\", context: { ... }, fetchedAt }` or `{ status: \"failed\", reason, fetchedAt }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/merge": {
      "post": {
        "operationId": "mergeTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Merge into another ticket",
        "description": "The same customer's ticket on the same team. Its messages, files and links move into `into`, and this one closes. Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "into": {
                    "type": "string",
                    "description": "The ticket to keep: a number or id."
                  }
                },
                "required": [
                  "into"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/{ref}/split": {
      "post": {
        "operationId": "splitMessage",
        "tags": [
          "Tickets"
        ],
        "summary": "Split a message into a new ticket",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "description": "The customer message's id."
                  },
                  "subject": {
                    "type": "string",
                    "description": "The new ticket's subject. Default: this one's."
                  }
                },
                "required": [
                  "message"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/{ref}/links": {
      "post": {
        "operationId": "linkTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Link a related ticket",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ticket": {
                    "type": "string",
                    "description": "The other ticket's number or id."
                  }
                },
                "required": [
                  "ticket"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/{ref}/links/{other}": {
      "delete": {
        "operationId": "unlinkTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Unlink two tickets",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "other",
            "in": "path",
            "required": true,
            "description": "The linked ticket's number or id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/similar-tickets": {
      "get": {
        "operationId": "similarTickets",
        "tags": [
          "Tickets"
        ],
        "summary": "Find tickets about the same problem",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ticket",
            "in": "query",
            "required": false,
            "description": "A ticket's number or id.",
            "schema": {
              "type": "string",
              "description": "A ticket's number or id."
            }
          },
          {
            "name": "text",
            "in": "query",
            "required": false,
            "description": "What to look for.",
            "schema": {
              "type": "string",
              "description": "What to look for."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 10, default 5.",
            "schema": {
              "type": "integer",
              "description": "1 to 10, default 5."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ available, tickets: [{ id, number, subject, status, team, lastActivityAt, score, summary }] }`, closest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chats": {
      "get": {
        "operationId": "listChats",
        "tags": [
          "Chats"
        ],
        "summary": "List chats",
        "description": "Newest chat activity first. Excludes spam chats unless `spam=true`.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "A team's slug or id.",
            "schema": {
              "type": "string",
              "description": "A team's slug or id."
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "A comma list of chat statuses: `open`, `waiting`, `ended`.",
            "schema": {
              "type": "string",
              "description": "A comma list of chat statuses: `open`, `waiting`, `ended`."
            }
          },
          {
            "name": "handler",
            "in": "query",
            "required": false,
            "description": "Only chats currently run by this handler.",
            "schema": {
              "type": "string",
              "description": "Only chats currently run by this handler.",
              "enum": [
                "script",
                "bot",
                "agent"
              ]
            }
          },
          {
            "name": "spam",
            "in": "query",
            "required": false,
            "description": "`true` to list only spam chats; omit for non-spam chats.",
            "schema": {
              "type": "string",
              "description": "`true` to list only spam chats; omit for non-spam chats."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to answer, 1 to 200. Default 50.",
            "schema": {
              "type": "integer",
              "description": "How many to answer, 1 to 200. Default 50."
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "The page cursor: `<lastMessageAt>|<id>` from the page before.",
            "schema": {
              "type": "string",
              "description": "The page cursor: `<lastMessageAt>|<id>` from the page before."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ chats }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chats/presence": {
      "get": {
        "operationId": "getChatPresence",
        "tags": [
          "Chats"
        ],
        "summary": "Read live-chat agent presence",
        "description": "Who is currently watching Live chat and available to take new chats in this organization, with per-team availability.",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ onlineCount, availableCount, agents, teams }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chats/{id}": {
      "get": {
        "operationId": "getChat",
        "tags": [
          "Chats"
        ],
        "summary": "Get a chat",
        "description": "With its visitor details, linked ticket (if any), messages (including attachments) and handler-change events.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "Return only messages newer than this message id.",
            "schema": {
              "type": "string",
              "description": "Return only messages newer than this message id."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The chat, with `messages` and `events`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chats/{id}/attachments/{attachmentId}": {
      "get": {
        "operationId": "getChatAttachment",
        "tags": [
          "Chats"
        ],
        "summary": "Download a chat file",
        "description": "Pictures are shown inline; anything else downloads.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attachmentId",
            "in": "path",
            "required": true,
            "description": "The attachment's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file, in its own content type (`application/octet-stream` when unknown), with `Content-Disposition`.",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chats/{id}/spam": {
      "post": {
        "operationId": "markChatSpam",
        "tags": [
          "Chats"
        ],
        "summary": "Mark a chat spam and optionally block the visitor",
        "description": "Marks a chat spam (or not spam) and, when `block` is true, blocks the visitor by id and temporarily blocks their network when known. Set `blockEmail` with `block` to use the visitor's email address for the second block when available. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "spam": {
                    "type": "boolean",
                    "description": "`true` (default) to mark spam and end the chat; `false` to mark not spam."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Optional plain-language reason."
                  },
                  "block": {
                    "type": "boolean",
                    "description": "`true` to block the visitor."
                  },
                  "blockEmail": {
                    "type": "boolean",
                    "description": "`true` to block the visitor’s email address in place of the temporary network block when the email is available. Requires `block: true`."
                  },
                  "blockHours": {
                    "type": "integer",
                    "description": "Temporary IP block duration in hours (1 to 168, default 24)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ chat, blocked }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chat-blocks": {
      "get": {
        "operationId": "listChatBlocks",
        "tags": [
          "Chats"
        ],
        "summary": "List active chat visitor and IP blocks",
        "description": "Active visitor-id and temporary IP blocks for this organization, newest first.",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ blocks }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chat-blocks/{id}": {
      "delete": {
        "operationId": "deleteChatBlock",
        "tags": [
          "Chats"
        ],
        "summary": "Remove a chat visitor or IP block",
        "description": "Deletes a chat block by id so the visitor or IP may chat again. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/chat-bot": {
      "get": {
        "operationId": "getChatBot",
        "tags": [
          "Chats"
        ],
        "summary": "Read a team's chat bot",
        "description": "Its name, tone, instructions, sources and handoff rules (SUPT-116), with how its answers fared in the last 30 days. A team with none saved shows the defaults, switched off.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ enabled, name, tone, instructions, sources, handoff: { allowed, scriptRef, prefer, rules }, fallback, stats, ... }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateChatBot",
        "tags": [
          "Chats"
        ],
        "summary": "Change a team's chat bot",
        "description": "Only the fields sent change. The bot answers only from the team's published knowledge and links each article it used; it hands a chat over only to the targets in `handoff.allowed`, by the `handoff.rules`. `fallback` is where a chat goes when the bot cannot run (AI off, the AI budget used up, the model failing). Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "description": "`true`: new chats on this team start with the bot."
                  },
                  "name": {
                    "type": "string",
                    "description": "The bot's name, shown to visitors. Up to 60 characters."
                  },
                  "tone": {
                    "type": "string",
                    "description": "How it sounds, such as `warm and brief`. Up to 200 characters."
                  },
                  "instructions": {
                    "type": "string",
                    "description": "Plain-words rules, such as \"never promise refunds\". Up to 2,000 characters."
                  },
                  "sources": {
                    "type": "array",
                    "description": "What it may search. Today only `article`.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "handoff": {
                    "type": "object",
                    "description": "`{ allowed, scriptRef, prefer, rules }`: `allowed` is any of `agent`, `ticket`, `email`, `script`; `scriptRef` names the script for `script`; `prefer` is the one used first; `rules` is `{ askedForPerson, nothingRelevant, unhelpfulAnswers, topics, afterTurns }`."
                  },
                  "fallback": {
                    "type": "string",
                    "description": "Where a chat goes when the bot steps aside.",
                    "enum": [
                      "agent",
                      "ticket",
                      "email",
                      "script"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "As `GET /teams/:ref/chat-bot`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{ref}/chat-bot/answers": {
      "get": {
        "operationId": "listChatBotAnswers",
        "tags": [
          "Chats"
        ],
        "summary": "The bot's answer log",
        "description": "Newest first: each turn's question, answer, sources, tokens, cost and the visitor's thumbs up or down.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 200, default 50.",
            "schema": {
              "type": "integer",
              "description": "1 to 200, default 50."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ answers: [{ id, chatId, question, answer, outcome, handoffTarget, sources, model, inputTokens, outputTokens, costUsd, rating, error, createdAt }] }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/views": {
      "get": {
        "operationId": "listViews",
        "tags": [
          "Views"
        ],
        "summary": "List saved views",
        "description": "The desk's shared views, then the token owner's own, by name.",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ views: [{ id, name, shared, owner, filters, sort, createdBy, createdAt, updatedBy, updatedAt }] }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createView",
        "tags": [
          "Views"
        ],
        "summary": "Save a view",
        "description": "At most 30 of a person's own and 30 shared a desk (409 `too_many_views`). Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Up to 60 characters; unique among the person's own views, and among the shared ones (409 `name_taken`)."
                  },
                  "shared": {
                    "type": "boolean",
                    "description": "True shares it with the whole desk. Default false."
                  },
                  "filters": {
                    "type": "object",
                    "description": "The shape of a bulk `view`: `status`, `team`, `assignee` (`me` means whoever opens it), `priority`, `tags`, `channel`, `aiAgent`, `spam`, `approval`, `q`."
                  },
                  "sort": {
                    "type": "string",
                    "description": "The order.",
                    "enum": [
                      "recent",
                      "oldest",
                      "newest",
                      "priority"
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The view.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/views/{id}": {
      "get": {
        "operationId": "getView",
        "tags": [
          "Views"
        ],
        "summary": "Get a saved view",
        "description": "By its id or name. Another person's own view is 404.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The view.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateView",
        "tags": [
          "Views"
        ],
        "summary": "Change a saved view",
        "description": "Anyone on the desk can change a shared view; `shared: false` makes it the changer's own. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Up to 60 characters; unique among the person's own views, and among the shared ones (409 `name_taken`)."
                  },
                  "shared": {
                    "type": "boolean",
                    "description": "True shares it with the whole desk. Default false."
                  },
                  "filters": {
                    "type": "object",
                    "description": "The shape of a bulk `view`: `status`, `team`, `assignee` (`me` means whoever opens it), `priority`, `tags`, `channel`, `aiAgent`, `spam`, `approval`, `q`."
                  },
                  "sort": {
                    "type": "string",
                    "description": "The order.",
                    "enum": [
                      "recent",
                      "oldest",
                      "newest",
                      "priority"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The view.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteView",
        "tags": [
          "Views"
        ],
        "summary": "Delete a saved view",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted: true }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/views/{id}/tickets": {
      "get": {
        "operationId": "viewTickets",
        "tags": [
          "Views"
        ],
        "summary": "List a saved view's tickets",
        "description": "In the view's own sort, as `GET /tickets` lists them.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to answer.",
            "schema": {
              "type": "integer",
              "description": "How many to answer."
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "The page cursor, for a `recent` view.",
            "schema": {
              "type": "string",
              "description": "The page cursor, for a `recent` view."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ view, tickets }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/views/{id}/export": {
      "get": {
        "operationId": "exportViewCsv",
        "tags": [
          "Views"
        ],
        "summary": "Export a saved view as CSV",
        "description": "Streams every ticket in the saved view as RFC 4180 CSV in the view's own sort, including custom metadata columns (`metadata.<key>`).",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "UTC creation date lower bound (`YYYY-MM-DD`, inclusive).",
            "schema": {
              "type": "string",
              "description": "UTC creation date lower bound (`YYYY-MM-DD`, inclusive)."
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "UTC creation date upper bound (`YYYY-MM-DD`, inclusive).",
            "schema": {
              "type": "string",
              "description": "UTC creation date upper bound (`YYYY-MM-DD`, inclusive)."
            }
          },
          {
            "name": "excludeMerged",
            "in": "query",
            "required": false,
            "description": "`1`: leave out tickets merged into another ticket.",
            "schema": {
              "type": "string",
              "description": "`1`: leave out tickets merged into another ticket.",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A streamed `text/csv; charset=utf-8` file.",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/messages": {
      "post": {
        "operationId": "addMessage",
        "tags": [
          "Messages"
        ],
        "summary": "Reply or add a note",
        "description": "A public reply is emailed to the customer. Send `seenMessageId` to be told (409 `new_reply`) when someone wrote after you started. Send JSON: files cannot be attached through this API. Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "description": "The message."
                  },
                  "format": {
                    "type": "string",
                    "description": "How `body` is written.",
                    "enum": [
                      "text",
                      "markdown"
                    ]
                  },
                  "internal": {
                    "type": "boolean",
                    "description": "True for an internal note only agents see."
                  },
                  "status": {
                    "type": "string",
                    "description": "Set the status in the same step.",
                    "enum": [
                      "new",
                      "open",
                      "pending",
                      "solved",
                      "closed"
                    ]
                  },
                  "seenMessageId": {
                    "type": "string",
                    "description": "The newest message you had read."
                  },
                  "predictionId": {
                    "type": "string",
                    "description": "The reply prediction this reply builds on."
                  }
                },
                "required": [
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/{ref}/attachments/{id}": {
      "get": {
        "operationId": "getAttachment",
        "tags": [
          "Messages"
        ],
        "summary": "Download a file",
        "description": "Pictures are shown, anything else downloads.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file, in its own content type (`application/octet-stream` when unknown), with `Content-Disposition`.",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/drafts/{id}/send": {
      "post": {
        "operationId": "sendReplyDraft",
        "tags": [
          "Messages"
        ],
        "summary": "Send a drafted reply",
        "description": "A fix reply drafted by the fix loop, or an AI agent's reply waiting for approval (only a person sends those). Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "description": "Default: the draft."
                  },
                  "status": {
                    "type": "string",
                    "description": "Default: the draft's.",
                    "enum": [
                      "new",
                      "open",
                      "pending",
                      "solved",
                      "closed"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/{ref}/drafts/{id}": {
      "delete": {
        "operationId": "discardReplyDraft",
        "tags": [
          "Messages"
        ],
        "summary": "Throw a draft away",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/articles": {
      "get": {
        "operationId": "listArticles",
        "tags": [
          "Knowledge base"
        ],
        "summary": "List or search articles",
        "description": "With `q`, the best matches first, each with the sections that matched; otherwise the newest change first. Drafts and internal articles included.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Words to search the title, summary and body for.",
            "schema": {
              "type": "string",
              "description": "Words to search the title, summary and body for."
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "A team's slug or id.",
            "schema": {
              "type": "string",
              "description": "A team's slug or id."
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "A category's id or slug.",
            "schema": {
              "type": "string",
              "description": "A category's id or slug."
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only these.",
            "schema": {
              "type": "string",
              "description": "Only these.",
              "enum": [
                "draft",
                "published"
              ]
            }
          },
          {
            "name": "audience",
            "in": "query",
            "required": false,
            "description": "Only these.",
            "schema": {
              "type": "string",
              "description": "Only these.",
              "enum": [
                "public",
                "internal"
              ]
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "Only articles with this tag.",
            "schema": {
              "type": "string",
              "description": "Only articles with this tag."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to answer.",
            "schema": {
              "type": "integer",
              "description": "How many to answer."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ articles }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createArticle",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Write an article",
        "description": "A draft unless `status` is published. Publishing needs a summary and a body. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Its title."
                  },
                  "summary": {
                    "type": "string",
                    "description": "One line saying what it answers."
                  },
                  "body": {
                    "type": "string",
                    "description": "The article in Markdown, without the title."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Its address; made from the title when left out."
                  },
                  "category": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A category's id or slug on the same team, or null."
                  },
                  "audience": {
                    "type": "string",
                    "description": "Who may read it: public for customers, internal for the desk and AI only.",
                    "enum": [
                      "public",
                      "internal"
                    ]
                  },
                  "tags": {
                    "type": "array",
                    "description": "Tags.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "status": {
                    "type": "string",
                    "description": "published publishes it, draft unpublishes it.",
                    "enum": [
                      "draft",
                      "published"
                    ]
                  },
                  "team": {
                    "type": "string",
                    "description": "A team's slug or id."
                  }
                },
                "required": [
                  "title",
                  "body",
                  "team"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The article.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/article-draft": {
      "post": {
        "operationId": "draftArticleFromTicket",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Draft an article from a solved ticket",
        "description": "Asks the AI to turn a solved or closed ticket into a help article, with the customer's name, email addresses and ids taken out, and saves it as an unpublished draft on the ticket's team. 409 `not_solved` for an open ticket, `ai_off` or `budget_reached` when the organization has AI stopped; 502 `ai_failed` when the AI gave no article. AI agents' keys may not. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The draft article.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/articles/{ref}": {
      "get": {
        "operationId": "getArticle",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Read an article",
        "description": "By id or slug (an earlier slug still finds it). With `section`, only that `##` section.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "The team, when two teams use the slug.",
            "schema": {
              "type": "string",
              "description": "The team, when two teams use the slug."
            }
          },
          {
            "name": "section",
            "in": "query",
            "required": false,
            "description": "A `##` heading or its anchor.",
            "schema": {
              "type": "string",
              "description": "A `##` heading or its anchor."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The article with `body` and `outline`, or `{ article, section }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateArticle",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Change an article",
        "description": "Only the fields sent change. Send the `version` you read: if it changed since, the answer is 409 `conflict`. A published article keeps its team; a new slug keeps the old one as a redirect. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "The team, when two teams use the slug.",
            "schema": {
              "type": "string",
              "description": "The team, when two teams use the slug."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Its title."
                  },
                  "summary": {
                    "type": "string",
                    "description": "One line saying what it answers."
                  },
                  "body": {
                    "type": "string",
                    "description": "The article in Markdown, without the title."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Its address; made from the title when left out."
                  },
                  "category": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A category's id or slug on the same team, or null."
                  },
                  "audience": {
                    "type": "string",
                    "description": "Who may read it: public for customers, internal for the desk and AI only.",
                    "enum": [
                      "public",
                      "internal"
                    ]
                  },
                  "tags": {
                    "type": "array",
                    "description": "Tags.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "status": {
                    "type": "string",
                    "description": "published publishes it, draft unpublishes it.",
                    "enum": [
                      "draft",
                      "published"
                    ]
                  },
                  "team": {
                    "type": "string",
                    "description": "A team's slug or id. A published article keeps its team."
                  },
                  "version": {
                    "type": "integer",
                    "description": "The version you read."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The article.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteArticle",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Delete a draft",
        "description": "A published article is 409 `article_published`: unpublish it first. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "The team, when two teams use the slug.",
            "schema": {
              "type": "string",
              "description": "The team, when two teams use the slug."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted: true }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/articles/{ref}/publish": {
      "post": {
        "operationId": "publishArticle",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Publish an article",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "The team, when two teams use the slug.",
            "schema": {
              "type": "string",
              "description": "The team, when two teams use the slug."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "version": {
                    "type": "integer",
                    "description": "The version you read."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The article.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/articles/{ref}/unpublish": {
      "post": {
        "operationId": "unpublishArticle",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Unpublish an article",
        "description": "It goes back to a draft and leaves every public page. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "The team, when two teams use the slug.",
            "schema": {
              "type": "string",
              "description": "The team, when two teams use the slug."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "version": {
                    "type": "integer",
                    "description": "The version you read."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The article.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/articles/{ref}/history": {
      "get": {
        "operationId": "articleHistory",
        "tags": [
          "Knowledge base"
        ],
        "summary": "An article's history",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "The team, when two teams use the slug.",
            "schema": {
              "type": "string",
              "description": "The team, when two teams use the slug."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ versions }`, newest first: version, action, what changed, who and through which door.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/articles/{ref}/history/{version}": {
      "get": {
        "operationId": "articleVersion",
        "tags": [
          "Knowledge base"
        ],
        "summary": "An article as it was",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "description": "An article's version number.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "The team, when two teams use the slug.",
            "schema": {
              "type": "string",
              "description": "The team, when two teams use the slug."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The article at that version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/article-deflection": {
      "get": {
        "operationId": "articleDeflection",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Measure article deflection",
        "description": "While a customer types in the contact form or the widget, it suggests published public articles (SUPT-53). A visit that opened a suggestion and filed no ticket is a deflection; one that opened a suggestion in the last 30 minutes and filed nothing yet is pending.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "A team's slug or id. Default: every team.",
            "schema": {
              "type": "string",
              "description": "A team's slug or id. Default: every team."
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "How many days back, 1 to 365. Default 30.",
            "schema": {
              "type": "integer",
              "description": "How many days back, 1 to 365. Default 30."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ days, since, visits, deflected, filed, pending, articles }`: articles are the most opened, each with `opened` (visits) and `deflected`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/article-categories": {
      "get": {
        "operationId": "listArticleCategories",
        "tags": [
          "Knowledge base"
        ],
        "summary": "List categories",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "A team's slug or id.",
            "schema": {
              "type": "string",
              "description": "A team's slug or id."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ categories }`: top categories and their sections.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createArticleCategory",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Make a category",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "team": {
                    "type": "string",
                    "description": "A team's slug or id."
                  },
                  "name": {
                    "type": "string",
                    "description": "Its name."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Its address; made from the name when left out."
                  },
                  "description": {
                    "type": "string",
                    "description": "A line about it."
                  },
                  "parent": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A top category's id or slug to make this a section in it, or null."
                  },
                  "position": {
                    "type": "integer",
                    "description": "Its place in the list."
                  }
                },
                "required": [
                  "team",
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The category.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/article-categories/{ref}": {
      "patch": {
        "operationId": "updateArticleCategory",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Change a category",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Its name."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Its address; made from the name when left out."
                  },
                  "description": {
                    "type": "string",
                    "description": "A line about it."
                  },
                  "parent": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A top category's id or slug to make this a section in it, or null."
                  },
                  "position": {
                    "type": "integer",
                    "description": "Its place in the list."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The category.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteArticleCategory",
        "tags": [
          "Knowledge base"
        ],
        "summary": "Delete an empty category",
        "description": "One that holds articles or sections is 409 `category_in_use`. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted: true }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/macros": {
      "get": {
        "operationId": "listMacros",
        "tags": [
          "Macros"
        ],
        "summary": "List macros",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "required": false,
            "description": "Only the macros this team's tickets can use: a slug or id.",
            "schema": {
              "type": "string",
              "description": "Only the macros this team's tickets can use: a slug or id."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ macros }`, by name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createMacro",
        "tags": [
          "Macros"
        ],
        "summary": "Make a macro",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Unique on the desk, in any case (409 `name_taken`)."
                  },
                  "body": {
                    "type": "string",
                    "description": "Markdown with placeholders such as `{{customer.firstName | there}}`. May be empty when the macro changes fields."
                  },
                  "team": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A team's slug or id, or null for every team."
                  },
                  "changes": {
                    "type": "object",
                    "description": "Field changes: `status`, `priority`, `assignee` (`me`, an email or null), `addTags`, `removeTags`."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The macro.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Macro"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/macros/{id}": {
      "patch": {
        "operationId": "updateMacro",
        "tags": [
          "Macros"
        ],
        "summary": "Change a macro",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Unique on the desk, in any case (409 `name_taken`)."
                  },
                  "body": {
                    "type": "string",
                    "description": "Markdown with placeholders such as `{{customer.firstName | there}}`. May be empty when the macro changes fields."
                  },
                  "team": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A team's slug or id, or null for every team."
                  },
                  "changes": {
                    "type": "object",
                    "description": "Field changes: `status`, `priority`, `assignee` (`me`, an email or null), `addTags`, `removeTags`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The macro.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Macro"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteMacro",
        "tags": [
          "Macros"
        ],
        "summary": "Delete a macro",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted: true }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/macro": {
      "post": {
        "operationId": "applyMacro",
        "tags": [
          "Macros"
        ],
        "summary": "Apply a macro",
        "description": "Makes its field changes and fills in its reply for this ticket. Sends nothing: send `body` with `POST /tickets/{ref}/messages`, and `statusAfter` as its `status`. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "macro": {
                    "type": "string",
                    "description": "The macro's id or name."
                  }
                },
                "required": [
                  "macro"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ ticket, body, macro, statusAfter }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/automations": {
      "get": {
        "operationId": "listAutomations",
        "tags": [
          "Automations"
        ],
        "summary": "List triggers and automations",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "description": "Only one kind.",
            "schema": {
              "type": "string",
              "description": "Only one kind.",
              "enum": [
                "trigger",
                "automation"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ automations }`: triggers in the order they run, then automations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createAutomation",
        "tags": [
          "Automations"
        ],
        "summary": "Make a trigger or automation",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Unique on the desk, in any case (409 `name_taken`)."
                  },
                  "event": {
                    "type": "string",
                    "description": "Triggers only: when it runs.",
                    "enum": [
                      "created",
                      "updated",
                      "any"
                    ]
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "False keeps it without running it. Default true."
                  },
                  "position": {
                    "type": "integer",
                    "description": "Order among triggers, lowest first. New ones go last."
                  },
                  "conditions": {
                    "type": "array",
                    "description": "Every one must hold. Each is `{ field, op, value }`: `status`, `priority`, `channel`, `team`, `assignee`, `updatedBy`, `changed` with `is`/`isNot`; `tags` with `includes`/`excludes`; `subject` with `contains`/`notContains`; `hoursSinceCreated`, `hoursSinceUpdated`, `hoursSinceSolved` with `atLeast`/`lessThan`. An automation needs an `atLeast` hours condition and cannot use `updatedBy` or `changed`.",
                    "items": {
                      "type": "object"
                    }
                  },
                  "actions": {
                    "type": "array",
                    "description": "At least one, each type once: `{ type: \"status\"|\"priority\", value }`, `{ type: \"assign\", value: email|null }`, `{ type: \"addTags\"|\"removeTags\", value: [tags] }`, `{ type: \"reply\"|\"note\", body }` (Markdown with macro placeholders), `{ type: \"notify\", to: \"assignee\"|\"alerts\"|email, body }`.",
                    "items": {
                      "type": "object"
                    }
                  },
                  "kind": {
                    "type": "string",
                    "description": "`trigger` runs when a ticket is created or changed; `automation` runs on a clock.",
                    "enum": [
                      "trigger",
                      "automation"
                    ]
                  }
                },
                "required": [
                  "name",
                  "conditions",
                  "actions",
                  "kind"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The automation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/automations/{id}": {
      "patch": {
        "operationId": "updateAutomation",
        "tags": [
          "Automations"
        ],
        "summary": "Change a trigger or automation",
        "description": "Only the fields sent change; conditions and actions are replaced whole. The kind cannot change. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Unique on the desk among triggers and automations, in any case (409 `name_taken`)."
                  },
                  "event": {
                    "type": "string",
                    "description": "Triggers only: when it runs.",
                    "enum": [
                      "created",
                      "updated",
                      "any"
                    ]
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "False keeps it without running it. Default true."
                  },
                  "position": {
                    "type": "integer",
                    "description": "Order among triggers, lowest first. New ones go last."
                  },
                  "conditions": {
                    "type": "array",
                    "description": "Every one must hold. Each is `{ field, op, value }`: `status`, `priority`, `channel`, `team`, `assignee`, `updatedBy`, `changed` with `is`/`isNot`; `tags` with `includes`/`excludes`; `subject` with `contains`/`notContains`; `hoursSinceCreated`, `hoursSinceUpdated`, `hoursSinceSolved` with `atLeast`/`lessThan`. An automation needs an `atLeast` hours condition and cannot use `updatedBy` or `changed`.",
                    "items": {
                      "type": "object"
                    }
                  },
                  "actions": {
                    "type": "array",
                    "description": "At least one, each type once: `{ type: \"status\"|\"priority\", value }`, `{ type: \"assign\", value: email|null }`, `{ type: \"addTags\"|\"removeTags\", value: [tags] }`, `{ type: \"reply\"|\"note\", body }` (Markdown with macro placeholders), `{ type: \"notify\", to: \"assignee\"|\"alerts\"|email, body }`.",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The automation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteAutomation",
        "tags": [
          "Automations"
        ],
        "summary": "Delete a trigger or automation",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted: true }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/automations/reorder": {
      "post": {
        "operationId": "reorderAutomations",
        "tags": [
          "Automations"
        ],
        "summary": "Reorder triggers or automations",
        "description": "Rewrites dense positions (0, 1, 2, …) for one kind in a single step, placing `ids` first in the order sent and keeping any other rules of that kind in their existing order. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "description": "Optional kind check (`trigger` or `automation`).",
                    "enum": [
                      "trigger",
                      "automation"
                    ]
                  },
                  "ids": {
                    "type": "array",
                    "description": "Rule ids of one kind in their new order.",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ automations }`: that kind's rules in their new order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/customers/{ref}": {
      "get": {
        "operationId": "getCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Get a customer and their tickets",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The customer, with `tickets`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/mail-domains": {
      "get": {
        "operationId": "listMailDomains",
        "tags": [
          "Mail domains"
        ],
        "summary": "List your own mail domains",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ enabled, domains: [{ domain, defaultTeam, status, statusReason, records, checkedAt, verifiedAt, createdBy, createdAt }] }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "addMailDomain",
        "tags": [
          "Mail domains"
        ],
        "summary": "Receive mail on your own domain",
        "description": "Answers the DNS records to add. Mail to `<team slug>@<domain>` reaches that team once it is verified. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string",
                    "description": "Such as help.yourcompany.com."
                  },
                  "team": {
                    "type": "string",
                    "description": "The team that takes mail to addresses that name no team."
                  }
                },
                "required": [
                  "domain"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The domain, with its `records`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/mail-domains/{domain}": {
      "patch": {
        "operationId": "setMailDomainTeam",
        "tags": [
          "Mail domains"
        ],
        "summary": "Set a domain's default team",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "description": "A mail domain, such as help.yourcompany.com.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "team": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A slug or id, or null to refuse addresses that name no team."
                  }
                },
                "required": [
                  "team"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The domain.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "removeMailDomain",
        "tags": [
          "Mail domains"
        ],
        "summary": "Stop receiving on a domain",
        "description": "Its tickets stay. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "description": "A mail domain, such as help.yourcompany.com.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/mail-domains/{domain}/check": {
      "post": {
        "operationId": "checkMailDomain",
        "tags": [
          "Mail domains"
        ],
        "summary": "Check a domain's DNS records now",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "description": "A mail domain, such as help.yourcompany.com.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The domain.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/throwaway/settings": {
      "get": {
        "operationId": "getThrowawaySettings",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "Get throwaway mail settings",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "Whether throwaway mail is enabled and its domain.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/throwaway/inboxes": {
      "get": {
        "operationId": "listThrowawayInboxes",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "List throwaway inboxes",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ inboxes: [{ localPart, recipient, count, lastReceivedAt }] }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/throwaway/messages": {
      "get": {
        "operationId": "listThrowawayMessages",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "List throwaway messages",
        "description": "Newest first. Requires the organization's throwaway-mail toggle and the Supportress staff feature switch to be on.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "inbox",
            "in": "query",
            "required": false,
            "description": "Filter by local part or full address.",
            "schema": {
              "type": "string",
              "description": "Filter by local part or full address."
            }
          },
          {
            "name": "recipient",
            "in": "query",
            "required": false,
            "description": "Alias for inbox.",
            "schema": {
              "type": "string",
              "description": "Alias for inbox."
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search sender, subject and message text.",
            "schema": {
              "type": "string",
              "description": "Search sender, subject and message text."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Messages per page, 1 to 100 (default 50).",
            "schema": {
              "type": "integer",
              "description": "Messages per page, 1 to 100 (default 50)."
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "The next cursor from the previous page.",
            "schema": {
              "type": "string",
              "description": "The next cursor from the previous page."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ messages, next, total }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "clearThrowawayMessages",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "Clear throwaway messages",
        "description": "Omit both filters to clear all messages. A supplied blank filter is refused. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "inbox",
            "in": "query",
            "required": false,
            "description": "Clear only messages to this inbox local part or full address.",
            "schema": {
              "type": "string",
              "description": "Clear only messages to this inbox local part or full address."
            }
          },
          {
            "name": "recipient",
            "in": "query",
            "required": false,
            "description": "Alias for inbox.",
            "schema": {
              "type": "string",
              "description": "Alias for inbox."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/throwaway/messages/{id}": {
      "get": {
        "operationId": "getThrowawayMessage",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "Read a throwaway message",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The message, including text and sanitized HTML bodies and headers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteThrowawayMessage",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "Delete a throwaway message",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ deleted: true }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/throwaway/messages/{id}/raw": {
      "get": {
        "operationId": "getThrowawayRaw",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "Download the original throwaway message",
        "description": "The raw RFC 822 message, when one was retained.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/throwaway/links": {
      "get": {
        "operationId": "listThrowawayLinks",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "List throwaway inbox links",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ links }`; link tokens are never returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createThrowawayLink",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "Make a throwaway inbox link",
        "description": "Only a current organization admin may make a link. Its token appears only in the returned URL. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "localPart": {
                    "type": "string",
                    "description": "The inbox local part or full address."
                  },
                  "expiresInDays": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Expire after 1 to 365 days, or null for no expiry."
                  }
                },
                "required": [
                  "localPart"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The link metadata and its one-time URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/throwaway/links/{id}": {
      "delete": {
        "operationId": "revokeThrowawayLink",
        "tags": [
          "Throwaway mail"
        ],
        "summary": "Revoke a throwaway inbox link",
        "description": "Only a current organization admin may revoke a link. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ revoked: true }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/spam-settings": {
      "get": {
        "operationId": "getSpamSettings",
        "tags": [
          "Spam"
        ],
        "summary": "Get the spam check's settings",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ filter, deleteAfterDays, aiCheck, salesPitches, aiDailyCap, aiChecksToday, domainStrikes, chatBotDailyTurns, allowedSenders, struckDomains }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setSpamSettings",
        "tags": [
          "Spam"
        ],
        "summary": "Change the spam check's settings",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filter": {
                    "type": "string",
                    "description": "How hard it filters.",
                    "enum": [
                      "off",
                      "normal",
                      "strict"
                    ]
                  },
                  "deleteAfterDays": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Delete spam after this many days, or null to keep it.",
                    "enum": [
                      7,
                      30,
                      90,
                      null
                    ]
                  },
                  "aiCheck": {
                    "type": "boolean",
                    "description": "Ask the AI about mail the rules are unsure of."
                  },
                  "salesPitches": {
                    "type": "string",
                    "description": "Where cold sales mail goes.",
                    "enum": [
                      "spam",
                      "inbox"
                    ]
                  },
                  "aiDailyCap": {
                    "type": "integer",
                    "description": "AI checks a day, 0 to 10,000."
                  },
                  "domainStrikes": {
                    "type": "integer",
                    "description": "Spam marks against a domain before its strangers go to Spam: 0 (off) to 20."
                  },
                  "chatBotDailyTurns": {
                    "type": "integer",
                    "description": "Daily AI bot turn cap per anonymous chat widget visitor, 1 to 200."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "As `GET /spam-settings`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/blocked-senders": {
      "get": {
        "operationId": "listBlockedSenders",
        "tags": [
          "Spam"
        ],
        "summary": "List blocked senders",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ blockedSenders: [{ id, kind, value, createdBy, via, createdAt }] }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "blockSender",
        "tags": [
          "Spam"
        ],
        "summary": "Block a sender",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sender": {
                    "type": "string",
                    "description": "An address, or a domain such as example.com."
                  }
                },
                "required": [
                  "sender"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The blocked sender.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/blocked-senders/{ref}": {
      "delete": {
        "operationId": "unblockSender",
        "tags": [
          "Spam"
        ],
        "summary": "Unblock a sender",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/allowed-senders": {
      "post": {
        "operationId": "allowSender",
        "tags": [
          "Spam"
        ],
        "summary": "Never put a sender in Spam",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sender": {
                    "type": "string",
                    "description": "An address, or a domain."
                  }
                },
                "required": [
                  "sender"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The allowed sender.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/allowed-senders/{ref}": {
      "delete": {
        "operationId": "disallowSender",
        "tags": [
          "Spam"
        ],
        "summary": "Take a sender off the allow list",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/spam-strikes/{domain}": {
      "delete": {
        "operationId": "clearSpamStrikes",
        "tags": [
          "Spam"
        ],
        "summary": "Forget Spam marks against a domain",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "description": "A mail domain, such as help.yourcompany.com.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/outgoing-mail/settings": {
      "get": {
        "operationId": "getOutgoingMailSettings",
        "tags": [
          "Alerts"
        ],
        "summary": "Read the outgoing mail switch (organization admins only)",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ outgoingMailOff }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateOutgoingMailSettings",
        "tags": [
          "Alerts"
        ],
        "summary": "Turn outgoing mail off or on (organization admins only)",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "outgoingMailOff": {
                    "type": "boolean",
                    "description": "True stops all outgoing organization mail, including account and billing notices."
                  }
                },
                "required": [
                  "outgoingMailOff"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ outgoingMailOff }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/alerts": {
      "get": {
        "operationId": "getAlerts",
        "tags": [
          "Alerts"
        ],
        "summary": "Who gets an email for each new ticket and customer reply",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ emails }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setAlerts",
        "tags": [
          "Alerts"
        ],
        "summary": "Set who gets alerts",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "emails": {
                    "type": "array",
                    "description": "Up to 20 addresses; `[]` for none.",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "emails"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ emails }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ai-settings": {
      "get": {
        "operationId": "getAiSettings",
        "tags": [
          "AI"
        ],
        "summary": "Get the AI settings",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ available, enabled, triage, replyPrediction, autoAnswer, stats, budget, answers, practice }`. `autoAnswer` is `{ topics, bars, modes, teams }`, each team `{ team, mode, bar, excludedTopics, rules }`. `answers` is this month's AI resolution billing (`GET /ai-answers`), and `practice` is the last 30 days' per-team practice report.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setAiSettings",
        "tags": [
          "AI"
        ],
        "summary": "Change AI triage, reply prediction and a team's Auto-answer",
        "description": "Only an admin turns AI on or off for the whole organization, in the app. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "triage": {
                    "type": "string",
                    "description": "What AI triage does with new tickets.",
                    "enum": [
                      "off",
                      "suggest",
                      "apply"
                    ]
                  },
                  "replyPrediction": {
                    "type": "boolean",
                    "description": "Predict replies to customers."
                  },
                  "autoAnswer": {
                    "type": "object",
                    "description": "One team's Auto-answer (SUPT-208, SUPT-217): `{ team, mode?: off|suggest|practice|auto, bar?: careful|balanced|eager, excludedTopics?: [topic], rules?: [sentence] }`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "As `GET /ai-settings`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ai-usage": {
      "get": {
        "operationId": "getAiUsage",
        "tags": [
          "AI"
        ],
        "summary": "This month's AI spend",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ month, spentUsd, calls, state, allowanceUsd, monthlyBudgetUsd, limitUsd, capBy, chargeable, chargeUsd, markupPercent, byFeature, byTeam }`: the spend against the plan's allowance and the budget for use past it, and what that adds to the bill so far.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ai-answers": {
      "get": {
        "operationId": "getAiAnswers",
        "tags": [
          "AI"
        ],
        "summary": "This month's AI answers",
        "description": "Auto-answer's verified resolutions (SUPT-210, SUPT-219): each month's first ones are in the plan, then prepaid packs, then `priceUsd` each up to the organization's cap. Open answers count as if they will resolve; at `limitAnswers` the AI stops answering on its own. An admin sets the cap in Settings, AI.",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ month, includedAnswers, includedAnswersLeft, resolvedAnswers, openAnswers, limitAnswers, monthlyCapUsd, priceUsd, state, warnAtPercent, chargeable, comped, paygAnswers, chargeUsd, packAnswers, packCreditsLeft }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ai-usage/calls": {
      "get": {
        "operationId": "listAiCalls",
        "tags": [
          "AI"
        ],
        "summary": "The AI call log",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 200, default 50.",
            "schema": {
              "type": "integer",
              "description": "1 to 200, default 50."
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "The `next` of the page before.",
            "schema": {
              "type": "string",
              "description": "The `next` of the page before."
            }
          },
          {
            "name": "feature",
            "in": "query",
            "required": false,
            "description": "Only one feature.",
            "schema": {
              "type": "string",
              "description": "Only one feature.",
              "enum": [
                "triage",
                "reply_prediction",
                "spam",
                "summary",
                "article_draft",
                "config_prompt",
                "chat_bot"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ calls, next }`, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/prediction": {
      "get": {
        "operationId": "getPrediction",
        "tags": [
          "AI"
        ],
        "summary": "The predicted reply, if one was made",
        "description": "Never calls the AI. Includes the help articles used to ground the draft (`articles`).",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ prediction, reason }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "makePrediction",
        "tags": [
          "AI"
        ],
        "summary": "Predict the reply",
        "description": "Searches the team's help articles and asks the AI when there is no prediction yet. AI agents' keys may not. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ prediction, reason }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/prediction/{id}/dismiss": {
      "post": {
        "operationId": "dismissPrediction",
        "tags": [
          "AI"
        ],
        "summary": "Turn a prediction down",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ dismissed }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/config/current": {
      "get": {
        "operationId": "getCurrentConfig",
        "tags": [
          "Configuration"
        ],
        "summary": "Current safe support configuration in plain language",
        "description": "Returns `{ markdown, snapshot }` for teams, macros, saved views, help articles, spam settings, alerts and AI settings. Never includes secrets, credentials, billing or sign-in access.",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ markdown, snapshot }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/config/proposals": {
      "get": {
        "operationId": "listConfigProposals",
        "tags": [
          "Configuration"
        ],
        "summary": "List recent configuration proposals",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ proposals }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "proposeConfig",
        "tags": [
          "Configuration"
        ],
        "summary": "Propose support configuration changes from plain words",
        "description": "Turns plain words into typed validated operations with diffs and a 30-day dry-run against real tickets. Changes nothing until approved. Secrets, credentials, billing and sign-in access cannot be changed. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "words": {
                    "type": "string",
                    "description": "What to configure, in plain words."
                  }
                },
                "required": [
                  "words"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The pending proposal with `operations`, `dryRun` and `warnings`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/config/proposals/{id}": {
      "patch": {
        "operationId": "editConfigProposal",
        "tags": [
          "Configuration"
        ],
        "summary": "Edit a pending configuration proposal",
        "description": "Replaces the pending proposal's operations, re-validating every operation and recomputing its 30-day dry-run. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operations": {
                    "type": "array",
                    "description": "Typed operation payloads.",
                    "items": {
                      "type": "object"
                    }
                  },
                  "summary": {
                    "type": "string",
                    "description": "Optional updated summary."
                  }
                },
                "required": [
                  "operations"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated proposal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/config/proposals/{id}/apply": {
      "post": {
        "operationId": "applyConfigProposal",
        "tags": [
          "Configuration"
        ],
        "summary": "Apply a pending configuration proposal",
        "description": "Applies all operations as one undoable config event. Destructive operations ask twice: the first call returns `{ applied: false, needsConfirmation: true, confirmToken, destructiveOperations }` without changing anything; pass `confirmToken` on the second call to apply. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirmToken": {
                    "type": "string",
                    "description": "One-time confirmation token returned on the first apply call for destructive proposals."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ applied: true, event }` or `{ applied: false, needsConfirmation: true, confirmToken, destructiveOperations, message }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/config/proposals/{id}/reject": {
      "post": {
        "operationId": "rejectConfigProposal",
        "tags": [
          "Configuration"
        ],
        "summary": "Reject a pending configuration proposal",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The rejected proposal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/config/events": {
      "get": {
        "operationId": "listConfigEvents",
        "tags": [
          "Configuration"
        ],
        "summary": "List applied configuration events",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ events }`, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/config/events/{id}/undo": {
      "post": {
        "operationId": "undoConfigEvent",
        "tags": [
          "Configuration"
        ],
        "summary": "Undo an applied configuration event as a unit",
        "description": "Reverts every operation of that config event in reverse order. Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ event }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/trackers": {
      "get": {
        "operationId": "listTrackers",
        "tags": [
          "Dev issues"
        ],
        "summary": "List the connected dev trackers",
        "description": "Trackers are connected in the app.",
        "security": [
          {
            "token": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{ kinds, trackers, defaultTrackerId }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/dev-issues/route": {
      "get": {
        "operationId": "devIssueRoute",
        "tags": [
          "Dev issues"
        ],
        "summary": "Where an issue filed from this ticket goes",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ tracker, destination, from, where }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ref}/dev-issues": {
      "post": {
        "operationId": "fileDevIssue",
        "tags": [
          "Dev issues"
        ],
        "summary": "File a dev issue from a ticket",
        "description": "When the issue is done, the ticket's customer gets the fix reply, drafted or sent as the team chose. Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "summary": {
                    "type": "string",
                    "description": "For engineers."
                  },
                  "title": {
                    "type": "string",
                    "description": "Default: the ticket's subject."
                  },
                  "tracker": {
                    "type": "string",
                    "description": "A tracker's name or id. Default: the team's, else the organization's."
                  },
                  "destination": {
                    "type": "object",
                    "description": "Where in the tracker, such as `{ \"repo\": \"owner/name\" }`."
                  },
                  "includeCustomerWords": {
                    "type": "boolean",
                    "description": "Quote the customer's first message. Default false."
                  }
                },
                "required": [
                  "summary"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`{ issue, ticket }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/{ref}/dev-issues/link": {
      "post": {
        "operationId": "linkDevIssue",
        "tags": [
          "Dev issues"
        ],
        "summary": "Link an issue already in the tracker",
        "description": "Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "issue": {
                    "type": "string",
                    "description": "Its address, key or number."
                  },
                  "tracker": {
                    "type": "string",
                    "description": "A tracker's name or id."
                  }
                },
                "required": [
                  "issue"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`{ issue, ticket }`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/tickets/{ref}/dev-issues/{id}": {
      "delete": {
        "operationId": "unlinkDevIssue",
        "tags": [
          "Dev issues"
        ],
        "summary": "Unlink a dev issue",
        "description": "The issue stays in the tracker. Needs a read-and-write token.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "A ticket's number or id (an article: its id or slug, with `?team=` when two teams share the slug; an article category: its id or slug; a team: its id or slug; a customer: their email or id; a blocked or allowed sender: its id, or the address or domain itself).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketDetail"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. `rate_limited` (intake, 120 a minute per key) carries `Retry-After` in seconds. `ai_rate_limited` (an AI agent's public replies and new tickets: 60 an hour across the desk, 5 an hour on one ticket) has no `Retry-After`: try again later in the hour; notes still go.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-ai-agent-allowed": true
      }
    },
    "/dev-issues/{id}": {
      "get": {
        "operationId": "getDevIssue",
        "tags": [
          "Dev issues"
        ],
        "summary": "Get a dev issue and the tickets waiting on it",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The issue, with `tickets`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/dev-issues/{id}/refresh": {
      "post": {
        "operationId": "refreshDevIssue",
        "tags": [
          "Dev issues"
        ],
        "summary": "Read a dev issue from its tracker now",
        "description": "Needs a read-and-write token. Not open to AI agents' keys.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The item's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The issue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The request was not right: `invalid_<field>`, `invalid_body` and the like.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No credential, or a wrong one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Refused for billing: `billing_lapsed` (the desk is read-only until paid), or `add_a_card` (the desk is exploring and this reaches real mail).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not allowed: `insufficient_scope` (a read token), `ai_not_allowed`, `not_an_agent`, `blocked`, `feature_off`, `organization_suspended`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such item, or not in this organization. `no_organization` when the address names no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It conflicts with what is there, such as `new_reply` or `name_taken`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "tags": [
          "Reference"
        ],
        "summary": "This description, as OpenAPI 3.1",
        "security": [],
        "responses": {
          "200": {
            "description": "This document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "token": {
        "type": "http",
        "scheme": "bearer",
        "description": "A personal access token (`spt_...`, Settings > API and MCP) or an AI agent's key (`spa_...`, Settings > AI agents). Read tokens may only GET."
      },
      "intakeKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A team's intake key (`spk_...`), made in Settings on the team's menu. It only opens tickets on its own team."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string",
                "description": "Written for a person."
              }
            }
          }
        }
      },
      "Team": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "enum": [
              "blue",
              "teal",
              "amber",
              "violet",
              "rose",
              "orange"
            ]
          },
          "supportEmail": {
            "type": [
              "string",
              "null"
            ],
            "description": "The support address that forwards to this team."
          },
          "senderName": {
            "type": "string"
          },
          "autoReply": {
            "type": "boolean"
          },
          "autoReplyText": {
            "type": [
              "string",
              "null"
            ]
          },
          "autoReplyDefault": {
            "type": "string"
          },
          "solvedEmail": {
            "type": "boolean"
          },
          "csat": {
            "type": "boolean",
            "description": "Solving a ticket asks the customer to rate it, good or bad."
          },
          "signature": {
            "type": [
              "string",
              "null"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "customerMcp": {
            "type": "boolean"
          },
          "contextUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer context callback (SUPT-28), or null."
          },
          "mailPrefix": {
            "type": [
              "string",
              "null"
            ]
          },
          "forwardingCheck": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "Ticket": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "number": {
            "type": "integer"
          },
          "subject": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "open",
              "pending",
              "solved",
              "closed"
            ]
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "normal",
              "high",
              "urgent"
            ]
          },
          "team": {
            "type": "object",
            "description": "`{ id, slug, name, color }`."
          },
          "customer": {
            "type": "object",
            "description": "`{ id, email, name }`."
          },
          "channel": {
            "type": "string",
            "description": "The door it came in by, such as email, portal or api."
          },
          "assignee": {
            "type": [
              "string",
              "null"
            ],
            "description": "An agent's or AI agent's email."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "spam": {
            "type": "boolean"
          },
          "spamReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "firstResponseAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "solvedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastActivityAt": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "sla": {
            "type": [
              "object",
              "null"
            ],
            "description": "Its team's SLA clocks, `{ firstResponse, resolution }`, or null when the team has no SLA policy. Each clock is null when the policy sets no target for the ticket's priority, or `{ state, targetMinutes, dueAt, warnAt }`: state `running` (due at dueAt), `paused` (pending, when the policy pauses on it; dueAt null), `met`, `breached`, or `unanswered` (first response only: the ticket was solved or closed in time with no public reply). warnAt is when three quarters of the time is used, while running."
          }
        }
      },
      "TicketDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Ticket"
          },
          {
            "type": "object",
            "properties": {
              "messages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "description": "`{ id, authorKind, authorName, authorEmail, body, format, html, internal, via, attachments, createdAt }`"
                }
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "emails": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "devIssues": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "drafts": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "linkedTickets": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "otherTickets": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "mergedInto": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "mergedFrom": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "description": "Definition plus value: id, label, type, value, options, teamIds, requiredToSolve, aiMayFill, helpText, position, archived, version. Only applicable fields; archived ones with retained values are read-only."
                }
              },
              "metadata": {
                "type": "object"
              },
              "externalUserId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "summary": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "triage": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "csat": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "The customer's satisfaction rating: `{ rating: \"good\" | \"bad\", comment, ratedAt }`, or null while they gave none."
              }
            }
          }
        ]
      },
      "Automation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "trigger",
              "automation"
            ]
          },
          "event": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "position": {
            "type": "integer"
          },
          "conditions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        }
      },
      "Macro": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "team": {
            "type": [
              "object",
              "null"
            ]
          },
          "changes": {
            "type": "object"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        }
      }
    }
  }
}
