Secrets let your Notion Workers use API keys, tokens, client secrets, webhook signing secrets, and other credentials without committing those values to your source code. Notion encrypts worker secrets at rest and exposes them as environment variables at runtime. In your worker code, read them fromDocumentation Index
Fetch the complete documentation index at: https://developers.notion.com/llms.txt
Use this file to discover all available pages before exploring further.
process.env.
Add a secret
Usentn workers env set to store one or more secrets for your worker:
KEY=value pairs:
Use a secret in worker code
Read secrets fromprocess.env inside your worker capability:
Pull secrets for local development
When you run a worker locally, use a.env file to provide the same environment variables that the hosted worker receives.
Pull remote secrets into .env:
pull preserves comments, blank lines, and local-only keys. It updates keys that also exist remotely, then appends new remote keys.
For non-interactive scripts, add --yes to skip the confirmation prompt:
Push local secrets to your worker
If you’ve added secrets locally to.env, push them to the hosted worker:
push adds new local keys and updates changed local keys. It does not remove keys that exist only in the remote worker environment.
For non-interactive scripts, add --yes:
Manage another worker
When you run these commands inside a worker project, the CLI reads the worker ID fromworkers.json. To manage a different worker, pass its worker ID.
For set and unset, use --worker-id:
list, pull, and push, pass the worker ID as the positional argument:
Use secrets for OAuth client credentials
For custom OAuth providers, store the OAuth client ID and client secret as worker secrets:process.env in the OAuth capability configuration:
Command summary
| Command | What it does |
|---|---|
ntn workers env set KEY=value | Stores or replaces one or more secrets |
ntn workers env list | Lists secret keys without revealing values |
ntn workers env unset KEY | Removes a secret |
ntn workers env pull | Writes remote secrets to a local .env file |
ntn workers env push | Adds or updates remote secrets from a local .env file |