Cloudflare Setup

Creating your Cloudflare API token

EmailFlare needs a Cloudflare API token with specific Email Sending, DNS, and routing permissions. This guide walks through every step — from the API Tokens page to your .env.local file.

1

Open the API Tokens page

Go to dash.cloudflare.com/profile/api-tokens. Click Create Token and choose Create Custom Token at the bottom of the template list.

2

Name the token

Give it a descriptive name so you can identify it later — for example emailflare-deploy or emailflare-prod.

3

Add permissions

Under Permissions, add each row in the table below. For each permission, you select the resource type and the access level from dropdowns.

PermissionScopeAccess
Email SendingAccountEdit
Email SecurityAccountEdit
Workers ScriptsAccountEdit
Access: UsersAccountRead
Account SettingsAccountRead
Email Routing RulesZoneEdit
ZoneZoneRead
Zone SettingsZoneEdit
DNSZoneEdit
⚠️Zone Settings: Edit is the one most people miss.Enabling Email Routing (POST /zones/{id}/email/routing/enable) is gated by Zone Settings: Editnot by "Email Routing Rules". There is no obvious "Email Routing" entry in the permission list, so without Zone Settings: Edit the enable step fails with an authentication error even though everything else works.
💡Workers Scripts (Account · Edit) and Email Routing Rules (Zone · Edit)are required for the Bounce Forwarding feature — they let EmailFlare deploy the forwarder Worker and configure catch-all routing rules automatically from the Settings page. If you don't plan to use bounce forwarding you can omit those two.

DNS Edit is only needed if EmailFlare is managing your MX records automatically. If you handle DNS manually, DNS Read is sufficient.
4

Set the resource scope

Under Account Resources, set to your Cloudflare account. Under Zone Resources, you can either include all zones or restrict to a specific zone for the sending domain.

Account Resources
IncludeYour Account · yourname
Zone Resources
IncludeAll zones from account · yourname
💡For production, restrict Zone Resources to only the domain(s) you use for sending — this limits the blast radius if the token is ever compromised.
5

Create the token

Click Continue to summary, review the permissions, then click Create Token. Cloudflare will show you the token value once — copy it immediately.

⚠️You will not be able to see this token value again after leaving the page. Copy it now and store it securely — a password manager is ideal.
6

Find your Account ID

Go to dash.cloudflare.com, click any domain, and look at the right sidebar under API. Your Account ID is a 32-character hex string.

💡You can also find your Account ID in the URL when you're on the Cloudflare dashboard: dash.cloudflare.com/<account-id>/…
7

Add to your config

For Cloudflare Workers (primary), add the values to scripts/config.toml. For Docker self-hosting (secondary), add them to your .env.local.

.env.local (Docker)

CF_API_TOKEN=your_token_value_hereCF_ACCOUNT_ID=your_32_char_account_id

scripts/config.toml (Workers)

[deploy]cloudflare_api_token = "your_token_value_here"account_id = "your_32_char_account_id"
That's it. Run just worker-setup for Workers or docker compose up for Docker — EmailFlare will use these credentials for all Cloudflare API operations.

Continue setting up EmailFlare

Next steps after creating your API token.