{
  "openapi": "3.1.1",
  "info": {
    "title": "Sortbay API",
    "version": "1.0.0",
    "summary": "Deterministic tools for people and AI agents.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://sortbay.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/tools": {
      "get": {
        "operationId": "listTools",
        "summary": "Catalog of all tools",
        "responses": {
          "200": {
            "description": "Tool list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/{id}": {
      "get": {
        "operationId": "getTool",
        "summary": "Definition of one tool",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "sortbay-email-parse",
                "sortbay-triage-rules",
                "sortbay-thread-group"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/sortbay-email-parse/calculate": {
      "post": {
        "operationId": "calculateSortbayEmailParse",
        "summary": "Read an .eml or .mbox file: sender, recipients, date, subject, clean text and attachment list.",
        "description": "Parses e-mail source the way a mail program would — RFC 5322 headers, MIME multipart, quoted-printable and base64, encoded subjects and file names in any charset, mbox archives — and returns each message as JSON: sender, recipients, date in UTC, subject, the readable text (HTML mail reduced to safe plain text), threading ids and the attachments by name, type and size. Attachment contents are never extracted or stored.\n\nMethodology:\n- Headers are unfolded (RFC 5322 §2.2.3), encoded words like =?UTF-8?B?…?= and =?ISO-8859-1?Q?…?= are decoded (RFC 2047), file names with RFC 2231 continuations and charsets are joined; raw 8-bit headers are read as UTF-8, else Windows-1252.\n- Bodies: base64 and quoted-printable are decoded and the declared charset is applied; multipart/alternative prefers the plain-text part; an HTML-only mail is reduced to plain text (scripts, styles and comments removed, all tags dropped, links kept as “text (url)” for http(s) and mailto only, entities decoded).\n- Attachments (including inline images and forwarded messages) are listed with name, type and decoded size; their content is not returned. Forwarded messages (message/rfc822) are also quoted into the text.\n- Dates are converted to UTC from the numeric offset or the obsolete zone names (GMT, EST, PDT …). mbox files split on “From ” lines after an empty line (RFC 4155) and “\u003eFrom ” escapes are undone. Limits: 500 messages, 200 MIME parts and 8 nesting levels per message, 100 000 characters of text.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "sortbay_email_parse",
        "x-owner-app": "sortbay",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SortbayEmailParseInput"
              },
              "examples": {
                "example1": {
                  "summary": "Invoice with a PDF and a German subject",
                  "value": {
                    "source": "From: =?UTF-8?Q?J=C3=BCrgen_M=C3=BCller?= \u003cbuchhaltung@example.de\u003e\nTo: \"Example Ltd, Accounts\" \u003caccounts@example.org\u003e\nSubject: =?UTF-8?B?UmVjaG51bmcgTnIuIDIwMjYtMTE4IOKAkyBiaXR0ZSBwcsO8ZmVu?=\nDate: Tue, 1 Dec 2026 08:03:10 +0000\nMessage-ID: \u003cinv-118@example.de\u003e\nMIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"mix-1\"\n\n--mix-1\nContent-Type: multipart/alternative; boundary=\"alt-1\"\n\n--alt-1\nContent-Type: text/plain; charset=ISO-8859-1\nContent-Transfer-Encoding: quoted-printable\n\nGuten Tag,\n\nanbei die Rechnung f=FCr November. Zahlbar innerhalb von 14 Tagen.\n\nGr=FC=DFe\nJ=FCrgen M=FCller\n--alt-1\nContent-Type: text/html; charset=utf-8\n\n\u003chtml\u003e\u003cbody\u003e\u003cp\u003eGuten Tag,\u003c/p\u003e\u003cp\u003eanbei die Rechnung f\u0026uuml;r November.\u003c/p\u003e\u003cscript\u003ealert(1)\u003c/script\u003e\u003c/body\u003e\u003c/html\u003e\n--alt-1--\n\n--mix-1\nContent-Type: application/pdf; name=\"Rechnung-2026-118.pdf\"\nContent-Disposition: attachment; filename=\"Rechnung-2026-118.pdf\"\nContent-Transfer-Encoding: base64\n\nJVBERi0xLjQKJcfsj6IKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c+PgplbmRvYmoKdHJhaWxlcgo8\nPC9Sb290IDEgMCBSPj4KJSVFT0YK\n--mix-1--\n"
                  }
                },
                "example2": {
                  "summary": "HTML-only booking mail (base64)",
                  "value": {
                    "source": "From: Events Team \u003cevents@example.net\u003e\nTo: hello@example.org\nSubject: Your booking for the winter workshop\nDate: Wed, 2 Dec 2026 15:30:00 -0500\nMessage-ID: \u003cbook-77@example.net\u003e\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: base64\n\nPGgxPkJvb2tpbmcgY29uZmlybWVkPC9oMT48cD5IaSBTYW0sPGJyPnlvdXIgc2VhdCBmb3IgdGhl\nIDxiPldpbnRlciB3b3Jrc2hvcDwvYj4gb24gMTIgRGVjZW1iZXIgaXMgYm9va2VkLjwvcD48dWw+\nPGxpPlRpbWU6IDEwOjAwPC9saT48bGk+Um9vbTogQjI8L2xpPjwvdWw+PHA+PGEgaHJlZj0iaHR0\ncHM6Ly9leGFtcGxlLm5ldC9ib29raW5nLzc3Ij5NYW5hZ2UgeW91ciBib29raW5nPC9hPjwvcD48\nc3R5bGU+cHtjb2xvcjpyZWR9PC9zdHlsZT4=\n"
                  }
                },
                "example3": {
                  "summary": "mbox with three messages",
                  "value": {
                    "source": "From maria.lopez@example.com Mon Nov 30 09:12:44 2026\nFrom: \"Maria Lopez\" \u003cmaria.lopez@example.com\u003e\nTo: Support \u003csupport@example.org\u003e\nSubject: Can't log in after the update\nDate: Mon, 30 Nov 2026 09:12:44 +0100\nMessage-ID: \u003ca1-login@example.com\u003e\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: quoted-printable\n\nHi there,\n\nsince yesterday's update I can't log in any more. The page says =E2=80=9Cs=\nession expired=E2=80=9D right after I type my password.\n\nI'm on Firefox on Windows 11. Could you have a look?\n\nThanks,\nMaria\n\nFrom maria.lopez@example.com Mon Nov 30 11:40:02 2026\nFrom: Maria Lopez \u003cmaria.lopez@example.com\u003e\nTo: support@example.org\nSubject: Re: Can't log in after the update\nDate: Mon, 30 Nov 2026 11:40:02 +0100\nMessage-ID: \u003ca2-login@example.com\u003e\nIn-Reply-To: \u003ca1-login@example.com\u003e\nReferences: \u003ca1-login@example.com\u003e\nContent-Type: text/plain; charset=us-ascii\n\nClearing the cookies helped, thank you! Still strange that it happened.\n\nMaria\n\nFrom priya@shop.example Tue Dec  1 08:35:00 2026\nFrom: Priya Natarajan \u003cpriya@shop.example\u003e\nTo: sales@example.org\nCc: Tom Becker \u003ctom@shop.example\u003e\nSubject: Quote for 40 seats?\nDate: Tue, 01 Dec 2026 14:05:00 +0530\nMessage-ID: \u003clead-40@shop.example\u003e\nContent-Type: text/plain; charset=utf-8\n\nHello,\n\nwe are a team of 40 and would like a quote for annual licences, ideally with\na training session in January. Can you send pricing by Friday?\n\n\u003eFrom the team side we are flexible.\n\nBest regards,\nPriya\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SortbayEmailParseResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/sortbay-triage-rules/calculate": {
      "post": {
        "operationId": "calculateSortbayTriageRules",
        "summary": "Test inbox rules on real mail: which labels, assignee, status and due date each message gets.",
        "description": "Runs deterministic triage rules — conditions on sender, recipients, subject, text, attachment names or source, actions that add labels, assign, set a status or a due date — over e-mails from an .eml/.mbox file and explains for every message which rule matched and what it set. The same evaluator sorts new mail in the Sortbay shared inbox.\n\nMethodology:\n- A rule matches when all (match: all) or any (match: any) of its conditions hold. Comparisons ignore case and accents; there are no user regular expressions, so a rule can never hang the evaluator.\n- Rules run in order. Labels of every matching rule are collected; assignee, status and due date come from the FIRST matching rule that sets them; a matching rule with stop ends the evaluation for that message.\n- Due dates are the message date (UTC day) plus dueInDays; messages without a date use “today”. “text” means subject and body together; “to” covers To and Cc; domain_is also matches subdomains.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "sortbay_triage_rules",
        "x-owner-app": "sortbay",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SortbayTriageRulesInput"
              },
              "examples": {
                "example1": {
                  "summary": "Support, invoice and sales mail",
                  "value": {}
                },
                "example2": {
                  "summary": "One invoice with a PDF",
                  "value": {
                    "source": "From: =?UTF-8?Q?J=C3=BCrgen_M=C3=BCller?= \u003cbuchhaltung@example.de\u003e\nTo: \"Example Ltd, Accounts\" \u003caccounts@example.org\u003e\nSubject: =?UTF-8?B?UmVjaG51bmcgTnIuIDIwMjYtMTE4IOKAkyBiaXR0ZSBwcsO8ZmVu?=\nDate: Tue, 1 Dec 2026 08:03:10 +0000\nMessage-ID: \u003cinv-118@example.de\u003e\nMIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"mix-1\"\n\n--mix-1\nContent-Type: multipart/alternative; boundary=\"alt-1\"\n\n--alt-1\nContent-Type: text/plain; charset=ISO-8859-1\nContent-Transfer-Encoding: quoted-printable\n\nGuten Tag,\n\nanbei die Rechnung f=FCr November. Zahlbar innerhalb von 14 Tagen.\n\nGr=FC=DFe\nJ=FCrgen M=FCller\n--alt-1\nContent-Type: text/html; charset=utf-8\n\n\u003chtml\u003e\u003cbody\u003e\u003cp\u003eGuten Tag,\u003c/p\u003e\u003cp\u003eanbei die Rechnung f\u0026uuml;r November.\u003c/p\u003e\u003cscript\u003ealert(1)\u003c/script\u003e\u003c/body\u003e\u003c/html\u003e\n--alt-1--\n\n--mix-1\nContent-Type: application/pdf; name=\"Rechnung-2026-118.pdf\"\nContent-Disposition: attachment; filename=\"Rechnung-2026-118.pdf\"\nContent-Transfer-Encoding: base64\n\nJVBERi0xLjQKJcfsj6IKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c+PgplbmRvYmoKdHJhaWxlcgo8\nPC9Sb290IDEgMCBSPj4KJSVFT0YK\n--mix-1--\n"
                  }
                },
                "example3": {
                  "summary": "Route by sender domain",
                  "value": {
                    "source": "From: Priya Natarajan \u003cpriya@shop.example\u003e\nTo: sales@example.org\nCc: Tom Becker \u003ctom@shop.example\u003e\nSubject: Quote for 40 seats?\nDate: Tue, 01 Dec 2026 14:05:00 +0530\nMessage-ID: \u003clead-40@shop.example\u003e\nContent-Type: text/plain; charset=utf-8\n\nHello,\n\nwe are a team of 40 and would like a quote for annual licences, ideally with\na training session in January. Can you send pricing by Friday?\n\nBest regards,\nPriya\n",
                    "rules": "[{\"name\":\"Shop customers\",\"conditions\":[{\"field\":\"from\",\"op\":\"domain_is\",\"value\":\"shop.example\"}],\"actions\":{\"labels\":[\"Customer\"],\"assignee\":\"Sam\",\"dueInDays\":2}}]"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SortbayTriageRulesResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/sortbay-thread-group/calculate": {
      "post": {
        "operationId": "calculateSortbayThreadGroup",
        "summary": "Group an mbox into conversations by Message-ID, In-Reply-To and References, like a mail program.",
        "description": "Sorts the messages of an mbox file (or several pasted .eml sources) into conversations: replies are linked through Message-ID, In-Reply-To and References, missing parents still connect their replies, and messages without those headers join a thread only when the subject matches after removing Re:/Fwd:/AW:/WG: prefixes and they share a participant.\n\nMethodology:\n- Union-find over Message-ID ↔ In-Reply-To/References (RFC 5322 §3.6.4); a reference to a message that is not in the file still links every message that names it.\n- Messages without header links are merged by normalised subject only when one of them is a reply/forward (Re:, Fwd:, AW:, WG:, SV:, Antw:, Tr: … and [list] tags removed) and they share an address — so unrelated mails with the same subject stay apart.\n- Threads are sorted newest first by their latest message; messages inside a thread by date. Thread ids are a stable hash of the first message.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "sortbay_thread_group",
        "x-owner-app": "sortbay",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SortbayThreadGroupInput"
              },
              "examples": {
                "example1": {
                  "summary": "Support conversation and a sales mail",
                  "value": {}
                },
                "example2": {
                  "summary": "Reply without headers, joined by subject",
                  "value": {
                    "source": "From a Mon Nov 30 09:00:00 2026\nFrom: \"Maria Lopez\" \u003cmaria.lopez@example.com\u003e\nTo: Support \u003csupport@example.org\u003e\nSubject: Can't log in after the update\nDate: Mon, 30 Nov 2026 09:12:44 +0100\nMessage-ID: \u003ca1-login@example.com\u003e\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: quoted-printable\n\nHi there,\n\nsince yesterday's update I can't log in any more. The page says =E2=80=9Cs=\nession expired=E2=80=9D right after I type my password.\n\nI'm on Firefox on Windows 11. Could you have a look?\n\nThanks,\nMaria\n\nFrom b Tue Dec  1 10:00:00 2026\nFrom: support@example.org\nTo: maria.lopez@example.com\nSubject: AW: Can't log in after the update\nDate: Tue, 1 Dec 2026 10:00:00 +0100\n\nWe reset your session. Please try again.\n"
                  }
                },
                "example3": {
                  "summary": "Two messages, two threads",
                  "value": {
                    "source": "From a Mon Nov 30 09:00:00 2026\nFrom: Maria Lopez \u003cmaria.lopez@example.com\u003e\nTo: support@example.org\nSubject: Re: Can't log in after the update\nDate: Mon, 30 Nov 2026 11:40:02 +0100\nMessage-ID: \u003ca2-login@example.com\u003e\nIn-Reply-To: \u003ca1-login@example.com\u003e\nReferences: \u003ca1-login@example.com\u003e\nContent-Type: text/plain; charset=us-ascii\n\nClearing the cookies helped, thank you! Still strange that it happened.\n\nMaria\n\nFrom b Tue Dec  1 08:00:00 2026\nFrom: Priya Natarajan \u003cpriya@shop.example\u003e\nTo: sales@example.org\nCc: Tom Becker \u003ctom@shop.example\u003e\nSubject: Quote for 40 seats?\nDate: Tue, 01 Dec 2026 14:05:00 +0530\nMessage-ID: \u003clead-40@shop.example\u003e\nContent-Type: text/plain; charset=utf-8\n\nHello,\n\nwe are a team of 40 and would like a quote for annual licences, ideally with\na training session in January. Can you send pricing by Friday?\n\nBest regards,\nPriya\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SortbayThreadGroupResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflows": {
      "get": {
        "operationId": "listWorkflows",
        "summary": "Multi-tool workflows",
        "responses": {
          "200": {
            "description": "Workflow list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "SortbayEmailParseInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "source": {
            "title": "E-mail source (.eml text) or mbox",
            "description": "Paste the full source of a message (headers, a blank line, then the body) — in most mail programs “Show original” or “View source”. Several messages: paste an mbox (each starts with a “From ” line).",
            "type": "string",
            "maxLength": 2000000,
            "default": "From: =?UTF-8?Q?J=C3=BCrgen_M=C3=BCller?= \u003cbuchhaltung@example.de\u003e\nTo: \"Example Ltd, Accounts\" \u003caccounts@example.org\u003e\nSubject: =?UTF-8?B?UmVjaG51bmcgTnIuIDIwMjYtMTE4IOKAkyBiaXR0ZSBwcsO8ZmVu?=\nDate: Tue, 1 Dec 2026 08:03:10 +0000\nMessage-ID: \u003cinv-118@example.de\u003e\nMIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"mix-1\"\n\n--mix-1\nContent-Type: multipart/alternative; boundary=\"alt-1\"\n\n--alt-1\nContent-Type: text/plain; charset=ISO-8859-1\nContent-Transfer-Encoding: quoted-printable\n\nGuten Tag,\n\nanbei die Rechnung f=FCr November. Zahlbar innerhalb von 14 Tagen.\n\nGr=FC=DFe\nJ=FCrgen M=FCller\n--alt-1\nContent-Type: text/html; charset=utf-8\n\n\u003chtml\u003e\u003cbody\u003e\u003cp\u003eGuten Tag,\u003c/p\u003e\u003cp\u003eanbei die Rechnung f\u0026uuml;r November.\u003c/p\u003e\u003cscript\u003ealert(1)\u003c/script\u003e\u003c/body\u003e\u003c/html\u003e\n--alt-1--\n\n--mix-1\nContent-Type: application/pdf; name=\"Rechnung-2026-118.pdf\"\nContent-Disposition: attachment; filename=\"Rechnung-2026-118.pdf\"\nContent-Transfer-Encoding: base64\n\nJVBERi0xLjQKJcfsj6IKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c+PgplbmRvYmoKdHJhaWxlcgo8\nPC9Sb290IDEgMCBSPj4KJSVFT0YK\n--mix-1--\n"
          },
          "file": {
            "title": "E-mail file (.eml or .mbox, optional)",
            "description": "Up to 10 MB. Used instead of the pasted text when given. Export single mails as .eml or a folder as .mbox from your mail program. Upload as {filename, contentType?, contentBase64}. Max 9766 KiB. Accepts .eml,.mbox,.mbx,.txt,message/rfc822,application/mbox,text/plain.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "includeHeaders": {
            "title": "Include every header line in the result",
            "type": "boolean",
            "default": false
          }
        },
        "required": []
      },
      "SortbayEmailParseResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "required": [
              "kind",
              "count",
              "truncated",
              "messages"
            ],
            "properties": {
              "kind": {
                "enum": [
                  "eml",
                  "mbox"
                ]
              },
              "count": {
                "type": "integer"
              },
              "truncated": {
                "type": "boolean"
              },
              "messages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "subject",
                    "from",
                    "to",
                    "date",
                    "text",
                    "attachments"
                  ]
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "SortbayTriageRulesInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "source": {
            "title": "E-mail source (.eml text) or mbox",
            "description": "Paste the full source of a message (headers, a blank line, then the body) — in most mail programs “Show original” or “View source”. Several messages: paste an mbox (each starts with a “From ” line).",
            "type": "string",
            "maxLength": 2000000,
            "default": "From maria.lopez@example.com Mon Nov 30 09:12:44 2026\nFrom: \"Maria Lopez\" \u003cmaria.lopez@example.com\u003e\nTo: Support \u003csupport@example.org\u003e\nSubject: Can't log in after the update\nDate: Mon, 30 Nov 2026 09:12:44 +0100\nMessage-ID: \u003ca1-login@example.com\u003e\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: quoted-printable\n\nHi there,\n\nsince yesterday's update I can't log in any more. The page says =E2=80=9Cs=\nession expired=E2=80=9D right after I type my password.\n\nI'm on Firefox on Windows 11. Could you have a look?\n\nThanks,\nMaria\n\nFrom maria.lopez@example.com Mon Nov 30 11:40:02 2026\nFrom: Maria Lopez \u003cmaria.lopez@example.com\u003e\nTo: support@example.org\nSubject: Re: Can't log in after the update\nDate: Mon, 30 Nov 2026 11:40:02 +0100\nMessage-ID: \u003ca2-login@example.com\u003e\nIn-Reply-To: \u003ca1-login@example.com\u003e\nReferences: \u003ca1-login@example.com\u003e\nContent-Type: text/plain; charset=us-ascii\n\nClearing the cookies helped, thank you! Still strange that it happened.\n\nMaria\n\nFrom buchhaltung@example.de Tue Dec  1 08:03:10 2026\nFrom: =?UTF-8?Q?J=C3=BCrgen_M=C3=BCller?= \u003cbuchhaltung@example.de\u003e\nTo: \"Example Ltd, Accounts\" \u003caccounts@example.org\u003e\nSubject: =?UTF-8?B?UmVjaG51bmcgTnIuIDIwMjYtMTE4IOKAkyBiaXR0ZSBwcsO8ZmVu?=\nDate: Tue, 1 Dec 2026 08:03:10 +0000\nMessage-ID: \u003cinv-118@example.de\u003e\nMIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"mix-1\"\n\n--mix-1\nContent-Type: multipart/alternative; boundary=\"alt-1\"\n\n--alt-1\nContent-Type: text/plain; charset=ISO-8859-1\nContent-Transfer-Encoding: quoted-printable\n\nGuten Tag,\n\nanbei die Rechnung f=FCr November. Zahlbar innerhalb von 14 Tagen.\n\nGr=FC=DFe\nJ=FCrgen M=FCller\n--alt-1\nContent-Type: text/html; charset=utf-8\n\n\u003chtml\u003e\u003cbody\u003e\u003cp\u003eGuten Tag,\u003c/p\u003e\u003cp\u003eanbei die Rechnung f\u0026uuml;r November.\u003c/p\u003e\u003cscript\u003ealert(1)\u003c/script\u003e\u003c/body\u003e\u003c/html\u003e\n--alt-1--\n\n--mix-1\nContent-Type: application/pdf; name=\"Rechnung-2026-118.pdf\"\nContent-Disposition: attachment; filename=\"Rechnung-2026-118.pdf\"\nContent-Transfer-Encoding: base64\n\nJVBERi0xLjQKJcfsj6IKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c+PgplbmRvYmoKdHJhaWxlcgo8\nPC9Sb290IDEgMCBSPj4KJSVFT0YK\n--mix-1--\n\nFrom priya@shop.example Tue Dec  1 08:35:00 2026\nFrom: Priya Natarajan \u003cpriya@shop.example\u003e\nTo: sales@example.org\nCc: Tom Becker \u003ctom@shop.example\u003e\nSubject: Quote for 40 seats?\nDate: Tue, 01 Dec 2026 14:05:00 +0530\nMessage-ID: \u003clead-40@shop.example\u003e\nContent-Type: text/plain; charset=utf-8\n\nHello,\n\nwe are a team of 40 and would like a quote for annual licences, ideally with\na training session in January. Can you send pricing by Friday?\n\n\u003eFrom the team side we are flexible.\n\nBest regards,\nPriya\n"
          },
          "file": {
            "title": "E-mail file (.eml or .mbox, optional)",
            "description": "Up to 10 MB. Used instead of the pasted text when given. Export single mails as .eml or a folder as .mbox from your mail program. Upload as {filename, contentType?, contentBase64}. Max 9766 KiB. Accepts .eml,.mbox,.mbx,.txt,message/rfc822,application/mbox,text/plain.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "rules": {
            "title": "Rules (JSON list)",
            "description": "Each rule: name, match (all | any), conditions [{ field, op, value }], actions { labels, assignee, status (open | waiting | done), dueInDays, stop }. Fields: from, to, subject, body, text, attachment, source. Comparisons: contains, not_contains, equals, starts_with, ends_with, domain_is, any_word, is_empty, has_attachment.",
            "type": "string",
            "maxLength": 60000,
            "default": "[\n {\n  \"name\": \"Invoices to accounts\",\n  \"match\": \"all\",\n  \"conditions\": [\n   {\n    \"field\": \"attachment\",\n    \"op\": \"ends_with\",\n    \"value\": \".pdf\"\n   },\n   {\n    \"field\": \"text\",\n    \"op\": \"any_word\",\n    \"value\": \"invoice, rechnung, receipt\"\n   }\n  ],\n  \"actions\": {\n   \"labels\": [\n    \"Billing\"\n   ],\n   \"assignee\": \"Accounts\",\n   \"dueInDays\": 14\n  }\n },\n {\n  \"name\": \"Login problems\",\n  \"conditions\": [\n   {\n    \"field\": \"text\",\n    \"op\": \"any_word\",\n    \"value\": \"log in, login, password\"\n   }\n  ],\n  \"actions\": {\n   \"labels\": [\n    \"Bug\"\n   ],\n   \"assignee\": \"Alex\",\n   \"dueInDays\": 1\n  }\n },\n {\n  \"name\": \"Quote requests\",\n  \"conditions\": [\n   {\n    \"field\": \"text\",\n    \"op\": \"any_word\",\n    \"value\": \"quote, pricing\"\n   }\n  ],\n  \"actions\": {\n   \"labels\": [\n    \"Lead\"\n   ],\n   \"status\": \"open\",\n   \"stop\": true\n  }\n },\n {\n  \"name\": \"Thank-you replies\",\n  \"conditions\": [\n   {\n    \"field\": \"subject\",\n    \"op\": \"starts_with\",\n    \"value\": \"re:\"\n   },\n   {\n    \"field\": \"body\",\n    \"op\": \"any_word\",\n    \"value\": \"thank you, thanks\"\n   }\n  ],\n  \"actions\": {\n   \"status\": \"done\"\n  }\n }\n]"
          },
          "today": {
            "title": "Today (YYYY-MM-DD, base for due dates of undated mail)",
            "type": "string",
            "maxLength": 10,
            "default": "2026-12-02"
          }
        },
        "required": []
      },
      "SortbayTriageRulesResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "required": [
              "messages",
              "rules",
              "unmatched"
            ],
            "properties": {
              "messages": {
                "type": "array"
              },
              "rules": {
                "type": "array"
              },
              "unmatched": {
                "type": "integer"
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "SortbayThreadGroupInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "source": {
            "title": "E-mail source (.eml text) or mbox",
            "description": "Paste the full source of a message (headers, a blank line, then the body) — in most mail programs “Show original” or “View source”. Several messages: paste an mbox (each starts with a “From ” line).",
            "type": "string",
            "maxLength": 2000000,
            "default": "From maria.lopez@example.com Mon Nov 30 09:12:44 2026\nFrom: \"Maria Lopez\" \u003cmaria.lopez@example.com\u003e\nTo: Support \u003csupport@example.org\u003e\nSubject: Can't log in after the update\nDate: Mon, 30 Nov 2026 09:12:44 +0100\nMessage-ID: \u003ca1-login@example.com\u003e\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: quoted-printable\n\nHi there,\n\nsince yesterday's update I can't log in any more. The page says =E2=80=9Cs=\nession expired=E2=80=9D right after I type my password.\n\nI'm on Firefox on Windows 11. Could you have a look?\n\nThanks,\nMaria\n\nFrom maria.lopez@example.com Mon Nov 30 11:40:02 2026\nFrom: Maria Lopez \u003cmaria.lopez@example.com\u003e\nTo: support@example.org\nSubject: Re: Can't log in after the update\nDate: Mon, 30 Nov 2026 11:40:02 +0100\nMessage-ID: \u003ca2-login@example.com\u003e\nIn-Reply-To: \u003ca1-login@example.com\u003e\nReferences: \u003ca1-login@example.com\u003e\nContent-Type: text/plain; charset=us-ascii\n\nClearing the cookies helped, thank you! Still strange that it happened.\n\nMaria\n\nFrom priya@shop.example Tue Dec  1 08:35:00 2026\nFrom: Priya Natarajan \u003cpriya@shop.example\u003e\nTo: sales@example.org\nCc: Tom Becker \u003ctom@shop.example\u003e\nSubject: Quote for 40 seats?\nDate: Tue, 01 Dec 2026 14:05:00 +0530\nMessage-ID: \u003clead-40@shop.example\u003e\nContent-Type: text/plain; charset=utf-8\n\nHello,\n\nwe are a team of 40 and would like a quote for annual licences, ideally with\na training session in January. Can you send pricing by Friday?\n\n\u003eFrom the team side we are flexible.\n\nBest regards,\nPriya\n"
          },
          "file": {
            "title": "E-mail file (.eml or .mbox, optional)",
            "description": "Up to 10 MB. Used instead of the pasted text when given. Export single mails as .eml or a folder as .mbox from your mail program. Upload as {filename, contentType?, contentBase64}. Max 9766 KiB. Accepts .eml,.mbox,.mbx,.txt,message/rfc822,application/mbox,text/plain.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          }
        },
        "required": []
      },
      "SortbayThreadGroupResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "required": [
              "threads",
              "messages"
            ],
            "properties": {
              "threads": {
                "type": "array"
              },
              "messages": {
                "type": "integer"
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}