Developer tools
Service tokens

Service tokens

Create service tokens and scope each one to the resources and environments it needs.

A service token authenticates requests to the Management API, CLI, and MCP server for resources under your Knock account. Service tokens start with knock_st_.

Service tokens are account-wide. Each token's access decides which resources it can use and which environments it can reach, so you can give a CI pipeline, a script, or an agent only what it needs.

Who can manage service tokens

#

To create, edit, or revoke service tokens, you need the owner or admin role, or a custom permission group that's allowed to manage service tokens.

A token takes the role of the member who creates it, and it can never hold a permission that role doesn't have. See what you can grant for how your role limits the access you give a token.

Create a service token

#
  1. Go to Settings > Service tokens and click New token.
  2. Enter a Name that says what the token is for.
  3. Choose an Expiration. See expiration for the options.
  4. Set the token's access. A new token starts as Restricted with Read only access in every environment.
  5. Click Create token.
  6. Copy the token from the dialog and store it somewhere secure. Knock shows the token only once. After you close the dialog, the dashboard opens the token's page, where you can review its access.

Choose a token's access

#

The Access control sets how much of the Management API the token can use:

  • Full access. If you're an owner, the token can use every Management API endpoint in every environment. For any other role, the token gets every permission you can grant, in every environment.
  • Restricted. The token can only do what you choose under Account access and Environment access.

A token with full access can change or delete anything, including in production. Use Restricted unless the token needs everything.

Each resource has access levels, and each level includes the ones before it. For example, Manage on workflows also grants Run and Read. Set a resource to None to leave it out.

Presets

#

The Account access card and each environment card offer two presets:

  • Read only. Grants the lowest level on each resource, so the token can read resources but not change them. It leaves out API keys, because an API key can trigger workflows through the Knock API.
  • Read and write. Grants the highest level on each resource, so the token can take actions like running workflows, promoting commits, and reading API keys.

Neither preset grants Environments, Billing, Agent sessions, or Manage on Members. Both grant Read on Members. Set those resources yourself if the token needs them.

When you change a single resource's level, the card shows Custom.

Account access

#

Account access applies across the whole account, not to one environment.

ResourceLevelsWhat it covers
AssetsRead, ManageUploaded assets.
TagsRead, ManageResource tags.
Preference categoriesRead, ManagePreference categories.
EnvironmentsManageCreate, update, and delete environments.
MembersRead, ManageAccount members.
Audit logsReadThe account audit log.
BillingReadBilling and usage.
Agent sessionsRead, ManageSessions with the Knock agent.

Environment access

#

Environment access sets what the token can do inside each environment:

  • All. The token has the same access in every environment, including environments created later.
  • Granular. You set access for each environment on its own card. An environment created later starts with no access until you grant it on the token's page.

If you've enabled environments, use Granular to give a token different access in each one, such as Read and write in development and Read only in production, or to keep a token out of production. A token's access in the development environment also applies on its branches.

Switching from All to Granular preserves each environment's current access until you update it. Switching from Granular to All gives every environment the narrowest access they share, so the switch never widens what an environment can do. The dashboard asks you to confirm before it applies the change.

Environment access covers these resources:

ResourceLevelsWhat it covers
WorkflowsRead, Run, ManageWorkflows and their steps. Run grants the ability to trigger workflows.
GuidesRead, ManageIn-app guides.
BroadcastsRead, ManageBroadcasts.
Email layoutsRead, ManageEmail layouts.
PartialsRead, ManageReusable template partials.
Message typesRead, ManageIn-app message types.
TranslationsRead, ManageTranslations.
Reusable stepsRead, ManageReusable workflow steps.
VariablesRead, ManageEnvironment variables.
AudiencesRead, ManageAudiences.
SchemasRead, Edit, ManageData schemas.
GoalsRead, ManageGoals.
Preference centersRead, ManagePreference center configuration.
Warehouse syncsRead, ManageWarehouse syncs.
ChannelsRead, ManageChannels and their settings in the environment.
SourcesRead, ManageSources and their settings in the environment.
Source mappingsRead, ManageMappings from source events to workflow actions. Saving a mapping also needs Run on workflows.
WebhooksRead, ManageOutbound webhooks.
CommitsRead, Commit, PromoteCommits in the environment. Promote promotes commits from this environment to the next.
BranchesRead, ManageBranches of development. Applies to the development environment only. Manage includes merging a branch.
Environment defaultsRead, ManageDefault settings for the environment.
API keysReadExchanging the service token for the environment's API keys.

What you can grant

#

Your own role limits the access you can give a token:

  • You can only grant permissions your role holds in each environment. The dashboard disables any level or preset you can't grant.
  • Only owners can give a token full access or grant Billing.
  • You can always narrow a token's access, even when it holds more than you could grant. When the token's role ranks above yours, such as an owner's token edited by an admin, narrowing is the only change you can make.

Change a token's access

#
  1. Go to Settings > Service tokens and click the token.
  2. On the Permissions tab, change the token's access.
  3. Click Save permissions.

The change takes effect immediately in every environment it touches, including production. The audit log records each change to a token's access.

The token's Details tab summarizes its access, such as "Read and write in Development, Read only in Production," and shows who created the token, when it expires, and when it was last used.

Insufficient access errors

#

When a token is used for a Management API, CLI, or MCP server action that it doesn't have access to, the request fails with a 403 and this message:

To fix it, change the token's access to include the resource and environment the request needs.

Expiration

#

Set a token's expiration when you create it: No expiration, 1 day, 7 days, 14 days, 30 days, 90 days, or a Custom date. A custom date runs to the end of that day and must be at least 24 hours away. The field's tip shows the exact time the token stops working.

You can't change a token's expiration after you create it. To extend access, create a new token and revoke the old one.

Once a token expires, its requests fail with a 401, and Knock agent runs can't authenticate with it. The token's page shows when it stopped working. For a token with no expiration, the page shows a warning that long-lived credentials are a security risk.

Revoke a service token

#
  1. Go to Settings > Service tokens.
  2. Open the token's three-dot menu and click Delete token.

Deleting a token revokes it immediately. From then on, requests that use it fail through the Management API, the CLI, and the MCP server.

Frequently asked questions

#

No. A service token authenticates the Management API, CLI, and MCP server, not the Knock API, which uses API keys. A token with Read on API keys can exchange itself for an environment's API keys.

Yes. Pass the token as a bearer credential in your MCP client config. See authenticate with a service token for more detail. The MCP server can only do what the token's access includes.

Changes made with a service token appear in the audit log with the token as the author, the same way dashboard changes show the member who made them. If you need help tracing a request back to a service token, contact our support team.

New chat