POST /scan
Audit a GTM container you send as JSON, either the export file from GTM or an already parsed container. Returns findings most important first (by tier, then severity) plus a health score.
On this page 5
Summary
- endpoint —
POST /scan - purpose — audit a GTM container sent in the request body, without fetching any URLs
- mcp equivalent —
scan_container - rate limit — 200/day per user
- synchronous — yes
Send a GTM container in the request body and receive findings, per-category counts, and a health score. The endpoint fetches nothing: no page and no gtm.js. Use it when you have the container export file from GTM, including one for a workspace that is not published.
Request
Headers
| Header | Required | Value |
|---|---|---|
Authorization | yes | Bearer <token>. An API key, or an MCP access token with the mcp:tools scope. See Authentication. |
Content-Type | recommended | application/json. The body is read as JSON whether or not the header is sent. |
Body parameters
| Field | Type | Required | Description |
|---|---|---|---|
data | object | required | The container. Either the GTM JSON export as downloaded, or an already parsed container. See below. |
category | string | optional | Restrict findings to one category: consent, ga4, ads, ecommerce, security, pii, performance, quality, organization or dead-code. |
tier | string | optional | Restrict findings to one tier: error, warning, optimization, or info. |
top_n | number | optional | Maximum findings to return, most important first (by tier, then severity). Must be 0 or more. 0 returns no findings. Returns all findings when omitted. Numeric text such as "10" is accepted; a fraction is rounded down. |
include_evidence | boolean | optional | Return the longer finding: description, evidence, and the affected items the rule reports (some rules list only the first 10 or 20) in place of the first three. Default false. The text "true" and "false" are accepted. |
Any other field in the body is refused with a 400, so a misspelt filter is never silently ignored.
What data accepts
data takes one of two forms.
- A GTM JSON export. This is the file from Admin → Export container in GTM, sent unchanged. The endpoint recognises it by its
containerVersionkey and parses it.containerVersion.containermust carry the container'spublicId(acontainerIdis accepted in its place). With only acontainerId, the container is still audited andcontainer.gtm_idin the response is the textUnknown. Iftag,trigger,variableorfolderare present undercontainerVersion, each must be an array of objects. - A parsed container. This is the form TagManifest's own parser produces: an object with
tags,triggersandvariables, each an array of objects. Every tag needs a stringtypeand afiringTriggerIdsarray. Every trigger and every variable needs a stringtypeand areferencedByTagsarray.meta.publicIdandmeta.containerNameare optional and fillcontainer.gtm_idandcontainer.namein the response.
Most callers should send the export. Anything that is neither form is refused with a 400 and is not audited.
Synchronous. The endpoint returns when the audit completes. No scan IDs, no polling, no webhooks.
Response
Returns a scan object with container metadata, a findings array sorted by tier then severity, per-category and per-tier counts, and a health score. The shape is the same as POST /scan-url without the site object.
| Field | Description |
|---|---|
container | Tag, trigger and variable counts, plus the GTM ID and container name read from the container (or null). |
findings | The findings after the category and tier filters and the top_n cut. |
findings_total | How many findings match the filters, before top_n. |
findings_truncated | true when top_n cut the list short. |
by_category, by_tier | Counts of all findings in the container. Filters do not change them. |
health_score | The score for the whole container. Filters do not change it. See Health score. |
affected_items is a list of objects, one per tag, trigger or variable. Each has an id and a name, and some rules add fields such as eventName. By default the list holds the first three items and affected_items_total gives the number of items the rule reported.
With include_evidence: true a finding has description and evidence as well, affected_items holds the affected items the rule reports (some rules list only the first 10 or 20), and finding_count and affected_items_total are left out. The set of fields is fixed: a rule's own extra fields, such as subType, are not returned.
{
"scanned_at": "2026-05-04T14:00:00.000Z",
"duration_ms": 38,
"container": {
"tag_count": 42,
"trigger_count": 18,
"variable_count": 31,
"gtm_id": "GTM-EXAMPLE",
"name": "My Website"
},
"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
}
}
Response headers
| Header | Description |
|---|---|
X-RateLimit-Limit | Daily call ceiling for this endpoint (200) |
X-RateLimit-Remaining | Calls remaining in the current bucket |
X-RateLimit-Reset | ISO timestamp when the bucket resets (UTC midnight) |
These headers are on every response to a request that was counted, including the 400 and 429 errors below. They are absent on 401, 403, 405, 503 and on a 413 for a declared oversize body. See Rate limits.
Errors
| Status | Body | Cause |
|---|---|---|
400 | { "error": "Missing required field: data (parsed container)" } | The body has no data field, or the body is not valid JSON |
400 | { "error": "data must be a GTM container: a GTM JSON export or a parsed container object" } | data is not an object |
400 | { "error": "data.containerVersion is not a GTM export: expected a container record with a publicId" } | data has containerVersion but no container record with an ID |
400 | { "error": "data.containerVersion.tag must be an array of objects" } | tag, trigger, variable or folder under containerVersion is not an array of objects. The message names the key. |
400 | { "error": "Could not parse GTM export: ..." } | The export could not be parsed |
400 | { "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)" } | data is an object but is neither accepted form |
400 | { "error": "Unknown category \"privacy\". Category must be one of: ..." } | category or tier is not a real value. The message lists the accepted ones. An empty string is refused too: leave the field out. |
400 | { "error": "Unknown field: \"categories\" (did you mean \"category\"?). Accepted: ..." } | The body has a field this endpoint does not take. It is refused so that a misspelt filter is never silently ignored. |
400 | { "error": "top_n must be a number of 0 or more (got -5)." } | top_n is negative or not a number. A number sent as text is accepted; a fraction is rounded down. |
400 | { "error": "include_evidence must be true or false (got ...)." } | include_evidence is not a boolean (the text "true" and "false" are accepted, and null is treated as left out). |
401 | { "error": "Invalid or expired token" } | Missing, malformed, expired or revoked bearer token. An API key failure reads Invalid or revoked API key. |
403 | { "error": "insufficient_scope", "message": "This token was not granted 'mcp:tools', which this endpoint requires." } | An MCP access token without the mcp:tools scope. Not counted against the rate limit. |
413 | { "error": "payload_too_large", "message": "Request body too large. The limit is 10 MB." } | Request body over 10 MB |
429 | { "error": "rate_limit_exceeded", "message": "Daily limit reached for scan_container (201/200)", "tool": "scan_container", "limit": 200, "count": 201, "reset_at": "..." } | Daily bucket exhausted; retry after X-RateLimit-Reset |
503 | { "error": "rate_limiter_unavailable", "message": "..." } | The rate limiter could not be reached, so the scan was not run. The response has Retry-After: 30. |
500 | { "error": "..." } | Internal failure; retry once before reporting |
Try saying
Useful when wiring this endpoint to an agent that will call it programmatically.
Tell the agent something like:
You have access to TagManifest's REST API at https://developer.tagmanifest.com/v1.
Use POST /scan to audit a GTM container export.
Pass the export JSON, unchanged, as the "data" field in the request body.
Authentication: include header "Authorization: Bearer <api-key>".
Or, when the agent has direct HTTP capability:
- "Audit this GTM export using TagManifest's scan endpoint and return any consent findings"
- "Run a TagManifest audit on the container export I just downloaded and show only warning-tier findings"
See also
- MCP equivalent:
scan_container— same audit, MCP path - POST /scan-url — use this instead when you only have a URL or GTM ID
- POST /evaluate-rule — run a single rule and get full evidence
Examples
# container-export.json is the file from
# GTM → Admin → Export container, unchanged.
curl https://developer.tagmanifest.com/v1/scan \
-H "Authorization: Bearer $TM_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"data\": $(cat container-export.json), \"top_n\": 25}"
import { readFile } from "node:fs/promises";
// The GTM export file, unchanged.
const containerJson = JSON.parse(
await readFile("container-export.json", "utf8")
);
const r = await fetch("https://developer.tagmanifest.com/v1/scan", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TM_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
data: containerJson,
top_n: 25
})
});
const result = await r.json();
import httpx, json, os
# The GTM export file, unchanged.
with open("container-export.json") as f:
container_json = json.load(f)
r = httpx.post(
"https://developer.tagmanifest.com/v1/scan",
headers={"Authorization": f"Bearer {os.environ['TM_API_KEY']}"},
json={"data": container_json, "top_n": 25},
)
result = r.json()
{
"scanned_at": "2026-05-04T14:00:00.000Z",
"duration_ms": 38,
"container": {
"tag_count": 42,
"trigger_count": 18,
"variable_count": 31,
"gtm_id": "GTM-EXAMPLE",
"name": "My Website"
},
"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
}
}