{
  "openapi": "3.1.0",
  "info": {
    "title": "TagManifest API",
    "version": "1.0.0",
    "description": "Audit Google Tag Manager containers against 92 rules covering consent, GA4 configuration, PII exposure, ads, ecommerce, performance, security, and container hygiene. Returns structured findings, health scores, and recommendations.\n\n## Authentication\n\nSend a bearer token in the `Authorization` header. Three kinds of token exist:\n\n- **API key** — prefixed `tm_`, created on the account page at https://developer.tagmanifest.com/account/. Use it for REST calls and for MCP clients that take a header.\n- **MCP access token** — a short-lived JWT issued by TagManifest's own OAuth server to MCP clients and refreshed at `/oauth/token`. It also works on the scan and rule endpoints, within the scopes the user granted (`mcp:read`, `mcp:tools`). See https://developer.tagmanifest.com/mcp/oauth/.\n- **Account session token** — the session JWT the account page holds after sign-in. It is the only token the `/api-keys` endpoints accept. An API key, or a valid MCP access token, gets a 403 there.\n\n## Request checking\n\nThe scan and rule-list endpoints check requests strictly. An unknown body field on `/scan-url`, `/scan` or `/evaluate-rule`, or an unknown query parameter on `/rules`, returns 400. The message suggests an accepted name when one is close. `/rules-detail` ignores extra query parameters and `POST /api-keys` ignores extra body fields. An unknown `category`, `tier` or `status` value returns 400 and lists the accepted values. Counts (`top_n`, `limit`) must be 0 or more; a number or numeric text is accepted and a fraction is rounded down. `include_evidence` must be `true` or `false` (the text forms are accepted). A `null` value for an optional body field is treated as left out.\n\n## Rate limits\n\nLimits are per user, per tool, per day (reset at 00:00 UTC). REST responses to requests that were counted carry `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset`. The headers are absent on 401, 403, 405 and 503 responses, on a 413 for a declared oversize body, and on every `/api-keys` response.\n\n| Endpoint | Daily limit |\n|---|---|\n| `/scan-url` | 100 |\n| `/scan` | 200 |\n| `/evaluate-rule` | 500 |\n| `/rules` | 1 000 |\n| `/rules-detail` | 1 000 |\n\n## MCP endpoint\n\n`POST https://developer.tagmanifest.com/mcp` implements the MCP Streamable HTTP JSON-RPC 2.0 protocol for AI agent integrations. It is not a REST endpoint and is not documented here as a path. Tools available over MCP: `scan_url`, `scan_container`, `evaluate_rule`, `list_rules`, `get_rule`, `get_health_score`, `compare_containers`, `account_status`. MCP responses carry no rate-limit headers; a tool call over its limit returns a JSON-RPC error with code `-32603`.",
    "contact": {
      "name": "TagManifest",
      "url": "https://tagmanifest.com"
    },
    "license": {
      "name": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://developer.tagmanifest.com/v1",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Scans",
      "description": "Run the full rule engine against a GTM container. Returns findings, health score, and a summary breakdown by category and tier."
    },
    {
      "name": "Rules",
      "description": "Browse the rule catalog. List rules with optional filters, or fetch full metadata for a single rule."
    },
    {
      "name": "Keys",
      "description": "Create, list, and revoke API keys. Takes the account page's session token only. API keys and MCP access tokens cannot manage API keys."
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token. Three kinds are accepted: a TagManifest API key prefixed `tm_`; an MCP access token (a JWT issued by TagManifest's OAuth server and refreshed at `/oauth/token`); and the account page's session JWT, which is the only kind the `/api-keys` endpoints accept. Example: `Authorization: Bearer tm_a1b2c3d4...`"
      }
    },
    "schemas": {
      "ContainerData": {
        "type": "object",
        "description": "A GTM container, in one of two forms. (1) A GTM JSON export, sent exactly as downloaded from GTM (Admin → Export container). It is recognised by its `containerVersion` key and parsed by the API. `containerVersion.container` must carry a `publicId` or, in its place, a `containerId`. `container.gtm_id` in the response is read from `publicId`; an export with only a `containerId` is audited and reports the text `Unknown` there. `tag`, `trigger`, `variable` and `folder`, when present, must be arrays of objects. (2) A container already parsed by TagManifest: an object with `tags`, `triggers` and `variables` arrays of objects, where every tag has a string `type` and a `firingTriggerIds` array, and every trigger and variable has a string `type` and a `referencedByTags` array. Anything else is refused with 400.",
        "properties": {
          "containerVersion": {
            "type": "object",
            "description": "Export form only. The `containerVersion` object of a GTM JSON export.",
            "properties": {
              "container": {
                "type": "object",
                "description": "The container record. Must carry a `publicId` or a `containerId`, as a non-empty string.",
                "properties": {
                  "publicId": {
                    "type": "string",
                    "example": "GTM-ABC123"
                  },
                  "containerId": {
                    "type": "string",
                    "description": "Accepted in place of `publicId`. The response then reports `Unknown` as `container.gtm_id`."
                  },
                  "name": {
                    "type": "string",
                    "example": "Example Site"
                  }
                },
                "anyOf": [
                  {
                    "required": [
                      "publicId"
                    ]
                  },
                  {
                    "required": [
                      "containerId"
                    ]
                  }
                ]
              },
              "tag": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "trigger": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "variable": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "folder": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            },
            "required": [
              "container"
            ]
          },
          "meta": {
            "type": "object",
            "description": "Parsed form only. Container-level metadata. Optional.",
            "properties": {
              "publicId": {
                "type": "string",
                "description": "The GTM container ID. Returned as `container.gtm_id`.",
                "example": "GTM-ABC123"
              },
              "containerName": {
                "type": "string",
                "description": "The container name. Returned as `container.name`.",
                "example": "Example Site"
              }
            }
          },
          "tags": {
            "type": "array",
            "description": "Parsed form only. Tag objects. Each needs a string `type` and a `firingTriggerIds` array.",
            "items": {
              "type": "object",
              "required": [
                "type",
                "firingTriggerIds"
              ],
              "properties": {
                "type": {
                  "type": "string"
                },
                "firingTriggerIds": {
                  "type": "array"
                }
              }
            }
          },
          "triggers": {
            "type": "array",
            "description": "Parsed form only. Trigger objects. Each needs a string `type` and a `referencedByTags` array.",
            "items": {
              "type": "object",
              "required": [
                "type",
                "referencedByTags"
              ],
              "properties": {
                "type": {
                  "type": "string"
                },
                "referencedByTags": {
                  "type": "array"
                }
              }
            }
          },
          "variables": {
            "type": "array",
            "description": "Parsed form only. Variable objects. Each needs a string `type` and a `referencedByTags` array.",
            "items": {
              "type": "object",
              "required": [
                "type",
                "referencedByTags"
              ],
              "properties": {
                "type": {
                  "type": "string"
                },
                "referencedByTags": {
                  "type": "array"
                }
              }
            }
          }
        },
        "anyOf": [
          {
            "title": "GTM JSON export",
            "required": [
              "containerVersion"
            ]
          },
          {
            "title": "Parsed container",
            "required": [
              "tags",
              "triggers",
              "variables"
            ]
          }
        ],
        "examples": [
          {
            "exportFormatVersion": 2,
            "containerVersion": {
              "container": {
                "publicId": "GTM-ABC123",
                "name": "Example Site"
              },
              "tag": [],
              "trigger": [],
              "variable": []
            }
          },
          {
            "meta": {
              "publicId": "GTM-ABC123",
              "containerName": "Example Site"
            },
            "tags": [],
            "triggers": [],
            "variables": []
          }
        ]
      },
      "ThinFinding": {
        "type": "object",
        "description": "A compact finding returned by default from the scan endpoints.",
        "required": [
          "rule_id",
          "title",
          "severity",
          "tier",
          "category"
        ],
        "properties": {
          "rule_id": {
            "type": "string",
            "description": "Stable identifier for the rule that generated this finding. Use with `/rules-detail` to fetch full rule metadata.",
            "example": "ga4-event-name-invalid-chars"
          },
          "title": {
            "type": "string",
            "description": "Short label for the finding. Written by the rule for this container; it can differ from the rule's catalog title.",
            "example": "GA4 event names with invalid characters"
          },
          "severity": {
            "type": "string",
            "enum": [
              "critical",
              "high",
              "medium",
              "low"
            ],
            "description": "Severity of this finding on this container. It can differ from the rule's catalog severity."
          },
          "tier": {
            "type": "string",
            "enum": [
              "error",
              "warning",
              "optimization",
              "info"
            ],
            "description": "Urgency tier used for scoring and prioritization. `error` findings carry the largest health-score deduction (8 pts each, capped at 35)."
          },
          "category": {
            "type": "string",
            "enum": [
              "consent",
              "ga4",
              "ads",
              "ecommerce",
              "security",
              "pii",
              "performance",
              "quality",
              "organization",
              "dead-code"
            ],
            "description": "Rule category grouping. Matches the `category` filter parameter on scan endpoints."
          },
          "finding_count": {
            "type": "integer",
            "description": "Always 1.",
            "example": 1
          },
          "affected_items": {
            "type": "array",
            "description": "Up to 3 of the affected items the rule reports (tags, triggers, or variables). Each is an object with `id` and `name`; some rules add fields such as `eventName`.",
            "items": {
              "type": "object"
            },
            "maxItems": 3,
            "example": [
              {
                "id": "14",
                "name": "GA4 - Form Submit",
                "eventName": "form-submit"
              }
            ]
          },
          "affected_items_total": {
            "type": "integer",
            "description": "Count of the affected items the rule reports, including those not shown in `affected_items`. Some rules list only the first 10 or 20, so this can be lower than the number of matching items in the container.",
            "example": 1
          },
          "action": {
            "type": "string",
            "description": "Short phrase naming the recommended action.",
            "example": "Fix event name characters"
          },
          "recommendation": {
            "type": "string",
            "description": "Full prose recommendation explaining how to resolve the finding.",
            "example": "Rename events to use only letters, numbers, and underscores. Replace hyphens and spaces with underscores."
          }
        }
      },
      "Finding": {
        "type": "object",
        "description": "A full finding with evidence. Returned by the scan endpoints when `include_evidence` is true. Compared with ThinFinding it adds `description` and `evidence`, lists the affected items the rule reports (some rules list only the first 10 or 20), and has no `finding_count` or `affected_items_total`. Rule-specific extra fields, such as `subType`, are not returned here.",
        "required": [
          "rule_id",
          "title",
          "severity",
          "tier",
          "category"
        ],
        "properties": {
          "rule_id": {
            "type": "string",
            "description": "Stable rule identifier.",
            "example": "ga4-event-name-invalid-chars"
          },
          "title": {
            "type": "string",
            "description": "Short human-readable label.",
            "example": "GA4 event names with invalid characters"
          },
          "description": {
            "type": "string",
            "description": "Detailed explanation of why this pattern is a problem."
          },
          "severity": {
            "type": "string",
            "enum": [
              "critical",
              "high",
              "medium",
              "low"
            ]
          },
          "tier": {
            "type": "string",
            "enum": [
              "error",
              "warning",
              "optimization",
              "info"
            ]
          },
          "category": {
            "type": "string",
            "enum": [
              "consent",
              "ga4",
              "ads",
              "ecommerce",
              "security",
              "pii",
              "performance",
              "quality",
              "organization",
              "dead-code"
            ]
          },
          "affected_items": {
            "type": "array",
            "description": "The affected items the rule reports, not cut to 3. Some rules list only the first 10 or 20. Each is an object with `id` and `name`; some rules add fields.",
            "items": {
              "type": "object"
            }
          },
          "evidence": {
            "type": "array",
            "description": "Evidence objects taken from the container. Their fields depend on the rule.",
            "items": {
              "type": "object"
            }
          },
          "recommendation": {
            "type": "string"
          },
          "action": {
            "type": "string"
          }
        }
      },
      "HealthScore": {
        "type": "object",
        "description": "Composite health score computed from functional-dimension findings only. Errors deduct 8 pts each (capped at 35), warnings 4 pts each (capped at 20), optimizations use a logarithmic scale (capped at 25). Score starts at 100.",
        "required": [
          "score",
          "grade",
          "label",
          "deductions",
          "caps",
          "functionalIssueCount"
        ],
        "properties": {
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Numeric health score from 0–100. Higher is better.",
            "example": 71
          },
          "grade": {
            "type": "string",
            "enum": [
              "A",
              "B",
              "C",
              "D",
              "F"
            ],
            "description": "Letter grade. A = 90–100, B = 75–89, C = 60–74, D = 45–59, F = 0–44.",
            "example": "C"
          },
          "label": {
            "type": "string",
            "description": "Human-readable label corresponding to the grade. One of: Well-Configured, Healthy, Needs Attention, Patterns Found, Areas to Review.",
            "example": "Needs Attention"
          },
          "deductions": {
            "type": "object",
            "description": "Breakdown of how many points were deducted and from which sources.",
            "required": [
              "error",
              "warning",
              "optimization",
              "info",
              "byCategory"
            ],
            "properties": {
              "error": {
                "type": "integer",
                "description": "Points deducted from error-tier findings. Maximum 35.",
                "example": 16
              },
              "warning": {
                "type": "integer",
                "description": "Points deducted from warning-tier findings. Maximum 20.",
                "example": 8
              },
              "optimization": {
                "type": "integer",
                "description": "Points deducted from optimization-tier findings via logarithmic scale. Maximum 25.",
                "example": 5
              },
              "info": {
                "type": "integer",
                "description": "Points deducted from info-tier findings. Always 0 in the current model.",
                "example": 0
              },
              "byCategory": {
                "type": "object",
                "description": "Number of functional findings per category. These are counts of findings, not points.",
                "additionalProperties": {
                  "type": "integer"
                },
                "example": {
                  "consent": 2,
                  "ga4": 2,
                  "pii": 1
                }
              }
            }
          },
          "caps": {
            "type": "object",
            "description": "The maximum point deductions per tier. Informational — useful for displaying score ceilings.",
            "required": [
              "error",
              "warning",
              "optimization",
              "info"
            ],
            "properties": {
              "error": {
                "type": "integer",
                "example": 35
              },
              "warning": {
                "type": "integer",
                "example": 20
              },
              "optimization": {
                "type": "integer",
                "example": 25
              },
              "info": {
                "type": "integer",
                "example": 0
              }
            }
          },
          "functionalIssueCount": {
            "type": "integer",
            "description": "Number of findings in the 'functional' scoring dimension that were counted. Hygiene-only rules (naming, folder structure, etc.) are excluded from scoring.",
            "example": 5
          }
        }
      },
      "ScanResponse": {
        "type": "object",
        "description": "Response object returned by `/scan`. `/scan-url` returns the same fields plus `site`; see ScanUrlResponse.",
        "required": [
          "scanned_at",
          "duration_ms",
          "container",
          "findings",
          "findings_total",
          "findings_truncated",
          "by_category",
          "by_tier",
          "health_score"
        ],
        "properties": {
          "scanned_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of when the scan was initiated.",
            "example": "2026-05-01T14:23:00.000Z"
          },
          "duration_ms": {
            "type": "integer",
            "description": "Wall-clock time in milliseconds from scan start to response serialization.",
            "example": 412
          },
          "container": {
            "type": "object",
            "description": "Counts and metadata from the resolved container.",
            "required": [
              "tag_count",
              "trigger_count",
              "variable_count",
              "gtm_id",
              "name"
            ],
            "properties": {
              "tag_count": {
                "type": "integer",
                "description": "Total number of tags in the container.",
                "example": 34
              },
              "trigger_count": {
                "type": "integer",
                "description": "Total number of triggers in the container.",
                "example": 18
              },
              "variable_count": {
                "type": "integer",
                "description": "Total number of variables in the container.",
                "example": 22
              },
              "gtm_id": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The GTM container ID. On `/scan`, null when a parsed container carries no `meta.publicId`, and the text `Unknown` when an export carries no `publicId`.",
                "example": "GTM-ABC123"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Container name from GTM metadata, or null if not available.",
                "example": "My Website"
              }
            }
          },
          "findings": {
            "type": "array",
            "description": "Ordered list of findings, sorted by tier (error → warning → optimization → info) then severity (critical → high → medium → low). Contains ThinFinding objects by default, or full Finding objects when `include_evidence` is true.",
            "items": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/ThinFinding"
                },
                {
                  "$ref": "#/components/schemas/Finding"
                }
              ]
            }
          },
          "findings_total": {
            "type": "integer",
            "description": "Total count of findings that matched the applied filters, before the `top_n` truncation.",
            "example": 18
          },
          "findings_truncated": {
            "type": "boolean",
            "description": "True when `top_n` cut the list short.",
            "example": false
          },
          "by_category": {
            "type": "object",
            "description": "Count of all findings (across all tiers) grouped by category, before any filters are applied.",
            "additionalProperties": {
              "type": "integer"
            },
            "example": {
              "consent": 4,
              "ga4": 6,
              "pii": 1,
              "organization": 3
            }
          },
          "by_tier": {
            "type": "object",
            "description": "Count of all findings grouped by tier, before any filters are applied.",
            "additionalProperties": {
              "type": "integer"
            },
            "example": {
              "error": 2,
              "warning": 3,
              "optimization": 10,
              "info": 3
            }
          },
          "health_score": {
            "$ref": "#/components/schemas/HealthScore"
          }
        }
      },
      "ScanUrlResponse": {
        "description": "Response object returned by `/scan-url`: every ScanResponse field plus `site`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ScanResponse"
          },
          {
            "type": "object",
            "required": [
              "site"
            ],
            "properties": {
              "site": {
                "type": "object",
                "description": "The page and container that were scanned.",
                "required": [
                  "url",
                  "gtm_id",
                  "from_cache"
                ],
                "properties": {
                  "url": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The URL passed in the request, or null if a gtm_id was passed directly.",
                    "example": "https://example.com"
                  },
                  "gtm_id": {
                    "type": "string",
                    "description": "The GTM container ID that was scanned.",
                    "example": "GTM-ABC123"
                  },
                  "from_cache": {
                    "type": "boolean",
                    "description": "True when the parsed container came from the cache (entries are reused for up to five minutes), false when it was fetched from Google for this request."
                  }
                }
              }
            }
          }
        ]
      },
      "EvaluateRuleResponse": {
        "type": "object",
        "description": "Result of running a single rule against a container.",
        "required": [
          "rule_id",
          "evaluated_at",
          "duration_ms",
          "fired",
          "finding_count",
          "findings",
          "container"
        ],
        "properties": {
          "rule_id": {
            "type": "string",
            "description": "The rule ID that was evaluated.",
            "example": "ga4-event-name-invalid-chars"
          },
          "evaluated_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of when the evaluation ran.",
            "example": "2026-05-01T14:23:01.000Z"
          },
          "duration_ms": {
            "type": "integer",
            "description": "Time in milliseconds to resolve the container and run the rule.",
            "example": 210
          },
          "fired": {
            "type": "boolean",
            "description": "True when the rule found at least one issue. False means the container passes this check.",
            "example": true
          },
          "finding_count": {
            "type": "integer",
            "description": "Number of findings the rule returned. A rule can return more than one.",
            "example": 1
          },
          "findings": {
            "type": "array",
            "description": "Findings in the rule engine's own form (see RuleFinding), always with evidence. Empty when `fired` is false.",
            "items": {
              "$ref": "#/components/schemas/RuleFinding"
            }
          },
          "container": {
            "type": [
              "object",
              "null"
            ],
            "description": "Container metadata for the resolved container.",
            "required": [
              "gtm_id",
              "tag_count",
              "from_cache"
            ],
            "properties": {
              "gtm_id": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The container ID. For a container sent in `data` it is read from the container; if the container carries none, a `gtm_id` sent in the same request is used, and with neither it is null.",
                "example": "GTM-ABC123"
              },
              "tag_count": {
                "type": "integer",
                "example": 34
              },
              "from_cache": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True or false when the container was fetched; null when it was sent in `data`."
              }
            }
          }
        }
      },
      "Rule": {
        "type": "object",
        "description": "A rule from the TagManifest rule catalog. Rules are the unit of audit logic — each rule checks for one specific anti-pattern.",
        "required": [
          "rule_id",
          "title",
          "category",
          "tier",
          "severity",
          "status"
        ],
        "properties": {
          "rule_id": {
            "type": "string",
            "description": "Stable kebab-case identifier. Used to reference the rule in scan results and in the `evaluate-rule` endpoint.",
            "example": "ga4-pii-parameter-names"
          },
          "title": {
            "type": "string",
            "description": "Short human-readable rule title.",
            "example": "Parameters with PII-suggesting names"
          },
          "description": {
            "type": "string",
            "description": "Full explanation of what the rule detects and why it matters."
          },
          "recommendation": {
            "type": "string",
            "description": "Prose guidance on how to resolve findings from this rule."
          },
          "category": {
            "type": "string",
            "enum": [
              "consent",
              "ga4",
              "ads",
              "ecommerce",
              "security",
              "pii",
              "performance",
              "quality",
              "organization",
              "dead-code"
            ],
            "description": "Rule category. Used for filtering and grouping."
          },
          "tier": {
            "type": "string",
            "enum": [
              "error",
              "warning",
              "optimization",
              "info"
            ],
            "description": "Default urgency tier assigned to findings from this rule."
          },
          "severity": {
            "type": "string",
            "enum": [
              "critical",
              "high",
              "medium",
              "low"
            ],
            "description": "The rule's catalog severity. A finding carries the severity that applies to the scanned container, which can differ."
          },
          "status": {
            "type": "string",
            "enum": [
              "not_started",
              "in_progress",
              "validated",
              "shipped",
              "retired",
              "deferred"
            ],
            "description": "`shipped` rules are the ones that produce findings. The catalog today holds only `shipped` rules and two `deferred` rules. The deferred rules are listed in the catalog and produce no findings today."
          },
          "version": {
            "type": "integer",
            "description": "Rule definition version.",
            "example": 1
          },
          "effort_estimate": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "15min",
              "2hr",
              "2wk",
              "strategic",
              null
            ],
            "description": "Rough effort to fix."
          },
          "reversibility": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "destructive",
              "non-destructive",
              null
            ],
            "description": "Whether the recommended change can be undone. Every rule in the catalog today is `non-destructive`."
          },
          "regulatory_cites": {
            "type": "array",
            "description": "Regulatory references, e.g. `GDPR Art. 7 (consent)`. Empty when none.",
            "items": {
              "type": "string"
            }
          },
          "learn_more_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "External reference URL. Null for every rule in the catalog today."
          },
          "layer_requirements": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "container",
              "container+page",
              "container+page+runtime",
              "container+api",
              null
            ],
            "description": "What the rule needs to run. Every shipped rule has `container`."
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "description": "Metadata for a TagManifest API key. The full plaintext key value is only returned once at creation time.",
        "required": [
          "id",
          "key_prefix",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "UUID of the key record. Use this ID to revoke the key.",
            "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
          },
          "key_prefix": {
            "type": "string",
            "description": "First 11 characters of the key (`tm_` plus 8 hex characters), used to identify it in a list.",
            "example": "tm_a1b2c3d4"
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional human-readable label assigned at creation.",
            "example": "Production server"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of when the key was created."
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "ISO 8601 timestamp of the last time this key was used to make an authenticated request."
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "ISO 8601 timestamp when the key was revoked, or null if still active."
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Error response body. Most errors carry only `error`, a sentence saying what went wrong. Four use a short code in `error` and a sentence in `message`: `rate_limit_exceeded`, `insufficient_scope`, `payload_too_large`, `rate_limiter_unavailable`.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "A message, or one of the four short codes.",
            "example": "Missing required field: rule_id"
          },
          "message": {
            "type": "string",
            "description": "Present with the four short codes."
          },
          "tool": {
            "type": "string",
            "description": "429 only. The rate-limit bucket."
          },
          "limit": {
            "type": "integer",
            "description": "429 only. The daily limit."
          },
          "count": {
            "type": "integer",
            "description": "429 only. The count when the request was refused."
          },
          "reset_at": {
            "type": "string",
            "format": "date-time",
            "description": "429 only. When the bucket resets."
          }
        },
        "example": {
          "error": "Provide either url or gtm_id"
        }
      },
      "RuleFinding": {
        "type": "object",
        "description": "A finding as returned by `/evaluate-rule`. It is the rule engine's own form: field names are camelCase (`ruleId`, `affectedItems`), unlike the scan endpoints. Some rules add extra fields, such as `subType` on `consent-no-cmp`.",
        "required": [
          "ruleId",
          "severity",
          "category",
          "title",
          "tier"
        ],
        "additionalProperties": true,
        "properties": {
          "ruleId": {
            "type": "string",
            "example": "ga4-event-name-invalid-chars"
          },
          "severity": {
            "type": "string",
            "enum": [
              "critical",
              "high",
              "medium",
              "low"
            ]
          },
          "category": {
            "type": "string",
            "enum": [
              "consent",
              "ga4",
              "ads",
              "ecommerce",
              "security",
              "pii",
              "performance",
              "quality",
              "organization",
              "dead-code"
            ]
          },
          "title": {
            "type": "string",
            "example": "GA4 event names with invalid characters"
          },
          "description": {
            "type": "string"
          },
          "affectedItems": {
            "type": "array",
            "description": "The affected items the rule reports. Some rules list only the first 10 or 20. Each is an object with `id` and `name`; some rules add fields.",
            "items": {
              "type": "object"
            }
          },
          "evidence": {
            "type": "array",
            "description": "Evidence objects. Their fields depend on the rule.",
            "items": {
              "type": "object"
            }
          },
          "recommendation": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "tier": {
            "type": "string",
            "enum": [
              "error",
              "warning",
              "optimization",
              "info"
            ]
          }
        }
      }
    },
    "responses": {
      "MethodNotAllowed": {
        "description": "Wrong HTTP method for this path. The scan and rule endpoints answer before the token is checked, and the message names the method to use. `/api-keys` checks the session token first, so a request without a valid one gets 401 or 403 instead. `OPTIONS` is answered with 200 on every path. Not counted against the rate limit; no rate-limit headers.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "scan_and_rule_endpoints": {
                "summary": "Scan and rule endpoints",
                "value": {
                  "error": "Method not allowed. Use POST."
                }
              },
              "api_keys": {
                "summary": "/api-keys, with a valid session token",
                "value": {
                  "error": "Method not allowed"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/scan": {
      "post": {
        "operationId": "scanContainer",
        "summary": "Scan a container sent in the request",
        "description": "Run every rule against a GTM container sent in `data`: either the GTM JSON export as downloaded, or a container already parsed by TagManifest. Nothing is fetched. Returns findings, health score, and category/tier counts. Use `/scan-url` to scan by URL or GTM ID.\n\nRequires the `mcp:tools` scope when called with an MCP access token.\n\n**Rate limit:** 200 requests/day.",
        "tags": [
          "Scans"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "data"
                ],
                "properties": {
                  "data": {
                    "$ref": "#/components/schemas/ContainerData"
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "consent",
                      "ga4",
                      "ads",
                      "ecommerce",
                      "security",
                      "pii",
                      "performance",
                      "quality",
                      "organization",
                      "dead-code"
                    ],
                    "description": "Optional filter: only return findings in this category. Any other value, including an empty string, returns 400."
                  },
                  "tier": {
                    "type": "string",
                    "enum": [
                      "error",
                      "warning",
                      "optimization",
                      "info"
                    ],
                    "description": "Optional filter: only return findings at this tier. Any other value, including an empty string, returns 400."
                  },
                  "top_n": {
                    "oneOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "string",
                        "pattern": "^\\s*\\d+(\\.\\d+)?\\s*$"
                      }
                    ],
                    "description": "Optional maximum number of findings to return, most important first (tier, then severity). 0 returns no findings. When omitted or null, all matching findings are returned. Accepts a number of 0 or more, or numeric text such as \"10\". A fraction is rounded down.",
                    "example": 10
                  },
                  "include_evidence": {
                    "oneOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "string",
                        "enum": [
                          "true",
                          "false"
                        ]
                      }
                    ],
                    "default": false,
                    "description": "When true, each finding includes `description` and `evidence`, and `affected_items` holds the affected items the rule reports (some rules list only the first 10 or 20) instead of the first 3. Accepts true or false, or the text \"true\" or \"false\". Null is treated as omitted. Defaults to false."
                  }
                },
                "additionalProperties": false,
                "description": "Fields other than these are refused with 400."
              },
              "examples": {
                "export": {
                  "summary": "A GTM JSON export, as downloaded",
                  "value": {
                    "data": {
                      "exportFormatVersion": 2,
                      "containerVersion": {
                        "container": {
                          "publicId": "GTM-ABC123",
                          "name": "Example Site"
                        },
                        "tag": [],
                        "trigger": [],
                        "variable": []
                      }
                    }
                  }
                },
                "parsed": {
                  "summary": "An already parsed container",
                  "value": {
                    "data": {
                      "meta": {
                        "publicId": "GTM-ABC123",
                        "containerName": "Example Site"
                      },
                      "tags": [],
                      "triggers": [],
                      "variables": []
                    }
                  }
                },
                "filtered": {
                  "summary": "Consent warnings only, with evidence",
                  "value": {
                    "data": {
                      "exportFormatVersion": 2,
                      "containerVersion": {
                        "container": {
                          "publicId": "GTM-ABC123",
                          "name": "Example Site"
                        },
                        "tag": [],
                        "trigger": [],
                        "variable": []
                      }
                    },
                    "category": "consent",
                    "tier": "warning",
                    "top_n": 5,
                    "include_evidence": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scan complete. Returns findings and health score.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanResponse"
                },
                "example": {
                  "scanned_at": "2026-05-01T14:23:00.000Z",
                  "duration_ms": 38,
                  "container": {
                    "tag_count": 34,
                    "trigger_count": 18,
                    "variable_count": 22,
                    "gtm_id": "GTM-ABC123",
                    "name": "Example Site"
                  },
                  "findings": [
                    {
                      "rule_id": "ga4-event-name-invalid-chars",
                      "title": "GA4 event names with invalid characters",
                      "severity": "high",
                      "tier": "warning",
                      "category": "ga4",
                      "finding_count": 1,
                      "affected_items": [
                        {
                          "id": "14",
                          "name": "GA4 - Form Submit",
                          "eventName": "form-submit"
                        }
                      ],
                      "affected_items_total": 1,
                      "action": "Fix event name characters",
                      "recommendation": "Rename events to use only letters, numbers, and underscores. Replace hyphens and spaces with underscores."
                    },
                    {
                      "rule_id": "consent-no-cmp",
                      "title": "No Consent Management Platform (CMP) detected",
                      "severity": "medium",
                      "tier": "warning",
                      "category": "consent",
                      "finding_count": 1,
                      "affected_items": [
                        {
                          "id": "21",
                          "name": "Google Ads - Conversion"
                        },
                        {
                          "id": "22",
                          "name": "Google Ads - Remarketing"
                        }
                      ],
                      "affected_items_total": 2,
                      "action": "Deploy a CMP",
                      "recommendation": "Verify whether consent management is deployed outside GTM (check for CMP scripts in your page source). If consent is managed externally, no action needed in GTM. If no CMP exists and your site serves visitors in regions requiring consent, consider deploying one."
                    },
                    {
                      "rule_id": "ga4-debug-mode-hardcoded",
                      "title": "GA4 debug_mode hardcoded to \"true\"",
                      "severity": "high",
                      "tier": "optimization",
                      "category": "ga4",
                      "finding_count": 1,
                      "affected_items": [
                        {
                          "id": "9",
                          "name": "GA4 - Config"
                        }
                      ],
                      "affected_items_total": 1,
                      "action": "Fix debug_mode configuration",
                      "recommendation": "Remove the debug_mode parameter, or replace the literal \"true\" with a GTM variable that is only enabled in preview/debug environments."
                    }
                  ],
                  "findings_total": 3,
                  "findings_truncated": false,
                  "by_category": {
                    "ga4": 2,
                    "consent": 1
                  },
                  "by_tier": {
                    "warning": 2,
                    "optimization": 1
                  },
                  "health_score": {
                    "score": 87,
                    "grade": "B",
                    "label": "Healthy",
                    "deductions": {
                      "error": 0,
                      "warning": 8,
                      "optimization": 5,
                      "info": 0,
                      "byCategory": {
                        "ga4": 2,
                        "consent": 1
                      }
                    },
                    "caps": {
                      "error": 35,
                      "warning": 20,
                      "optimization": 25,
                      "info": 0
                    },
                    "functionalIssueCount": 3
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            }
          },
          "400": {
            "description": "Bad request: `data` is missing or is not a GTM container, the body has an unknown field, a filter value is not accepted, `top_n` is not a count, or `include_evidence` is not a boolean.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_data": {
                    "summary": "No data field",
                    "value": {
                      "error": "Missing required field: data (parsed container)"
                    }
                  },
                  "data_not_object": {
                    "summary": "data is not an object",
                    "value": {
                      "error": "data must be a GTM container: a GTM JSON export or a parsed container object"
                    }
                  },
                  "data_not_export": {
                    "summary": "containerVersion without a container record",
                    "value": {
                      "error": "data.containerVersion is not a GTM export: expected a container record with a publicId"
                    }
                  },
                  "data_bad_list": {
                    "summary": "tag, trigger, variable or folder is not an array of objects",
                    "value": {
                      "error": "data.containerVersion.tag must be an array of objects"
                    }
                  },
                  "data_unparseable": {
                    "summary": "The export could not be parsed",
                    "value": {
                      "error": "Could not parse GTM export: <detail>"
                    }
                  },
                  "data_neither": {
                    "summary": "data is neither accepted form",
                    "value": {
                      "error": "data is not a GTM container: expected a GTM JSON export (with containerVersion) or a parsed container (with tags, triggers and variables arrays of objects)"
                    }
                  },
                  "unknown_field": {
                    "summary": "A field the endpoint does not take",
                    "value": {
                      "error": "Unknown field: \"categories\" (did you mean \"category\"?). Accepted: data, category, tier, top_n, include_evidence."
                    }
                  },
                  "bad_filter": {
                    "summary": "Unknown category, tier or status value",
                    "value": {
                      "error": "Unknown category \"privacy\". Category must be one of: consent, ga4, ads, ecommerce, security, pii, performance, quality, organization, dead-code. To check one rule by its rule_id, use POST /v1/evaluate-rule."
                    }
                  },
                  "bad_top_n": {
                    "summary": "top_n negative or not a number",
                    "value": {
                      "error": "top_n must be a number of 0 or more (got -5)."
                    }
                  },
                  "bad_include_evidence": {
                    "summary": "include_evidence not true or false",
                    "value": {
                      "error": "include_evidence must be true or false (got \"yes\")."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "An MCP access token that was not granted the `mcp:tools` scope. The request is not counted against the rate limit and the response has no rate-limit headers. API keys carry both scopes.",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "`Bearer error=\"insufficient_scope\", scope=\"mcp:tools\"`"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "insufficient_scope",
                  "message": "This token was not granted 'mcp:tools', which this endpoint requires."
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "413": {
            "description": "Request body over 10 MB. When the size is declared in `Content-Length` the request is refused before it is counted, and the response has no rate-limit headers. When the body turns out too large while it is being read, the request has been counted and the response carries the rate-limit headers.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "payload_too_large",
                  "message": "Request body too large. The limit is 10 MB."
                }
              }
            }
          },
          "429": {
            "description": "Daily rate limit of 200 requests exceeded. Resets at 00:00 UTC.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limit_exceeded",
                  "message": "Daily limit reached for scan_container (201/200)",
                  "tool": "scan_container",
                  "limit": 200,
                  "count": 201,
                  "reset_at": "2026-05-02T00:00:00.000Z"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The rate limiter could not be reached, so the request was not run. Retry after 30 seconds. No rate-limit headers.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Always `30`."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limiter_unavailable",
                  "message": "Rate limiter temporarily unavailable; request rejected to protect compute limits. Please retry shortly."
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl -X POST https://developer.tagmanifest.com/v1/scan \\\n  -H 'Authorization: Bearer tm_your_api_key' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"data\": {\n      \"meta\": { \"publicId\": \"GTM-ABC123\", \"containerName\": \"Example Site\" },\n      \"tags\": [],\n      \"triggers\": [],\n      \"variables\": []\n    }\n  }'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const response = await fetch('https://developer.tagmanifest.com/v1/scan', {\n  method: 'POST',\n  headers: {\n    'Authorization': 'Bearer tm_your_api_key',\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify({\n    data: {\n      meta: { publicId: 'GTM-ABC123', containerName: 'Example Site' },\n      tags: [],\n      triggers: [],\n      variables: []\n    }\n  })\n});\nconst result = await response.json();\nconsole.log(result.health_score.grade, result.findings_total, 'findings');"
          }
        ]
      }
    },
    "/scan-url": {
      "post": {
        "operationId": "scanUrl",
        "summary": "Scan a container by URL or GTM ID",
        "description": "Audit a published GTM container. Pass a page URL (the endpoint reads the page HTML only to find the first GTM container ID) or a GTM container ID. The container's public `gtm.js` is fetched from Google and parsed, then every rule is run on it. The page itself is not audited.\n\nThe parsed container may come from a cache; entries are reused for up to five minutes. Check `site.from_cache`.\n\nRequires the `mcp:tools` scope when called with an MCP access token.\n\n**Rate limit:** 100 requests/day.",
        "tags": [
          "Scans"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Provide `url` or `gtm_id`; at least one is required, and a request with neither returns 400. Fields other than these are refused with 400.",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Full URL of a page (must start with http:// or https://). The endpoint fetches the page HTML and takes the first GTM container ID it finds. Not fetched when `gtm_id` is given, but must still be a full address if sent.",
                    "example": "https://example.com"
                  },
                  "gtm_id": {
                    "type": "string",
                    "pattern": "^GTM-[A-Z0-9]+$",
                    "description": "GTM container ID. When given, no page is fetched.",
                    "example": "GTM-ABC123"
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "consent",
                      "ga4",
                      "ads",
                      "ecommerce",
                      "security",
                      "pii",
                      "performance",
                      "quality",
                      "organization",
                      "dead-code"
                    ],
                    "description": "Optional filter: only return findings in this category. Any other value, including an empty string, returns 400."
                  },
                  "tier": {
                    "type": "string",
                    "enum": [
                      "error",
                      "warning",
                      "optimization",
                      "info"
                    ],
                    "description": "Optional filter: only return findings at this tier. Any other value, including an empty string, returns 400."
                  },
                  "top_n": {
                    "oneOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "string",
                        "pattern": "^\\s*\\d+(\\.\\d+)?\\s*$"
                      }
                    ],
                    "description": "Optional maximum number of findings to return, most important first (tier, then severity). 0 returns no findings. When omitted or null, all matching findings are returned. Accepts a number of 0 or more, or numeric text such as \"10\". A fraction is rounded down.",
                    "example": 10
                  },
                  "include_evidence": {
                    "oneOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "string",
                        "enum": [
                          "true",
                          "false"
                        ]
                      }
                    ],
                    "default": false,
                    "description": "When true, each finding includes `description` and `evidence`, and `affected_items` holds the affected items the rule reports (some rules list only the first 10 or 20) instead of the first 3. Accepts true or false, or the text \"true\" or \"false\". Null is treated as omitted. Defaults to false."
                  }
                },
                "additionalProperties": false,
                "anyOf": [
                  {
                    "required": [
                      "url"
                    ]
                  },
                  {
                    "required": [
                      "gtm_id"
                    ]
                  }
                ]
              },
              "examples": {
                "by_url": {
                  "summary": "Scan by page URL",
                  "value": {
                    "url": "https://example.com",
                    "top_n": 10
                  }
                },
                "by_gtm_id": {
                  "summary": "Scan by GTM ID with evidence",
                  "value": {
                    "gtm_id": "GTM-ABC123",
                    "include_evidence": true
                  }
                },
                "filtered_consent": {
                  "summary": "Consent warnings only",
                  "value": {
                    "url": "https://example.com",
                    "category": "consent",
                    "tier": "warning"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scan complete. `site.from_cache` says whether the parsed container came from the cache.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanUrlResponse"
                },
                "example": {
                  "scanned_at": "2026-05-01T14:23:00.000Z",
                  "duration_ms": 412,
                  "site": {
                    "url": "https://example.com",
                    "gtm_id": "GTM-ABC123",
                    "from_cache": false
                  },
                  "container": {
                    "tag_count": 42,
                    "trigger_count": 21,
                    "variable_count": 30,
                    "gtm_id": "GTM-ABC123",
                    "name": "Example Site"
                  },
                  "findings": [
                    {
                      "rule_id": "ga4-event-name-invalid-chars",
                      "title": "GA4 event names with invalid characters",
                      "severity": "high",
                      "tier": "warning",
                      "category": "ga4",
                      "finding_count": 1,
                      "affected_items": [
                        {
                          "id": "14",
                          "name": "GA4 - Form Submit",
                          "eventName": "form-submit"
                        }
                      ],
                      "affected_items_total": 1,
                      "action": "Fix event name characters",
                      "recommendation": "Rename events to use only letters, numbers, and underscores. Replace hyphens and spaces with underscores."
                    },
                    {
                      "rule_id": "consent-no-cmp",
                      "title": "No Consent Management Platform (CMP) detected",
                      "severity": "medium",
                      "tier": "warning",
                      "category": "consent",
                      "finding_count": 1,
                      "affected_items": [
                        {
                          "id": "21",
                          "name": "Google Ads - Conversion"
                        },
                        {
                          "id": "22",
                          "name": "Google Ads - Remarketing"
                        }
                      ],
                      "affected_items_total": 2,
                      "action": "Deploy a CMP",
                      "recommendation": "Verify whether consent management is deployed outside GTM (check for CMP scripts in your page source). If consent is managed externally, no action needed in GTM. If no CMP exists and your site serves visitors in regions requiring consent, consider deploying one."
                    },
                    {
                      "rule_id": "ga4-debug-mode-hardcoded",
                      "title": "GA4 debug_mode hardcoded to \"true\"",
                      "severity": "high",
                      "tier": "optimization",
                      "category": "ga4",
                      "finding_count": 1,
                      "affected_items": [
                        {
                          "id": "9",
                          "name": "GA4 - Config"
                        }
                      ],
                      "affected_items_total": 1,
                      "action": "Fix debug_mode configuration",
                      "recommendation": "Remove the debug_mode parameter, or replace the literal \"true\" with a GTM variable that is only enabled in preview/debug environments."
                    }
                  ],
                  "findings_total": 3,
                  "findings_truncated": false,
                  "by_category": {
                    "ga4": 2,
                    "consent": 1
                  },
                  "by_tier": {
                    "warning": 2,
                    "optimization": 1
                  },
                  "health_score": {
                    "score": 87,
                    "grade": "B",
                    "label": "Healthy",
                    "deductions": {
                      "error": 0,
                      "warning": 8,
                      "optimization": 5,
                      "info": 0,
                      "byCategory": {
                        "ga4": 2,
                        "consent": 1
                      }
                    },
                    "caps": {
                      "error": 35,
                      "warning": 20,
                      "optimization": 25,
                      "info": 0
                    },
                    "functionalIssueCount": 3
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            }
          },
          "400": {
            "description": "Bad request: neither `url` nor `gtm_id` given, a malformed `url` or `gtm_id`, an unknown field, a filter value that is not accepted, a `top_n` that is not a count, or an `include_evidence` that is not a boolean.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "Neither url nor gtm_id",
                    "value": {
                      "error": "Provide either url or gtm_id"
                    }
                  },
                  "bad_url": {
                    "summary": "url is not a full http(s) address",
                    "value": {
                      "error": "url must be a full http(s) URL"
                    }
                  },
                  "bad_url_with_gtm_id": {
                    "summary": "gtm_id given with a url that is not an address",
                    "value": {
                      "error": "url must be a full http(s) URL. To scan by container ID alone, leave url out."
                    }
                  },
                  "bad_gtm_id": {
                    "summary": "gtm_id is malformed",
                    "value": {
                      "error": "Invalid gtm_id format: GTM-abc"
                    }
                  },
                  "unknown_field": {
                    "summary": "A field the endpoint does not take",
                    "value": {
                      "error": "Unknown field: \"categories\" (did you mean \"category\"?). Accepted: url, gtm_id, category, tier, top_n, include_evidence."
                    }
                  },
                  "bad_filter": {
                    "summary": "Unknown category, tier or status value",
                    "value": {
                      "error": "Unknown category \"privacy\". Category must be one of: consent, ga4, ads, ecommerce, security, pii, performance, quality, organization, dead-code. To check one rule by its rule_id, use POST /v1/evaluate-rule."
                    }
                  },
                  "bad_top_n": {
                    "summary": "top_n negative or not a number",
                    "value": {
                      "error": "top_n must be a number of 0 or more (got -5)."
                    }
                  },
                  "bad_include_evidence": {
                    "summary": "include_evidence not true or false",
                    "value": {
                      "error": "include_evidence must be true or false (got \"yes\")."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "An MCP access token that was not granted the `mcp:tools` scope. The request is not counted against the rate limit and the response has no rate-limit headers. API keys carry both scopes.",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "`Bearer error=\"insufficient_scope\", scope=\"mcp:tools\"`"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "insufficient_scope",
                  "message": "This token was not granted 'mcp:tools', which this endpoint requires."
                }
              }
            }
          },
          "404": {
            "description": "The page was fetched but its HTML contains no GTM container ID.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "No GTM container ID found in page HTML"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "413": {
            "description": "Request body over 10 MB. When the size is declared in `Content-Length` the request is refused before it is counted, and the response has no rate-limit headers. When the body turns out too large while it is being read, the request has been counted and the response carries the rate-limit headers.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "payload_too_large",
                  "message": "Request body too large. The limit is 10 MB."
                }
              }
            }
          },
          "429": {
            "description": "Daily rate limit of 100 requests exceeded. Resets at 00:00 UTC.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limit_exceeded",
                  "message": "Daily limit reached for scan_url (101/100)",
                  "tool": "scan_url",
                  "limit": 100,
                  "count": 101,
                  "reset_at": "2026-05-02T00:00:00.000Z"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The page or the GTM container could not be fetched.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "page": {
                    "summary": "The page could not be fetched",
                    "value": {
                      "error": "Failed to fetch page: https://example.com (HTTP 403)"
                    }
                  },
                  "container_404": {
                    "summary": "Google has no such published container",
                    "value": {
                      "error": "Container fetch failed: Failed to fetch gtm.js: HTTP 404. Google has no published container with that ID: check the ID, and that the container has been published."
                    }
                  },
                  "container_other": {
                    "summary": "Another failure fetching gtm.js",
                    "value": {
                      "error": "Container fetch failed: Failed to fetch gtm.js: HTTP 503"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The rate limiter could not be reached, so the request was not run. Retry after 30 seconds. No rate-limit headers.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Always `30`."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limiter_unavailable",
                  "message": "Rate limiter temporarily unavailable; request rejected to protect compute limits. Please retry shortly."
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl -X POST https://developer.tagmanifest.com/v1/scan-url \\\n  -H 'Authorization: Bearer tm_your_api_key' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"url\": \"https://example.com\", \"top_n\": 10}'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const response = await fetch('https://developer.tagmanifest.com/v1/scan-url', {\n  method: 'POST',\n  headers: {\n    'Authorization': 'Bearer tm_your_api_key',\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify({ url: 'https://example.com', top_n: 10 })\n});\nconst result = await response.json();\nconst { score, grade } = result.health_score;\nconsole.log(`Score: ${score} (${grade}) — ${result.findings_total} findings`);"
          }
        ]
      }
    },
    "/evaluate-rule": {
      "post": {
        "operationId": "evaluateRule",
        "summary": "Run a single rule against a container",
        "description": "Run one rule against a container. Useful for checking a fix after a GTM change, or for looking at one finding in detail. Findings are returned in full, with evidence, in the rule engine's own form (see RuleFinding).\n\nProvide the container as `data`, a `gtm_id`, or a `url`. At least one is required with `rule_id`. If more than one is sent, the first present is used, in this order: `data`, `gtm_id`, `url`.\n\nRequires the `mcp:tools` scope when called with an MCP access token.\n\n**Rate limit:** 500 requests/day.",
        "tags": [
          "Scans"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "rule_id"
                ],
                "description": "Requires `rule_id` and at least one of `data`, `gtm_id`, `url`. If several are sent, `data` wins, then `gtm_id`. Fields other than these are refused with 400.",
                "properties": {
                  "rule_id": {
                    "type": "string",
                    "description": "The stable rule identifier to evaluate. Use `GET /rules` to discover rule IDs.",
                    "example": "ga4-event-name-invalid-chars"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Full http(s) URL of a page. The endpoint reads the page HTML to find the GTM container ID, then fetches that container. Must be a full address whenever it is sent.",
                    "example": "https://example.com"
                  },
                  "gtm_id": {
                    "type": "string",
                    "pattern": "^GTM-[A-Z0-9]+$",
                    "description": "GTM container ID to fetch and evaluate.",
                    "example": "GTM-ABC123"
                  },
                  "data": {
                    "$ref": "#/components/schemas/ContainerData"
                  }
                },
                "additionalProperties": false,
                "anyOf": [
                  {
                    "required": [
                      "data"
                    ]
                  },
                  {
                    "required": [
                      "gtm_id"
                    ]
                  },
                  {
                    "required": [
                      "url"
                    ]
                  }
                ]
              },
              "examples": {
                "by_url": {
                  "summary": "Check one rule by URL",
                  "value": {
                    "rule_id": "consent-no-cmp",
                    "url": "https://example.com"
                  }
                },
                "by_gtm_id": {
                  "summary": "Check one rule by GTM ID",
                  "value": {
                    "rule_id": "ga4-event-name-invalid-chars",
                    "gtm_id": "GTM-ABC123"
                  }
                },
                "by_data": {
                  "summary": "Check one rule against an export",
                  "value": {
                    "rule_id": "consent-no-cmp",
                    "data": {
                      "exportFormatVersion": 2,
                      "containerVersion": {
                        "container": {
                          "publicId": "GTM-ABC123",
                          "name": "Example Site"
                        },
                        "tag": [],
                        "trigger": [],
                        "variable": []
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rule evaluated. `fired: false` means the container passes this check.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EvaluateRuleResponse"
                },
                "example": {
                  "rule_id": "ga4-event-name-invalid-chars",
                  "evaluated_at": "2026-05-01T14:25:00.000Z",
                  "duration_ms": 210,
                  "fired": true,
                  "finding_count": 1,
                  "findings": [
                    {
                      "ruleId": "ga4-event-name-invalid-chars",
                      "severity": "high",
                      "category": "ga4",
                      "title": "GA4 event names with invalid characters",
                      "description": "1 GA4 event tags have event names containing spaces, hyphens, or starting with a number. GA4 event names must only contain letters, numbers, and underscores, and must start with a letter. Events with invalid names may not appear in reports as expected.",
                      "affectedItems": [
                        {
                          "id": "14",
                          "name": "GA4 - Form Submit",
                          "eventName": "form-submit"
                        }
                      ],
                      "evidence": [
                        {
                          "tagId": "14",
                          "eventName": "form-submit"
                        }
                      ],
                      "recommendation": "Rename events to use only letters, numbers, and underscores. Replace hyphens and spaces with underscores.",
                      "action": "Fix event name characters",
                      "tier": "warning"
                    }
                  ],
                  "container": {
                    "gtm_id": "GTM-ABC123",
                    "tag_count": 34,
                    "from_cache": false
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            }
          },
          "400": {
            "description": "Bad request: `rule_id` missing, no container source, a malformed `url` or `gtm_id`, an unknown field, or `data` that is not a GTM container.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_rule_id": {
                    "summary": "No rule_id",
                    "value": {
                      "error": "Missing required field: rule_id"
                    }
                  },
                  "no_container": {
                    "summary": "No container source",
                    "value": {
                      "error": "Provide one of: data, gtm_id, url"
                    }
                  },
                  "bad_url": {
                    "summary": "url is not a full http(s) address",
                    "value": {
                      "error": "url must be a full http(s) URL"
                    }
                  },
                  "gtm_id_in_url": {
                    "summary": "A container ID sent as url",
                    "value": {
                      "error": "url must be a full http(s) URL. For a container ID, use gtm_id."
                    }
                  },
                  "bad_gtm_id": {
                    "summary": "gtm_id is malformed",
                    "value": {
                      "error": "Invalid gtm_id: GTM-abc"
                    }
                  },
                  "unknown_field": {
                    "summary": "A field the endpoint does not take",
                    "value": {
                      "error": "Unknown field: \"urls\" (did you mean \"url\"?). Accepted: rule_id, data, gtm_id, url."
                    }
                  },
                  "data_not_object": {
                    "summary": "data is not an object",
                    "value": {
                      "error": "data must be a GTM container: a GTM JSON export or a parsed container object"
                    }
                  },
                  "data_not_export": {
                    "summary": "containerVersion without a container record",
                    "value": {
                      "error": "data.containerVersion is not a GTM export: expected a container record with a publicId"
                    }
                  },
                  "data_bad_list": {
                    "summary": "tag, trigger, variable or folder is not an array of objects",
                    "value": {
                      "error": "data.containerVersion.tag must be an array of objects"
                    }
                  },
                  "data_unparseable": {
                    "summary": "The export could not be parsed",
                    "value": {
                      "error": "Could not parse GTM export: <detail>"
                    }
                  },
                  "data_neither": {
                    "summary": "data is neither accepted form",
                    "value": {
                      "error": "data is not a GTM container: expected a GTM JSON export (with containerVersion) or a parsed container (with tags, triggers and variables arrays of objects)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "An MCP access token that was not granted the `mcp:tools` scope. The request is not counted against the rate limit and the response has no rate-limit headers. API keys carry both scopes.",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "`Bearer error=\"insufficient_scope\", scope=\"mcp:tools\"`"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "insufficient_scope",
                  "message": "This token was not granted 'mcp:tools', which this endpoint requires."
                }
              }
            }
          },
          "404": {
            "description": "The `rule_id` is not a rule the engine runs, or the page HTML contains no GTM container ID.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unknown_rule": {
                    "summary": "Unknown rule",
                    "value": {
                      "error": "Unknown rule_id: not-a-rule"
                    }
                  },
                  "no_gtm": {
                    "summary": "No GTM ID on the page",
                    "value": {
                      "error": "No GTM container ID found in page HTML"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "413": {
            "description": "Request body over 10 MB. When the size is declared in `Content-Length` the request is refused before it is counted, and the response has no rate-limit headers. When the body turns out too large while it is being read, the request has been counted and the response carries the rate-limit headers.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "payload_too_large",
                  "message": "Request body too large. The limit is 10 MB."
                }
              }
            }
          },
          "429": {
            "description": "Daily rate limit of 500 requests exceeded. Resets at 00:00 UTC.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limit_exceeded",
                  "message": "Daily limit reached for evaluate_rule (501/500)",
                  "tool": "evaluate_rule",
                  "limit": 500,
                  "count": 501,
                  "reset_at": "2026-05-02T00:00:00.000Z"
                }
              }
            }
          },
          "500": {
            "description": "The rule threw an unexpected error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Rule evaluation failed: <message>"
                }
              }
            }
          },
          "502": {
            "description": "The page or the GTM container could not be fetched.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "page": {
                    "summary": "The page could not be fetched",
                    "value": {
                      "error": "Failed to fetch page: https://example.com"
                    }
                  },
                  "container": {
                    "summary": "gtm.js could not be fetched",
                    "value": {
                      "error": "Container fetch failed: Failed to fetch gtm.js: HTTP 404"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The rate limiter could not be reached, so the request was not run. Retry after 30 seconds. No rate-limit headers.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Always `30`."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limiter_unavailable",
                  "message": "Rate limiter temporarily unavailable; request rejected to protect compute limits. Please retry shortly."
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl -X POST https://developer.tagmanifest.com/v1/evaluate-rule \\\n  -H 'Authorization: Bearer tm_your_api_key' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"rule_id\": \"ga4-event-name-invalid-chars\", \"url\": \"https://example.com\"}'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const response = await fetch('https://developer.tagmanifest.com/v1/evaluate-rule', {\n  method: 'POST',\n  headers: {\n    'Authorization': 'Bearer tm_your_api_key',\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify({\n    rule_id: 'ga4-event-name-invalid-chars',\n    url: 'https://example.com'\n  })\n});\nconst { fired, findings } = await response.json();\nconsole.log(fired ? `Rule fired: ${findings.length} finding(s)` : 'Pass: the rule did not fire');"
          }
        ]
      }
    },
    "/rules": {
      "get": {
        "operationId": "listRules",
        "summary": "List the rule catalog",
        "description": "Return rules from the TagManifest catalog. By default returns all `shipped` rules (92). Use it to discover rule IDs before calling `/evaluate-rule` or `/rules-detail`.\n\nOnly `category`, `tier`, `status` and `limit` are accepted. Any other query parameter returns 400.\n\nRequires the `mcp:read` or `mcp:tools` scope when called with an MCP access token.\n\n**Rate limit:** 1 000 requests/day.",
        "tags": [
          "Rules"
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "consent",
                "ga4",
                "ads",
                "ecommerce",
                "security",
                "pii",
                "performance",
                "quality",
                "organization",
                "dead-code"
              ]
            },
            "description": "Filter rules to one category. Any other value, including an empty string, returns 400."
          },
          {
            "name": "tier",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "error",
                "warning",
                "optimization",
                "info"
              ]
            },
            "description": "Filter rules to one tier. Any other value, including an empty string, returns 400."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "shipped",
                "deferred",
                "all"
              ],
              "default": "shipped"
            },
            "description": "Filter by rule status. `shipped` returns the rules that produce findings. `deferred` returns the two rules that are listed in the catalog with status `deferred`; they produce no findings today. `all` returns every rule. Defaults to `shipped`. Any other value returns 400."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0,
              "default": 200
            },
            "description": "Maximum number of rules to return. Must be 0 or more. 0 means the default of 200. Values over 500 are cut to 500. A fraction is accepted and rounded down. An empty value (`limit=`) is treated as left out.",
            "allowEmptyValue": true
          }
        ],
        "responses": {
          "200": {
            "description": "Rule list returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total",
                    "rules"
                  ],
                  "properties": {
                    "total": {
                      "type": "integer",
                      "description": "Number of rules in this response, after the filters and the limit.",
                      "example": 92
                    },
                    "rules": {
                      "type": "array",
                      "description": "Array of rule catalog entries, ordered by category then rule_id alphabetically.",
                      "items": {
                        "$ref": "#/components/schemas/Rule"
                      }
                    }
                  }
                },
                "example": {
                  "total": 2,
                  "rules": [
                    {
                      "rule_id": "consent-cmp-not-wired",
                      "title": "CMP detected but consent mode not wired",
                      "description": "A CMP is installed but 80%+ of tags have no consent configuration, making the CMP effectively decorative.",
                      "recommendation": "Configure consent types on all tags that collect or process user data.",
                      "category": "consent",
                      "tier": "warning",
                      "severity": "critical",
                      "layer_requirements": "container",
                      "status": "shipped",
                      "version": 1,
                      "effort_estimate": "2wk",
                      "reversibility": "non-destructive",
                      "regulatory_cites": [
                        "GDPR Art. 6 (lawful basis)",
                        "GDPR Art. 7 (consent)"
                      ],
                      "learn_more_url": null
                    },
                    {
                      "rule_id": "consent-no-cmp",
                      "title": "No CMP detected",
                      "description": "Tags require consent but no Consent Management Platform is detected in the container.",
                      "recommendation": "Install a CMP (CookieBot, OneTrust, etc.) and configure it to fire on Consent Initialization.",
                      "category": "consent",
                      "tier": "warning",
                      "severity": "high",
                      "layer_requirements": "container",
                      "status": "shipped",
                      "version": 1,
                      "effort_estimate": "strategic",
                      "reversibility": "non-destructive",
                      "regulatory_cites": [
                        "GDPR Art. 6 (lawful basis)",
                        "GDPR Art. 7 (consent)"
                      ],
                      "learn_more_url": null
                    }
                  ]
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            }
          },
          "400": {
            "description": "Bad request: an unknown query parameter, a `category`, `tier` or `status` value that is not accepted, or a `limit` that is not a count.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unknown_parameter": {
                    "summary": "A query parameter the endpoint does not take",
                    "value": {
                      "error": "Unknown query parameter: \"statuses\" (did you mean \"status\"?). Accepted: category, tier, status, limit."
                    }
                  },
                  "bad_tier": {
                    "summary": "Unknown tier value",
                    "value": {
                      "error": "Unknown tier \"critical\". Tier must be one of: error, warning, optimization, info."
                    }
                  },
                  "bad_status": {
                    "summary": "Unknown status value",
                    "value": {
                      "error": "Unknown status \"live\". Status must be one of: shipped, deferred, all."
                    }
                  },
                  "bad_limit": {
                    "summary": "limit negative or not a number",
                    "value": {
                      "error": "limit must be a number of 0 or more (got \"-1\")."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "An MCP access token that was not granted the `mcp:read` scope. The request is not counted against the rate limit and the response has no rate-limit headers. API keys carry both scopes.",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "`Bearer error=\"insufficient_scope\", scope=\"mcp:read\"`"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "insufficient_scope",
                  "message": "This token was not granted 'mcp:read', which this endpoint requires."
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "429": {
            "description": "Daily rate limit of 1 000 requests exceeded. Resets at 00:00 UTC.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limit_exceeded",
                  "message": "Daily limit reached for list_rules (1001/1000)",
                  "tool": "list_rules",
                  "limit": 1000,
                  "count": 1001,
                  "reset_at": "2026-05-02T00:00:00.000Z"
                }
              }
            }
          },
          "500": {
            "description": "The rule registry could not be read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Registry read failed: <status> <detail>"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "# List all shipped consent rules\ncurl 'https://developer.tagmanifest.com/v1/rules?category=consent' \\\n  -H 'Authorization: Bearer tm_your_api_key'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const url = new URL('https://developer.tagmanifest.com/v1/rules');\nurl.searchParams.set('category', 'consent');\nurl.searchParams.set('tier', 'warning');\n\nconst response = await fetch(url, {\n  headers: { 'Authorization': 'Bearer tm_your_api_key' }\n});\nconst { total, rules } = await response.json();\nconsole.log(`${total} rules matching filters:`);\nrules.forEach(r => console.log(`  ${r.rule_id}: ${r.title}`));"
          }
        ]
      }
    },
    "/rules-detail": {
      "get": {
        "operationId": "getRule",
        "summary": "Get full metadata for one rule",
        "description": "Fetch the catalog entry for one rule by `rule_id`: description, recommendation, regulatory citations, effort estimate and the other public fields. The rule is always passed as the `rule_id` query parameter; there is no `/rules/{rule_id}` path.\n\nRequires the `mcp:read` or `mcp:tools` scope when called with an MCP access token.\n\n**Rate limit:** 1 000 requests/day.",
        "tags": [
          "Rules"
        ],
        "parameters": [
          {
            "name": "rule_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The stable rule identifier. Obtain from `GET /rules` or from a `rule_id` in a scan response.",
            "example": "ga4-pii-parameter-names"
          }
        ],
        "responses": {
          "200": {
            "description": "Rule detail returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rule"
                },
                "example": {
                  "rule_id": "ga4-pii-parameter-names",
                  "title": "Parameters with PII-suggesting names",
                  "description": "Parameters with names like \"email\", \"phone\", or \"user_name\" — GA4 prohibits sending PII.",
                  "recommendation": "Remove PII parameters or hash values with SHA-256 before sending.",
                  "category": "ga4",
                  "tier": "error",
                  "severity": "critical",
                  "layer_requirements": "container",
                  "status": "shipped",
                  "version": 1,
                  "effort_estimate": "15min",
                  "reversibility": "non-destructive",
                  "regulatory_cites": [
                    "GDPR Art. 5",
                    "GDPR Art. 6"
                  ],
                  "learn_more_url": null
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            }
          },
          "400": {
            "description": "Missing required `rule_id` query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Missing required query param: rule_id"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "An MCP access token that was not granted the `mcp:read` scope. The request is not counted against the rate limit and the response has no rate-limit headers. API keys carry both scopes.",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "`Bearer error=\"insufficient_scope\", scope=\"mcp:read\"`"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "insufficient_scope",
                  "message": "This token was not granted 'mcp:read', which this endpoint requires."
                }
              }
            }
          },
          "404": {
            "description": "No rule found for the given `rule_id`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Rule not found: not-a-rule"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "429": {
            "description": "Daily rate limit of 1 000 requests exceeded. Resets at 00:00 UTC.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "string"
                },
                "description": "Daily limit for this endpoint."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Requests remaining today."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "string"
                },
                "description": "ISO 8601 timestamp when the limit resets (next 00:00 UTC)."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limit_exceeded",
                  "message": "Daily limit reached for get_rule (1001/1000)",
                  "tool": "get_rule",
                  "limit": 1000,
                  "count": 1001,
                  "reset_at": "2026-05-02T00:00:00.000Z"
                }
              }
            }
          },
          "500": {
            "description": "The rule registry could not be read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Registry read failed: <status> <detail>"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl 'https://developer.tagmanifest.com/v1/rules-detail?rule_id=ga4-pii-parameter-names' \\\n  -H 'Authorization: Bearer tm_your_api_key'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const ruleId = 'ga4-pii-parameter-names';\nconst response = await fetch(\n  `https://developer.tagmanifest.com/v1/rules-detail?rule_id=${encodeURIComponent(ruleId)}`,\n  { headers: { 'Authorization': 'Bearer tm_your_api_key' } }\n);\nif (!response.ok) throw new Error(`Rule fetch failed: ${response.status}`);\nconst rule = await response.json();\nconsole.log(rule.recommendation);"
          }
        ]
      }
    },
    "/api-keys": {
      "post": {
        "operationId": "createApiKey",
        "summary": "Create an API key",
        "description": "Create a new API key for the signed-in user. The full plaintext key (prefixed `tm_`) is returned **once** in the response and never again. An account can hold at most five active keys. Key creation can be limited to approved accounts; an account outside the list then gets a 403.\n\nRequires the account page's **session JWT** in the Authorization header. API keys and MCP access tokens are refused with 403. These endpoints are not rate limited and their responses carry no rate-limit headers.",
        "tags": [
          "Keys"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional label for the key, shown in the key list. Surrounding spaces are trimmed, and the trimmed label must be 60 characters or fewer. An empty label, or null, is stored as null. Any other type returns 400.",
                    "example": "Production server"
                  }
                }
              },
              "example": {
                "label": "Production server"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Key created. The `api_key` field contains the full plaintext value — save it now, it cannot be retrieved again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "prefix",
                    "label",
                    "api_key",
                    "warning"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "UUID of the new key record. Use this to revoke the key via `DELETE /api-keys?id=`.",
                      "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
                    },
                    "prefix": {
                      "type": "string",
                      "description": "First 11 characters of the key (`tm_` plus 8 hex characters).",
                      "example": "tm_a1b2c3d4"
                    },
                    "label": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "The label you provided, or null.",
                      "example": "Production server"
                    },
                    "api_key": {
                      "type": "string",
                      "description": "Full plaintext API key. Shown only once. Format: `tm_` followed by 48 hex characters (51 characters in all).",
                      "example": "tm_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6"
                    },
                    "warning": {
                      "type": "string",
                      "description": "Reminder that this is the only time the full key will be shown.",
                      "example": "This is the only time the full key will be shown. Store it now."
                    }
                  }
                },
                "example": {
                  "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
                  "prefix": "tm_a1b2c3d4",
                  "label": "Production server",
                  "api_key": "tm_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6",
                  "warning": "This is the only time the full key will be shown. Store it now."
                }
              }
            }
          },
          "400": {
            "description": "`label` is neither a string nor null, or is longer than 60 characters after trimming.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_string": {
                    "summary": "label is not a string",
                    "value": {
                      "error": "label must be a string"
                    }
                  },
                  "too_long": {
                    "summary": "label too long",
                    "value": {
                      "error": "label must be 60 characters or fewer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The token is not the account page's session JWT, or key creation is limited to approved accounts and this account is not one of them.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "api_key": {
                    "summary": "An API key was sent",
                    "value": {
                      "error": "API keys cannot manage API keys — use a session JWT"
                    }
                  },
                  "mcp_token": {
                    "summary": "An MCP access token was sent",
                    "value": {
                      "error": "MCP access tokens cannot manage API keys — use a session JWT"
                    }
                  },
                  "not_approved": {
                    "summary": "Key creation is limited to approved accounts",
                    "value": {
                      "error": "Key creation is limited to approved accounts."
                    }
                  }
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "409": {
            "description": "The account already holds five active keys.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "This account already has 5 active keys. Revoke one to create another."
                }
              }
            }
          },
          "413": {
            "description": "Request body over 16 KB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Request body too large"
                }
              }
            }
          },
          "500": {
            "description": "Key generation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Key generation failed"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl -X POST https://developer.tagmanifest.com/v1/api-keys \\\n  -H 'Authorization: Bearer YOUR_SESSION_JWT' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"label\": \"Production server\"}'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const response = await fetch('https://developer.tagmanifest.com/v1/api-keys', {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${sessionJwt}`,\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify({ label: 'Production server' })\n});\nif (response.status !== 201) throw new Error('Key creation failed');\nconst { api_key, id } = await response.json();\n// Store api_key securely — it won't be shown again\nconsole.log('Key ID:', id, '\\nKey (save this):', api_key);"
          }
        ]
      },
      "get": {
        "operationId": "listApiKeys",
        "summary": "List API keys",
        "description": "Return metadata for all API keys belonging to the signed-in user, newest first. Plaintext key values are never returned.\n\nRequires the account page's **session JWT** in the Authorization header. API keys and MCP access tokens are refused with 403. These endpoints are not rate limited and their responses carry no rate-limit headers.",
        "tags": [
          "Keys"
        ],
        "responses": {
          "200": {
            "description": "List of key metadata records, ordered newest-first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "keys"
                  ],
                  "properties": {
                    "keys": {
                      "type": "array",
                      "description": "Array of API key metadata objects.",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  }
                },
                "example": {
                  "keys": [
                    {
                      "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
                      "key_prefix": "tm_a1b2c3d4",
                      "label": "Production server",
                      "created_at": "2026-04-01T10:00:00.000Z",
                      "last_used_at": "2026-05-01T09:30:00.000Z",
                      "revoked_at": null
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The token is not the account page's session JWT.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "api_key": {
                    "summary": "An API key was sent",
                    "value": {
                      "error": "API keys cannot manage API keys — use a session JWT"
                    }
                  },
                  "mcp_token": {
                    "summary": "An MCP access token was sent",
                    "value": {
                      "error": "MCP access tokens cannot manage API keys — use a session JWT"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "500": {
            "description": "The keys could not be listed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to list keys"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl https://developer.tagmanifest.com/v1/api-keys \\\n  -H 'Authorization: Bearer YOUR_SESSION_JWT'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const response = await fetch('https://developer.tagmanifest.com/v1/api-keys', {\n  headers: { 'Authorization': `Bearer ${sessionJwt}` }\n});\nconst { keys } = await response.json();\nkeys.forEach(k => console.log(`${k.key_prefix} (${k.label}) — last used: ${k.last_used_at || 'never'}`));"
          }
        ]
      },
      "delete": {
        "operationId": "revokeApiKey",
        "summary": "Revoke an API key",
        "description": "Revoke one API key by its UUID. The key record is kept with its `revoked_at` timestamp set; the key stops authenticating requests at once. You can only revoke your own keys.\n\nRequires the account page's **session JWT** in the Authorization header. API keys and MCP access tokens are refused with 403. These endpoints are not rate limited and their responses carry no rate-limit headers.",
        "tags": [
          "Keys"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "UUID of the API key to revoke. Obtain from `GET /api-keys`.",
            "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
          }
        ],
        "responses": {
          "200": {
            "description": "Key successfully revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "revoked",
                    "id"
                  ],
                  "properties": {
                    "revoked": {
                      "type": "boolean",
                      "example": true
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
                    }
                  }
                },
                "example": {
                  "revoked": true,
                  "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
                }
              }
            }
          },
          "400": {
            "description": "The `id` query parameter is missing or is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No id",
                    "value": {
                      "error": "Missing required query param: id"
                    }
                  },
                  "invalid": {
                    "summary": "id is not a UUID",
                    "value": {
                      "error": "Invalid key id"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, expired or revoked bearer token. No rate-limit headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "No Authorization header",
                    "value": {
                      "error": "Missing or malformed Authorization header"
                    }
                  },
                  "bad_key": {
                    "summary": "Unknown or revoked API key",
                    "value": {
                      "error": "Invalid or revoked API key"
                    }
                  },
                  "bad_token": {
                    "summary": "Invalid or expired MCP access token or session token",
                    "value": {
                      "error": "Invalid or expired token"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The token is not the account page's session JWT.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "api_key": {
                    "summary": "An API key was sent",
                    "value": {
                      "error": "API keys cannot manage API keys — use a session JWT"
                    }
                  },
                  "mcp_token": {
                    "summary": "An MCP access token was sent",
                    "value": {
                      "error": "MCP access tokens cannot manage API keys — use a session JWT"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No key found with the given ID belonging to the authenticated user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Key not found"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "500": {
            "description": "Revocation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Revoke failed"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl -X DELETE 'https://developer.tagmanifest.com/v1/api-keys?id=f47ac10b-58cc-4372-a567-0e02b2c3d479' \\\n  -H 'Authorization: Bearer YOUR_SESSION_JWT'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js",
            "source": "const keyId = 'f47ac10b-58cc-4372-a567-0e02b2c3d479';\nconst response = await fetch(\n  `https://developer.tagmanifest.com/v1/api-keys?id=${keyId}`,\n  { method: 'DELETE', headers: { 'Authorization': `Bearer ${sessionJwt}` } }\n);\nconst result = await response.json();\nconsole.log(result.revoked ? `Key ${keyId} revoked` : 'Revoke failed');"
          }
        ]
      }
    }
  }
}
