{
  "openapi": "3.1.1",
  "info": {
    "title": "GitHub Webhook Signature Verifier API",
    "version": "1.0.0",
    "summary": "Check an X-Hub-Signature-256 header against the payload and the webhook secret.",
    "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://trackwellgithubwebhookverify.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Check an X-Hub-Signature-256 header against the payload and the webhook secret.",
        "description": "Computes the HMAC-SHA256 signature GitHub sends with every webhook delivery and compares it with the X-Hub-Signature-256 header you received, in constant time. Use it to debug a webhook receiver that rejects deliveries, or to create a valid signature for a test request. Same check as the Trackwell GitHub sync endpoint.\n\nMethodology:\n- GitHub signs the raw request body (exact bytes, UTF-8) with HMAC-SHA256 (RFC 2104) using the webhook secret as the key and sends “sha256=” plus 64 lower-case hex digits in the X-Hub-Signature-256 header.\n- The tool computes the same HMAC over the payload bytes (the uploaded file as is, or the pasted text encoded as UTF-8) and compares it with the header in constant time, so the comparison itself leaks no timing information.\n- Results: valid (identical), mismatch (wrong secret or changed body), malformed (not “sha256=” + 64 hex digits; the older SHA-1 header X-Hub-Signature is not accepted) or missing (no header given: only the expected signature is shown).\n- When the payload is JSON, the event hints (action, repository, issue number, sender) are read from it for orientation; they are not part of the check.\n- Trackwell’s GitHub sync uses this function for its webhook endpoint and additionally drops deliveries whose X-GitHub-Delivery id was already seen in the last 24 hours.\n\nThe secret is used only to compute this result and is not stored. Do not paste secrets of production systems into tools you do not trust; rotate a secret after debugging if in doubt.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "trackwell_github_webhook_verify",
        "x-owner-app": "trackwell",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TrackwellGithubWebhookVerifyInput"
              },
              "examples": {
                "example1": {
                  "summary": "GitHub’s documented test values (valid)",
                  "value": {
                    "secret": "It's a Secret to Everybody",
                    "payload": "Hello, World!",
                    "signature": "sha256=757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17"
                  }
                },
                "example2": {
                  "summary": "An issues delivery checked with the wrong signature",
                  "value": {
                    "secret": "trackwell-demo-secret",
                    "payload": "{\"action\":\"opened\",\"issue\":{\"number\":12,\"title\":\"Login button does nothing\"},\"repository\":{\"full_name\":\"octo-org/website\"},\"sender\":{\"login\":\"octocat\"}}",
                    "signature": "sha256=0e0b4ee30dd0bb2c3d38d6a1e1d5dfe0b1e74acbe90b37d6a7a2b4a1c3c6dd4f"
                  }
                },
                "example3": {
                  "summary": "Only compute the signature for a test request",
                  "value": {
                    "secret": "trackwell-demo-secret",
                    "payload": "{\"action\":\"opened\",\"issue\":{\"number\":12,\"title\":\"Login button does nothing\"},\"repository\":{\"full_name\":\"octo-org/website\"},\"sender\":{\"login\":\"octocat\"}}",
                    "signature": ""
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrackwellGithubWebhookVerifyResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "TrackwellGithubWebhookVerifyInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "secret": {
            "title": "Webhook secret",
            "description": "The secret entered in the repository’s webhook settings on GitHub.",
            "type": "string",
            "maxLength": 500,
            "default": "It's a Secret to Everybody"
          },
          "payload": {
            "title": "Payload (raw request body)",
            "description": "The exact body GitHub sent. Copying from a log can change line endings or spaces — then the signature cannot match. Use the file field for exact bytes.",
            "type": "string",
            "maxLength": 1000000,
            "default": "Hello, World!"
          },
          "payloadFile": {
            "title": "Payload file (optional, exact bytes)",
            "description": "Used instead of the pasted text when given. Upload as {filename, contentType?, contentBase64}. Max 977 KiB. Accepts .json,.txt,application/json,text/plain.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "signature": {
            "title": "X-Hub-Signature-256 header (optional)",
            "description": "Leave empty to only compute the signature for this payload and secret.",
            "type": "string",
            "maxLength": 200,
            "default": "sha256=757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17"
          }
        },
        "required": []
      },
      "TrackwellGithubWebhookVerifyResult": {
        "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": [
              "expected",
              "payloadBytes"
            ],
            "properties": {
              "valid": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "reason": {
                "type": "string"
              },
              "expected": {
                "type": "string"
              },
              "given": {
                "type": "string"
              },
              "payloadBytes": {
                "type": "integer"
              },
              "payloadSha256": {
                "type": "string"
              },
              "delivery": {
                "type": [
                  "object",
                  "null"
                ]
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}