API Tokens

Secure tokens for API access and CI/CD deployments.

Overview

ZeroDeploy supports two types of API tokens:

Site Tokens

Site-scoped tokens that can only deploy and manage a specific site. Ideal for single-site CI/CD pipelines.

Org Tokens

Organization-scoped tokens that can deploy to any site within an org. Perfect for monorepos where one CI/CD pipeline deploys multiple sites.

Scope vs. Permissions

The token scope (site or org) controls which *sites* the token can access. Permissions control what actions the token can perform. Note that scope only restricts site-level operations — a site-scoped or org-scoped token with orgs:read can still list all your organizations.

Fine-Grained Permissions

Tokens use fine-grained permissions in resource:action format. By default, tokens get sites:read and deployments:write. Use --permissions to customize.

PermissionDescription
orgs:readList and view organizations
sites:readList and view sites
sites:writeCreate, update, delete sites (includes read)
deployments:readView deployments, files, logs
deployments:writeCreate deployments, upload, rollback (includes read)
domains:readList and view custom domains
domains:writeAdd, verify, delete custom domains (includes read)
forms:readList forms and view submissions
forms:writeUpdate and delete forms (includes read)
analytics:readView traffic analytics, goals, and funnels
analytics:writeCreate and delete goals and funnels (includes read)

Key rule: write always implies read. A token with sites:write can also read sites.

Benefits

token create

Create a new API token. You must specify either --org or --site to set the token scope.

Org Token

zerodeploy token create <name> --org <org>

Site Token

zerodeploy token create <name> --site <site>

OptionDescription
--org <org>Org slug (creates org-scoped token)
--site <slug>Site slug (creates site-scoped token)
--permissions <perms>Comma-separated permissions (e.g., sites:read,deployments:write)
--expires <days>Token expiration in days (default: never)
--jsonOutput as JSON for scripting
bash
# Create an org token for CI/CD (deploys to any site in org)
zerodeploy token create "GitHub Actions" --org my-org

# Create a site token
zerodeploy token create "GitHub Actions" --site my-website

# Create a token with specific permissions
zerodeploy token create "Read Only" --org my-org --permissions sites:read,deployments:read

# Create a token with custom permissions
zerodeploy token create "CI" --site my-site --permissions deployments:write,sites:read,domains:read

Important: Save the token immediately. It will not be shown again.

token list

List your API tokens.

zerodeploy token list

OptionDescription
--type <user|site|org>Filter by token type (user=PAT, site/org=deploy)
--site <slug>Filter by site slug
--org <slug>Filter by org slug
--jsonOutput as JSON for scripting
bash
# List all tokens
zerodeploy token list

# List only site deploy tokens
zerodeploy token list --type site

# List only org deploy tokens
zerodeploy token list --type org

# List only PATs
zerodeploy token list --type user

token delete

Delete an API token.

zerodeploy token delete <tokenId>

bash
zerodeploy token delete zd_abc12345

You can use the full token ID or the token prefix.

Using Tokens in CI/CD

GitHub Actions

For Single Sites (Site Deploy Token)

  1. Create a site deploy token: zerodeploy token create "GitHub Actions" --site <slug>
  2. Go to your repository Settings → Secrets and variables → Actions
  3. Click "New repository secret"
  4. Name: ZERODEPLOY_TOKEN
  5. Value: Paste the token

For Monorepos (Org Deploy Token)

  1. Create an org deploy token: zerodeploy token create "GitHub Actions" --org <org>
  2. Go to your repository Settings → Secrets and variables → Actions
  3. Click "New repository secret"
  4. Name: ZERODEPLOY_TOKEN
  5. Value: Paste the token

Org tokens can deploy to any site in the organization, making them ideal for monorepos.

Then use it in your workflow:

yaml
- name: Deploy
  env:
    ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}
  run: npx @zerodeploy/cli deploy --dir dist

Other CI Systems

Set the ZERODEPLOY_TOKEN environment variable in your CI system's secrets configuration. The CLI will automatically use it for authentication.

Security Best Practices