User tokens
User tokens are used to authenticate API requests to Windmill. Every interaction with the Windmill API requires a Bearer token. Tokens can be scoped to restrict access to specific resources and actions, following the principle of least privilege.
Create a token
You can generate tokens from the Account settings menu. Open it by clicking your username on the side menu, then select "Account settings".
- Enter a label to identify the token (labels help distinguish tokens in the list).
- Optionally set an expiration date. If your instance sets a maximum token expiration, the expiration can't go past it.
- Click New token to create a token with full access, or enable Limit token permissions to restrict the token to specific scopes.
You can only see the token once, when it is created. Make sure to store it securely.
Token scopes
By default, tokens inherit the full permissions of the user who created them. By enabling the Limit token permissions toggle, you can restrict a token to only the actions and resources it needs.

Selected scopes appear as badges at the top of the selector. Each domain (Jobs, Scripts, Flows, etc.) can be expanded to configure Read, Write, or Run permissions, and Jobs also has Cancel. Use the Restrict paths button to limit a scope to specific resource paths.
Scope format
Scopes follow the format:
{domain}:{action}[:{resource_path}]
- domain: the resource category (e.g.
scripts,flows,jobs,resources) - action:
read,write, or, for jobs,runandcancel - resource_path (optional): restrict access to specific paths, with wildcard support
Examples:
| Scope | Description |
|---|---|
scripts:read | Read access to all scripts |
scripts:write:f/production/* | Write access to scripts in the f/production/ folder |
jobs:run:scripts:u/admin/my_script | Run a specific script |
jobs:run:flows | Run any flow |
jobs:read:f/production/* | Read the runs of the scripts, flows and AI agents in the f/production/ folder |
jobs:run:dependencies:f/production/* | Generate dependency locks for scripts, flows and apps in f/production/ |
jobs:cancel:f/production/* | Cancel the runs in the f/production/ folder, and nothing else |
resources:read:u/user/* | Read resources owned by u/user/ |
A write scope automatically includes read access for the same domain and resource.
Available scope domains
All domains support read and write actions. The Jobs domain additionally supports run:scripts, run:flows, run:agents (running a saved AI agent, created from the agent's webhook panel rather than offered in the selector), run:dependencies (shown as Generate dependency locks in the selector) and cancel.
Domains with path restriction support: scripts, flows, apps, raw_apps, resources, variables, schedules, folders, jobs (for read, run and cancel), and all trigger types (http_triggers, websocket_triggers, kafka_triggers, nats_triggers, mqtt_triggers, sqs_triggers, gcp_triggers, postgres_triggers).
Domains without path restriction: users, groups, workspaces, audit, workers, settings, service_logs, configs, oauth, ai, agent_workers, drafts, favorites, inputs, job_helpers, openapi, capture, concurrency_groups, oidc, acls, indexer, teams, git_sync.
Resource path patterns
For scopes that support it, you can restrict access to specific resource paths using the Restrict paths button in the scope selector. Wildcards are supported:
| Pattern | Matches |
|---|---|
u/admin/my_script | Exact path only |
u/admin/* | All resources under u/admin/ |
f/production/* | All resources in the f/production/ folder |
| (omitted) | All resources in the domain |
Multiple paths can be combined with commas: scripts:read:f/production/*,f/staging/*.
Since Windmill 1.825.0, a jobs:read scope with paths only reads the runs of the deployed scripts, flows and AI agents at those paths and the jobs started under them, such as the steps of a flow; any other job answers 404.
The job lists return only the top-level script and flow runs at those paths, and the job routes that aggregate over the workspace or issue a link or token for a job are refused with a 403.
Previews are not readable, and a token that also holds jobs:write is not restricted.
jobs:cancel grants canceling jobs, force cancel included, and no read or other job write; with paths it matches jobs the same way as jobs:read.
HTTP triggers and tokens
When calling an HTTP trigger with Windmill Auth, the token must have http_triggers:read access to the trigger path. For example, a scoped token calling an HTTP route at my_route needs http_triggers:read:my_route.
When configuring an HTTP trigger with Windmill Auth, you can generate a pre-scoped token directly from the trigger configuration page. See Token scopes for HTTP routes for details.
CLI and git sync
The Windmill CLI (wmill sync push/pull) and the GitHub Action git sync authenticate with a user token. The simplest choice is an unscoped token (full user permissions).
If you prefer a scoped token, sync needs read and write on every domain it touches:
users:readis always required — the CLI callswhoamion startup, so this is the first scope check that fires.folders,scripts,flows,apps(andraw_appsif you have raw apps),resources—readandwrite.variables,schedules—readandwrite, when those are not skipped inwmill.yaml.- All trigger domains (
http_triggers,websocket_triggers,kafka_triggers,nats_triggers,mqtt_triggers,sqs_triggers,gcp_triggers,azure_triggers,postgres_triggers,email_triggers,native_triggers) —readandwrite, whenincludeTriggers: true. users:write,groups:read,groups:write— only when syncing users or groups.
Generating locks with wmill generate-metadata also needs jobs:run:dependencies.
Treat this scope like a run scope: installing a package can run its build or install scripts on a worker.
The git_sync scope governs the git-sync trigger configuration endpoints (the integration set up in the workspace UI), not the CLI sync operation itself.
Webhook-specific tokens
Webhooks can generate tokens that are pre-scoped to only trigger a specific script or flow. These tokens cannot impersonate you for any other operation, making them safe to share publicly.
Using tokens
Bearer authentication
Include the token in the Authorization header:
curl -H "Authorization: Bearer <TOKEN>" \
https://your-windmill-instance.com/api/w/<workspace>/jobs/run/p/<script_path>
Query parameter
Alternatively, pass the token as a query parameter:
https://your-windmill-instance.com/api/w/<workspace>/jobs/run/p/<script_path>?token=<TOKEN>
From scripts
Within Windmill scripts, an ephemeral token for the current job is available as the WM_TOKEN environment variable. It can be used to call the Windmill API directly, for example to fetch variables or resources. The TypeScript, Python, and Rust client libraries load it automatically, so you typically don't need to handle it yourself.
Restricted job tokens
By default, WM_TOKEN has the full permissions of the identity the job runs as.
For code that handles untrusted input, such as an AI agent, toggle Restrict the job token in the settings of the script, flow or flow step and select the scopes its jobs keep.
In script.yaml, flow.yaml or a flow step, this is the job_token_scopes key, e.g. job_token_scopes: ["oidc:write"] to only allow minting an OIDC token; with no scope ([]), the token can only reach its own job.
Jobs created by a restricted job (flow steps, AI agent tools, workflow as code children, and jobs it starts through the API) keep only the scopes both it and their own setting allow, so a step setting can only narrow its flow's. Schedules, triggers and error handlers apply only the target's own setting.
Everything the job fetches through Windmill needs a scope: variables:read and resources:read for $var:/$res: inputs and an AI agent's provider resource, scripts:read for relative imports, resources:write for script state, job_helpers:read/write for object storage.
mcp: scopes are refused.
A write scope on scripts, flows, schedules or triggers lets a job escape its restriction by deploying something that runs unrestricted.
The editor's Test button does not apply the script or flow setting, and a restricted job never runs on a dedicated worker.
Keep every worker and server on 1.822.0 or later: an older worker ignores the setting, which an OIDC consumer can detect with the job_token_scopes claim.
Maximum token expiration
Superadmins can cap how long user tokens live with the "Maximum token expiration (days)" instance setting (max_token_expiration_days), a whole number of days.
Leave it empty for no limit.
The limit applies to tokens created from Account settings, the CLI (including browser login with wmill workspace add) and the API.
A token requested with no expiration, or with one past the limit, is created with the limit as its expiration instead of being refused.
The limit is checked when a token is created, so setting or lowering it does not change existing tokens.
The limit does not apply to:
- Tokens of service accounts, so automation can keep long-lived credentials.
- Tokens Windmill creates on its own, such as login sessions, integration trigger webhook tokens and app embed tokens.
Managing tokens
From the Account settings page, you can view all your tokens with their labels, scopes, and expiration dates. Tokens can be revoked at any time by deleting them from the list.
CLI token creation
You can also create tokens using the Windmill CLI:
wmill user create-token