> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webrouter.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Tag Manager

> Your Tag Manager accounts, containers and workspaces: read tags, triggers and variables.

![](https://mintcdn.com/webrouter/gPu3tCeozwRcDBjt/logo/data-apis/google-tag-manager.svg?fit=max\&auto=format\&n=gPu3tCeozwRcDBjt\&q=85\&s=ff44359ec2c39aea30e545c3173eea9e)

[Web Catalog · Analytics](https://docs.webrouter.net/data-apis.md?category=analytics)

Needs&#x20;

`GOOGLE_TAG_MANAGER_CLIENT_ID`

,&#x20;

`GOOGLE_TAG_MANAGER_CLIENT_SECRET`

,&#x20;

`GOOGLE_TAG_MANAGER_REFRESH_TOKEN`

Endpoints

7

Auth

OAuth refresh token

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2)

## Setup

| Variable | | What it is |
| - | - | - |
| `GOOGLE_TAG_MANAGER_CLIENT_ID` | required | the OAuth client id of a Google Cloud OAuth app with the Tag Manager API enabled (Google Cloud console > APIs & Services > Credentials) |
| `GOOGLE_TAG_MANAGER_CLIENT_SECRET` | required | that OAuth app's client secret |
| `GOOGLE_TAG_MANAGER_REFRESH_TOKEN` | required | a refresh token minted with that OAuth app for the scope [https://www.googleapis.com/auth/tagmanager.readonly](https://www.googleapis.com/auth/tagmanager.readonly) (reads), tagmanager.edit.containerversions and tagmanager.publish (the write calls) |

Put them in your environment or `.env`; [Data APIs](https://docs.webrouter.net/vendors.md) covers the other ways.

## Notes

* Own-account API: every call acts as the Google user the refresh token belongs to, and only reaches accounts that user can access.
* Resources nest: account > container > workspace > tags, triggers, variables. Ids are digits; the public GTM-XXXX id is not an API id.
* Lists page with pageToken/nextPageToken. A publish makes a container version live on the real site; create\_version only snapshots a workspace.
* Per-method OAuth scopes are narrower than one broad token: reads need tagmanager.readonly, creating a version needs tagmanager.edit.containerversions, publishing needs tagmanager.publish.

## Endpoints

GET

List Tag Manager accounts

Every GTM account the signed-in user can access.

[Open](#google-tag-manager-accounts-list)

GET

List containers in an account

Containers (web, server, iOS, Android) of one account.

[Open](#google-tag-manager-containers-list)

GET

List workspaces of a container

Workspaces (editing sandboxes) of one container.

[Open](#google-tag-manager-workspaces-list)

GET

List tags in a workspace

All tags of a workspace with type, parameters and firing triggers.

[Open](#google-tag-manager-tags-list)

GET

Get one tag

One tag of a workspace by id.

[Open](#google-tag-manager-tags-get)

GET

List triggers in a workspace

All triggers of a workspace.

[Open](#google-tag-manager-triggers-list)

GET

List variables in a workspace

All user-defined variables of a workspace.

[Open](#google-tag-manager-variables-list)

### List Tag Manager accounts

GET

`/accounts`

`google-tag-manager.accounts.list`

Every GTM account the signed-in user can access.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `includeGoogleTags`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Also return accounts associated with Google Tag.
      </td>
    </tr>

    <tr>
      <td>
        `pageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        nextPageToken from the previous answer.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2/accounts/list) · Same job: [Cloudflare](https://docs.webrouter.net/data-apis/cloudflare.md#cloudflare-zones-list), [Snitcher](https://docs.webrouter.net/data-apis/snitcher.md#snitcher-workspaces-list), [Sprout Social](https://docs.webrouter.net/data-apis/sprout-social.md#sprout-social-metadata-client)

```python Python theme={null}
router.call_data_api("google-tag-manager.accounts.list")
```

```text MCP theme={null}
call_data_api(endpoint="google-tag-manager.accounts.list")
```

### List containers in an account

GET

`/accounts/{account_id}/containers`

`google-tag-manager.containers.list`

Containers (web, server, iOS, Android) of one account.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`account_id` required</td><td>string</td><td>path</td><td>GTM account id, digits. Example `6000000000`</td></tr>

    <tr>
      <td>
        `pageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        nextPageToken from the previous answer.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2/accounts.containers/list)

```python Python theme={null}
router.call_data_api("google-tag-manager.containers.list", {'account_id': '6000000000'})
```

```text MCP theme={null}
call_data_api(endpoint="google-tag-manager.containers.list", params={"account_id": "6000000000"})
```

### List workspaces of a container

GET

`/accounts/{account_id}/containers/{container_id}/workspaces`

`google-tag-manager.workspaces.list`

Workspaces (editing sandboxes) of one container.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`account_id` required</td><td>string</td><td>path</td><td>GTM account id, digits. Example `6000000000`</td></tr>
    <tr><td>`container_id` required</td><td>string</td><td>path</td><td>GTM container id, digits (not the GTM-XXXX public id). Example `12345678`</td></tr>

    <tr>
      <td>
        `pageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        nextPageToken from the previous answer.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2/accounts.containers.workspaces/list)

```python Python theme={null}
router.call_data_api("google-tag-manager.workspaces.list", {'account_id': '6000000000', 'container_id': '12345678'})
```

```text MCP theme={null}
call_data_api(endpoint="google-tag-manager.workspaces.list", params={"account_id": "6000000000", "container_id": "12345678"})
```

### List tags in a workspace

GET

`/accounts/{account_id}/containers/{container_id}/workspaces/{workspace_id}/tags`

`google-tag-manager.tags.list`

All tags of a workspace with type, parameters and firing triggers.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`account_id` required</td><td>string</td><td>path</td><td>GTM account id, digits. Example `6000000000`</td></tr>
    <tr><td>`container_id` required</td><td>string</td><td>path</td><td>GTM container id, digits (not the GTM-XXXX public id). Example `12345678`</td></tr>
    <tr><td>`workspace_id` required</td><td>string</td><td>path</td><td>GTM workspace id; the default workspace is usually 1 or 2 - list workspaces to find it. Example `2`</td></tr>

    <tr>
      <td>
        `pageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        nextPageToken from the previous answer.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2/accounts.containers.workspaces.tags/list)

```python Python theme={null}
router.call_data_api("google-tag-manager.tags.list", {'account_id': '6000000000', 'container_id': '12345678', 'workspace_id': '2'})
```

```text MCP theme={null}
call_data_api(endpoint="google-tag-manager.tags.list", params={"account_id": "6000000000", "container_id": "12345678", "workspace_id": "2"})
```

### Get one tag

GET

`/accounts/{account_id}/containers/{container_id}/workspaces/{workspace_id}/tags/{tag_id}`

`google-tag-manager.tags.get`

One tag of a workspace by id.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`account_id` required</td><td>string</td><td>path</td><td>GTM account id, digits. Example `6000000000`</td></tr>
    <tr><td>`container_id` required</td><td>string</td><td>path</td><td>GTM container id, digits (not the GTM-XXXX public id). Example `12345678`</td></tr>
    <tr><td>`workspace_id` required</td><td>string</td><td>path</td><td>GTM workspace id; the default workspace is usually 1 or 2 - list workspaces to find it. Example `2`</td></tr>
    <tr><td>`tag_id` required</td><td>string</td><td>path</td><td>GTM tag id. Example `14`</td></tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2/accounts.containers.workspaces.tags/get)

```python Python theme={null}
router.call_data_api("google-tag-manager.tags.get", {'account_id': '6000000000', 'container_id': '12345678', 'workspace_id': '2', 'tag_id': '14'})
```

```text MCP theme={null}
call_data_api(endpoint="google-tag-manager.tags.get", params={"account_id": "6000000000", "container_id": "12345678", "workspace_id": "2", "tag_id": "14"})
```

### List triggers in a workspace

GET

`/accounts/{account_id}/containers/{container_id}/workspaces/{workspace_id}/triggers`

`google-tag-manager.triggers.list`

All triggers of a workspace.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`account_id` required</td><td>string</td><td>path</td><td>GTM account id, digits. Example `6000000000`</td></tr>
    <tr><td>`container_id` required</td><td>string</td><td>path</td><td>GTM container id, digits (not the GTM-XXXX public id). Example `12345678`</td></tr>
    <tr><td>`workspace_id` required</td><td>string</td><td>path</td><td>GTM workspace id; the default workspace is usually 1 or 2 - list workspaces to find it. Example `2`</td></tr>

    <tr>
      <td>
        `pageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        nextPageToken from the previous answer.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2/accounts.containers.workspaces.triggers/list)

```python Python theme={null}
router.call_data_api("google-tag-manager.triggers.list", {'account_id': '6000000000', 'container_id': '12345678', 'workspace_id': '2'})
```

```text MCP theme={null}
call_data_api(endpoint="google-tag-manager.triggers.list", params={"account_id": "6000000000", "container_id": "12345678", "workspace_id": "2"})
```

### List variables in a workspace

GET

`/accounts/{account_id}/containers/{container_id}/workspaces/{workspace_id}/variables`

`google-tag-manager.variables.list`

All user-defined variables of a workspace.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`account_id` required</td><td>string</td><td>path</td><td>GTM account id, digits. Example `6000000000`</td></tr>
    <tr><td>`container_id` required</td><td>string</td><td>path</td><td>GTM container id, digits (not the GTM-XXXX public id). Example `12345678`</td></tr>
    <tr><td>`workspace_id` required</td><td>string</td><td>path</td><td>GTM workspace id; the default workspace is usually 1 or 2 - list workspaces to find it. Example `2`</td></tr>

    <tr>
      <td>
        `pageToken`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        nextPageToken from the previous answer.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://developers.google.com/tag-platform/tag-manager/api/reference/rest/v2/accounts.containers.workspaces.variables/list)

```python Python theme={null}
router.call_data_api("google-tag-manager.variables.list", {'account_id': '6000000000', 'container_id': '12345678', 'workspace_id': '2'})
```

```text MCP theme={null}
call_data_api(endpoint="google-tag-manager.variables.list", params={"account_id": "6000000000", "container_id": "12345678", "workspace_id": "2"})
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.