Skip to main content

Overview

An access token is a credential that acts as its owner, a User or a Service User, 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. One access token works with:
  • The ngrok agent, in place of an authtoken.
  • The ngrok API, in place of an API key.
  • The ngrok api CLI commands.
  • The ngrok MCP server.
You can see and manage your access tokens on the 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.

Create an access token

  1. In the dashboard, go to 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:
    • 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.
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:
    You can also set the NGROK_AUTHTOKEN environment variable instead.
  2. Start an endpoint:
  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:
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:
To connect an AI agent with an access token, see 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 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

Domains and certificates

SSH

Identity and access

Security and policy

Observability and billing

Apps and integrations

Missing scopes

When a token calls the API without a scope it needs, the API returns 403 Forbidden with ERR_NGROK_29001 and names the missing scope:
When an agent starts with a token that doesn’t have tunnel:start, the agent fails with ERR_NGROK_15014. To fix either error, edit the token and add the scope. If you can’t add it, the token’s owner doesn’t have it. Ask an Administrator for a role that grants it.

Manage access tokens

Open a token from the 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 role is Read-only.
  • To change a token, you need credentials:write and you must be its owner or an Administrator (ERR_NGROK_256).
  • Only Administrators can create tokens for another User or a Service User (ERR_NGROK_257).

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. 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, then try again.
  • The agent fails with ERR_NGROK_107: 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: 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.

Access tokens pricing

Access tokens are available on all plans. For more information, see the ngrok Pricing page.

What’s next?