Accounts and API tokens
Everything you deploy to Cloudflare lives in an account: Workers, KV namespaces, R2 buckets, D1 databases, queues and your zones. An account has members, the people who can sign in to it, each with roles that decide what they can change.
Sign in with a profile
Section titled “Sign in with a profile”Alchemy reaches an account through a profile. Add Cloudflare to your default profile:
alchemy profile edit --add CloudflareOAuth is the simplest choice: it opens your browser, you approve the scopes, and Alchemy refreshes the session for you. On the consent page, turn on Account API Token Provisioning, so Alchemy can mint scoped tokens for your Workers. If you’d rather manage credentials yourself, paste an API token instead.
If you belong to several accounts, the profile records which one to deploy into. See Setup.
Use one profile per account
Section titled “Use one profile per account”A stage decides what you deploy. A profile decides where. Keep production in its own account, with its own profile:
alchemy profile create prodalchemy profile edit --profile prod --add Cloudflarealchemy deploy --stage prod --profile prodMany stages can share the development account, each with its own Workers and storage.
API tokens: access narrower than yours
Section titled “API tokens: access narrower than yours”An API token carries a list of policies. Each policy grants permission groups, like Workers Scripts Write, on a set of resources: a whole account, one zone, or one Worker. A token can do only what its policies say, whoever created it.
Account-owned tokens belong to the account rather than to a person, so they keep working when someone leaves. Declare one in your Stack to give CI exactly what it needs:
const { accountId } = yield* yield* Cloudflare.CloudflareEnvironment;
const token = yield* Cloudflare.ApiToken.AccountApiToken("ci-token", { policies: [ { effect: "allow", permissionGroups: ["Workers Scripts Write", "Workers KV Storage Write"], resources: { [`com.cloudflare.api.account.${accountId}`]: "*" }, }, ],});token.value is an output. Pass it to whatever needs it, like a GitHub Actions secret, and no one copies it by hand.
Tokens your runtimes get for you
Section titled “Tokens your runtimes get for you”Most of the time a Worker reaches KV, R2 or a queue through a native binding, with no token at all. Code that runs elsewhere, like a Lambda Function or a Container, reaches the same resources over Cloudflare’s HTTP API. Its HTTP binding mints an account-owned token with only the permission groups that binding needs, and passes it to the runtime. That’s why OAuth asks for Account API Token Provisioning.
CI can’t open a browser. With CI=true, Alchemy reads credentials from the environment instead: CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN. See CI.
Values your Workers read, like a third-party API key, are covered in Secrets & env. Secrets shared by several Workers belong in the Secrets Store. To put sign-in in front of an app, see Access.