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

# Access Tokens

> Learn how to create scoped access tokens that act as a User or Service User with the ngrok agent, the ngrok API, and the MCP server.

## Overview

An access token is a credential that acts as its owner, a [User](https://ngrok.com/docs/iam/users.md) or a [Service User](https://ngrok.com/docs/iam/service-users.md), and can do only what its scopes allow.
Use access tokens for anything that automates ngrok: agents, CI jobs, scripts, and AI agents that connect through the [ngrok MCP server](https://ngrok.com/docs/mcp-server.md).

One access token works with:

* The ngrok agent, in place of an authtoken.
* The [ngrok API](https://ngrok.com/docs/api.md), in place of an API key.
* The `ngrok api` CLI commands.
* The [ngrok MCP server](https://ngrok.com/docs/mcp-server.md).

You can see and manage your access tokens on the [Access Tokens](https://dashboard.ngrok.com/access-tokens) page of the dashboard.

## Access tokens, authtokens, and API keys

ngrok has three kinds of credentials for automation.
Use access tokens for everything new.
Your existing authtokens and API keys keep working as they do today.

| | Access token | [Authtoken](https://ngrok.com/docs/gateway/agent/authtokens.md) | [API key](https://ngrok.com/docs/api.md#authentication) |
| - | - | - | - |
| Works with | Agent, API, `ngrok api`, MCP server | Agent | API, `ngrok api` |
| Limits what it can do | Scopes you choose | [ACLs](https://ngrok.com/docs/gateway/agent/authtokens.md#authtoken-acls) on agent binds | None |
| Limited by the owner's role | Yes | No | No |
| Expires | Optional, set when you create it | No | No |
| Value starts with | `ngrok_pat_` | No fixed prefix | No fixed prefix |

## Create an access token

1. In the dashboard, go to [Access Tokens](https://dashboard.ngrok.com/access-tokens) and click **New Access Token**.
2. Enter a description, such as the job or machine that uses the token.
3. If you're an Administrator, choose the owner: yourself, another User, or a Service User.
   Other Users can create tokens only for themselves.
4. Choose when the token expires: 30 days, 60 days, 90 days, 1 year (the default), or **Indefinite**.
   You can't change the expiration later.
5. Choose the token's [scopes](#scopes):
   * **Full access** grants every scope the owner has.
   * **Read-only** grants every `read` scope the owner has.
   * **Custom** lets you pick scopes one by one.
     Use **Quick select** to add the scopes for a product, such as the Kubernetes Operator or Ship.
6. Save the token, then copy its value.
   The dashboard shows the value only once.

> [!WARNING]
>
> Store the token the way you store other secrets, such as in a secrets manager or an environment variable.
> Anyone who has the value can act as the token's owner, within its scopes.

To create a token with the API, send `POST /access_tokens`.
The API creates tokens for the caller only.

## Use an access token with the agent

The agent accepts an access token anywhere it accepts an authtoken.
The token needs the `tunnel:start` scope.

1. Save the token to your agent configuration file:

   ```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
   ngrok config add-authtoken ngrok_pat_<your-token>
   ```

   You can also set the `NGROK_AUTHTOKEN` environment variable instead.

2. Start an endpoint:

   ```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
   ngrok http 80
   ```

3. Confirm that the agent shows `Session Status online` and an endpoint URL.

## Use an access token with the API

Send the token as a bearer token, the same way you send an API key:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl \
  -H "Authorization: Bearer $NGROK_ACCESS_TOKEN" \
  -H "Ngrok-Version: 2" \
  https://api.ngrok.com/endpoints
```

A token with `endpoints:read` gets a `200 OK` response with the list of your endpoints.

The `ngrok api` CLI commands take the token through the `--api-key` flag or the `NGROK_API_KEY` environment variable:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
ngrok api endpoints list --api-key $NGROK_ACCESS_TOKEN
```

To connect an AI agent with an access token, see [Clients without OAuth](https://ngrok.com/docs/mcp-server.md#clients-without-oauth).

## Scopes

Scopes decide what an access token can do.
Each scope names a resource and an action, such as `endpoints:read` or `domains:write`.

A token can use a scope only while its owner's [role](https://ngrok.com/docs/iam/rbac.md) also allows it.
If the owner's role changes, the token loses any scope the new role doesn't allow, without an edit to the token.
When you create or edit a token, you can grant only the scopes that both you and the token's owner have.

Most resources have a `read` scope, to view them, and a `write` scope, to create, change, and delete them.
A few have other actions:

* `tunnel:start` lets the agent start endpoints.
* `tunnel-sessions:manage` lets the token restart, update, and stop agent sessions.
* `gateway:endpoints:connect` lets the token connect to private endpoints.

The tables below list the scopes, grouped by area.

### Endpoints and traffic

| Resource | Scopes | What it covers |
| - | - | - |
| Agent ingresses | `agent-ingresses:read`, `agent-ingresses:write` | Custom ingress addresses agents connect through. |
| Agents | `agents:read`, `agents:write`, `agents:manage` | ngrok agents connected to your account. |
| Endpoints | `endpoints:read`, `endpoints:write`, `endpoints:admin` | Cloud Endpoints and Agent Endpoints serving your traffic. |
| Private endpoints | `gateway:endpoints:connect` | Connections to private endpoints. |
| Kubernetes Operators | `kubernetes-operators:read`, `kubernetes-operators:write` | Kubernetes Operators managing ngrok resources in your clusters. |
| Networks | `networks:read`, `networks:write` | Private networks and the peers that join them. |
| TCP addresses | `tcp-addrs:read`, `tcp-addrs:write` | Reserved TCP addresses. |
| Tunnel sessions | `tunnel-sessions:read`, `tunnel-sessions:manage` | Agent sessions backing your tunnels. |
| Tunnels | `tunnels:read`, `tunnel:start` | Active tunnels established by your agents. |

### Domains and certificates

| Resource | Scopes | What it covers |
| - | - | - |
| Certificate authorities | `certificate-authorities:read`, `certificate-authorities:write` | Certificate authorities used for mutual TLS. |
| Domains | `domains:read`, `domains:write`, `domains:write:certificates` | Reserved domains pointed at your endpoints. |
| TLS certificates | `tls-certificates:read`, `tls-certificates:write` | Uploaded TLS certificates. |

### SSH

| Resource | Scopes | What it covers |
| - | - | - |
| SSH certificate authorities | `ssh-certificate-authorities:read`, `ssh-certificate-authorities:write` | Authorities that sign SSH certificates. |
| SSH credentials | `ssh-credentials:read`, `ssh-credentials:write` | SSH public keys authorized to connect agents. |
| SSH host certificates | `ssh-host-certificates:read`, `ssh-host-certificates:write` | Certificates identifying your SSH hosts. |
| SSH user certificates | `ssh-user-certificates:read`, `ssh-user-certificates:write` | Certificates identifying SSH users. |

### Identity and access

| Resource | Scopes | What it covers |
| - | - | - |
| API keys | `api-keys:read`, `api-keys:write` | API keys used against the ngrok API. |
| App sessions | `app-sessions:read`, `app-sessions:write` | Active end-user sessions on your endpoints. |
| App users | `app-users:read`, `app-users:write` | End users authenticating through your endpoints. |
| Bot users | `bot-users:read`, `bot-users:write` | Legacy bot user principals. |
| Credentials | `credentials:read`, `credentials:write` | Agent authtokens and access tokens. |
| SCIM provisioning | `scim:read`, `scim:write` | Automatic user provisioning from your identity provider. |
| Service users | `service-users:read`, `service-users:write` | Non-human principals that own automation credentials. |
| Team | `team:read`, `team:write` | Team membership. |
| Team invitations | `ngrok:invitations:write` | Invitations to join your account. |
| Vaults | `vaults:read`, `vaults:write` | Secret vaults available to Traffic Policy. |

### Security and policy

| Resource | Scopes | What it covers |
| - | - | - |
| Abuse reports | `abuse-reports:read`, `abuse-reports:write` | Abuse reports filed against your endpoints. |
| IP policies | `ip-policies:read`, `ip-policies:write` | Reusable allow and deny IP rule sets. |
| IP restrictions | `ip-restrictions:read`, `ip-restrictions:write` | IP policies applied to dashboard and API access. |

### Observability and billing

| Resource | Scopes | What it covers |
| - | - | - |
| Billing | `billing:read`, `billing:write` | Subscription, invoices, and payment method. |
| Events | `events:read`, `events:write` | Event subscriptions and destinations. |
| Limits | `ngrok:limits:read` | Your plan's limits. |
| Notifications | `ngrok:notifications:read`, `ngrok:notifications:write` | Notifications in the dashboard. |
| Usage | `ngrok:usage:read` | Your account's usage. |

### Apps and integrations

| Resource | Scopes | What it covers |
| - | - | - |
| Chatbot | `chatbot:read`, `chatbot:write` | The AI chat agent and its connected Slack workspaces. |
| Integrations | `integrations:read`, `integrations:write` | Third-party services connected to your account. |
| Ship apps | `ship:apps:read`, `ship:apps:write` | Container apps deployed and run by Ship. |

## Missing scopes

When a token calls the API without a scope it needs, the API returns `403 Forbidden` with [ERR\_NGROK\_29001](https://ngrok.com/docs/errors/err_ngrok_29001.md) and names the missing scope:

```http theme={"theme":{"light":"css-variables","dark":"css-variables"}}
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope", scope="endpoints:write"

{
  "error_code": "ERR_NGROK_29001",
  "status_code": 403,
  "msg": "You don't have permission to perform this action. Your credentials are missing the 'endpoints:write' scope.",
  "details": {
    "operation_id": "op_2RfSBcv0nsy71XCHWOegjx1OoKh"
  }
}
```

When an agent starts with a token that doesn't have `tunnel:start`, the agent fails with [ERR\_NGROK\_15014](https://ngrok.com/docs/errors/err_ngrok_15014.md).

To fix either error, [edit the token](#manage-access-tokens) and add the scope.
If you can't add it, the token's owner doesn't have it.
Ask an Administrator for a [role](https://ngrok.com/docs/iam/rbac.md) that grants it.

## Manage access tokens

Open a token from the [Access Tokens](https://dashboard.ngrok.com/access-tokens) page to change it:

* **Edit** changes the description and the scopes.
  You can't change a token's owner or expiration.
  Create a new token instead.
* **Revoke** stops the token from working.
  The token stays in the list, marked revoked, so you keep its record.
* **Delete** stops the token from working and removes it from the list.

The API has the same actions: `PATCH /access_tokens/{id}`, `POST /access_tokens/{id}/revoke`, and `DELETE /access_tokens/{id}`.

Who can see and change tokens:

* Anyone with `credentials:read` sees every access token in the account.
  This includes Users whose [Developer](https://ngrok.com/docs/iam/rbac.md#developer) role is Read-only.
* To change a token, you need `credentials:write` and you must be its owner or an Administrator ([ERR\_NGROK\_256](https://ngrok.com/docs/errors/err_ngrok_256.md)).
* Only Administrators can create tokens for another User or a Service User ([ERR\_NGROK\_257](https://ngrok.com/docs/errors/err_ngrok_257.md)).

## Revocation and expiration

A token stops working when you revoke or delete it, when it expires, or when its owner is removed from the account or suspended.
Agents using the token disconnect, and API and MCP calls with it fail, within about two minutes.

Removing a User from the account, or deleting a Service User, also deletes their access tokens.

Role changes take effect in the same window.
If an owner loses a role, their tokens lose the scopes that role granted.

## Limits

Each owner can have up to 10,000 active access tokens.
Creating more fails with [ERR\_NGROK\_29000](https://ngrok.com/docs/errors/err_ngrok_29000.md).
Revoke or delete tokens you no longer use.

Access token values start with `ngrok_pat_`, followed by 43 letters and numbers.
Secret scanners can use this prefix to find leaked tokens.

## Troubleshooting

* **The token owner has no role that grants access:** The owner has no role, so the token can't do anything.
  Give the owner a [role](https://ngrok.com/docs/iam/rbac.md), then try again.
* **The agent fails with [ERR\_NGROK\_107](https://ngrok.com/docs/errors/err_ngrok_107.md):** The token is revoked, deleted, or expired, or it was copied wrong.
  Create a new token and update your configuration.
* **The API fails with [ERR\_NGROK\_203](https://ngrok.com/docs/errors/err_ngrok_203.md):** The token is revoked, deleted, or expired, or it was copied wrong.
  Create a new token and update the `Authorization` header.
* **The API or agent says a scope is missing:** See [Missing scopes](#missing-scopes).

## Access tokens pricing

Access tokens are available on all plans.
For more information, see the [ngrok Pricing page](https://ngrok.com/pricing).

## What's next?

* Learn how roles limit tokens in [Role-Based Access Control](https://ngrok.com/docs/iam/rbac.md).
* Create tokens for automation that outlives any one person with [Service Users](https://ngrok.com/docs/iam/service-users.md).
* Connect an AI agent to your account with the [ngrok MCP server](https://ngrok.com/docs/mcp-server.md).
* Manage tokens programmatically with the [Access Tokens API](https://ngrok.com/docs/api-reference/accesstokens/list.md).


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