# Netlify API tokens: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/netlify
Last checked: 2026-10-25

Netlify personal access tokens are created under Applications → Personal access tokens (app.netlify.com/user/applications#personal-access-tokens) with New access token. You set an expiration, and the token cannot be viewed again after you leave the page. In CI, store it as `NETLIFY_AUTH_TOKEN`.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Personal access token (PAT) | — | Yes | Your user's access to Netlify; denied SAML-based team access unless you tick the SAML option when generating | You select an expiration date when generating |
| OAuth application client secret | — | Yes | Users authorize your app via OAuth2 | — |

## How to create a Netlify key

1. Go to **Applications** → **Personal access tokens**.
2. Select **New access token** and enter a descriptive name.
3. Optionally select **Allow access to my SAML-based Netlify team**.
4. Select an **Expiration** date, then **Generate token**.
5. Copy the token and store it safely, then select **Done**.

## Limiting what the key can do

Netlify personal access tokens have no scope selector; they act as your user. Narrow exposure by setting a short expiration, and by using a dedicated user for automation. Teams that require SAML SSO deny PATs team access by default unless you select the SAML option while logged in with SSO.

## How to rotate a Netlify key

1. Generate a new personal access token.
2. Update `NETLIFY_AUTH_TOKEN` in your CI and local environments.
3. Delete the old token under **Personal access tokens** → **Options** → **Delete personal token**.

## How to revoke a Netlify key

1. Go to **Applications** → **Personal access tokens**.
2. Choose **Options** → **Delete personal token** for the token.

## If the key leaked

1. Delete the exposed token under Personal access tokens.
2. Generate a replacement and update CI secrets.
3. Resetting your password invalidates all tokens created before the reset, if you cannot identify the exposed one.

## Environment variables

- `NETLIFY_AUTH_TOKEN`
- `NETLIFY_SITE_ID`

## Gotchas

- The token cannot be viewed again after you leave the generation page.
- `NETLIFY_SITE_ID` is the site's Project ID, found under Project configuration → General → Project details.
- A password reset invalidates every earlier PAT and OAuth token, which can silently break CI.

## Using this key with AI agents (BotPassword)

- `list_credentials`: Lists the credentials this agent is granted and what it may do with each. Never values.
- `run_with`: Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
- `http_request`: Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
- `cli_login`: Lets git, Docker, the AWS CLI and kubectl log in through bpw's credential helper, so the token is fetched when the tool needs it and not written into its config. The helper hands the value to the tool, so the grant is always disclosing. Other tools use run_with; OAuth device logins are planned.
- `rotate`: Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.
- `store_secret`: Saves a value the agent already holds as a new vault item.

## FAQ

### Where do I find my Netlify personal access token?

You can't view it after creation. Generate one at Applications → Personal access tokens and copy it before leaving the page.

### What is NETLIFY_AUTH_TOKEN?

It is the environment variable the Netlify CLI reads in CI, holding a personal access token.

### How do I delete a Netlify personal access token?

Under Personal access tokens choose Options → Delete personal token.

### Why did my Netlify tokens stop working?

Resetting your Netlify password permanently invalidates all personal access and OAuth tokens created before the reset.

### Can an AI agent use my Netlify key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a `.env` file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with `list_credentials`, `run_with`, `http_request`, so the agent gets the result and never the value.

## Sources

- https://docs.netlify.com/api-and-cli-guides/api-guides/get-started-with-api/
- https://docs.netlify.com/api-and-cli-guides/cli-guides/get-started-with-cli/
- https://docs.netlify.com/build/build-with-ai/netlify-mcp-server/
