{
  "openapi": "3.1.1",
  "info": {
    "title": "Parley Message Check API",
    "version": "1.0.0",
    "summary": "See how a chat message renders: formatting, safe links, @mentions and what gets notified.",
    "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://parleymessagecheck.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "See how a chat message renders: formatting, safe links, @mentions and what gets notified.",
        "description": "Checks a chat message the way Parley does before sending it: the Markdown subset (bold, italic, code, links, lists, quotes, code blocks), which links are kept (only http(s) and mailto), which @mentions match a member list, whether @channel or @here notifies everybody, and the length limit. Shows the safe HTML and the plain text a notification would use.\n\nMethodology:\n- @Name mentions are matched against the member names (longest name first, case-insensitive, must end at a word boundary); a matched name becomes a \u003c@id\u003e token. In this tool the id is “member-\u003cline number\u003e”.\n- The body is split into blocks with the platform’s shared Markdown parser (Deckwright); single line breaks are kept like in a chat. Headings become bold lines, tables and code blocks stay code, images become links.\n- Only http(s) and mailto links become links; other link targets (javascript:, data:, relative) stay visible text. Raw HTML is escaped, never interpreted.\n- Mentions inside code are not notifications. @channel and @here notify every member of the conversation.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "parley_message_check",
        "x-owner-app": "parley",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ParleyMessageCheckInput"
              },
              "examples": {
                "example1": {
                  "summary": "Mentions, list and a link",
                  "value": {
                    "body": "Hi @Ana, the **release notes** are ready: https://example.com/notes\n- check the `v2` links\n- tell @channel when done",
                    "members": "Ana\nBen Okafor\nCleo"
                  }
                },
                "example2": {
                  "summary": "Unsafe link and raw HTML stay text",
                  "value": {
                    "body": "Click [here](javascript:alert(1)) \u003cimg src=x onerror=alert(1)\u003e",
                    "members": ""
                  }
                },
                "example3": {
                  "summary": "Code block keeps mentions literal",
                  "value": {
                    "body": "```\n@Ben is not notified here\n```\nbut @Ben Okafor is",
                    "members": "Ben Okafor"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ParleyMessageCheckResult"
                }
              }
            }
          },
          "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/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "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"
                }
              }
            }
          }
        }
      },
      "ParleyMessageCheckInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "body": {
            "title": "Message",
            "description": "Up to 4000 characters. Mentions: @Name of a member (list below), @channel or @here.",
            "type": "string",
            "maxLength": 20000,
            "default": "Hi @Ana, the **release notes** are ready: https://example.com/notes\n- check the `v2` links\n- tell @channel when done"
          },
          "members": {
            "title": "Members (one name per line, optional)",
            "description": "Used to resolve @Name mentions like Parley does with the workspace members.",
            "type": "string",
            "maxLength": 5000,
            "default": "Ana\nBen Okafor\nCleo"
          }
        },
        "required": []
      },
      "ParleyMessageCheckResult": {
        "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": [
              "blocks",
              "mentions",
              "broadcast",
              "links",
              "text",
              "warnings",
              "characters",
              "limit",
              "html"
            ],
            "properties": {
              "blocks": {
                "type": "array"
              },
              "mentions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "broadcast": {
                "enum": [
                  "channel",
                  "here",
                  null
                ]
              },
              "links": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "text": {
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "characters": {
                "type": "integer"
              },
              "limit": {
                "type": "integer"
              },
              "html": {
                "type": "string"
              },
              "markdown": {
                "type": "string"
              },
              "resolved": {
                "type": "string",
                "description": "The body with @Name mentions replaced by \u003c@id\u003e tokens, as Parley stores it."
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}