Skip to content
GitHubXDiscordRSS

Profiles

Set up multiple profiles for your Alchemy projects.

Alchemy profiles provide a simple way to manage credentials for cloud providers without juggling multiple .env files or separate login CLI commands.

To create (or update) a profile, run the alchemy configure command:

Terminal window
alchemy configure
# or select a specific profile
alchemy configure --profile prod

After configuring a profile, you can use the alchemy login command to refresh each provider’s credentials.

Terminal window
# log in to the default profile
alchemy login
# log in to a named profile
alchemy login --profile prod

To clear a profile’s credentials, run the alchemy logout command:

Terminal window
alchemy logout
# log out of a specific profile
alchemy logout --profile prod

The alchemy deploy, dev, run and destroy commands all support the --profile flag to specify which profile to use.

Terminal window
alchemy deploy --profile prod

You can override the profile using environment variables:

Terminal window
ALCHEMY_PROFILE=prod alchemy deploy

Or just a specific provider’s default profile (e.g. Cloudflare):

Terminal window
CLOUDFLARE_PROFILE=prod alchemy deploy

Resources that support profiles can also be configured individually:

import { Worker } from "alchemy/cloudflare";
const worker = await Worker("my-worker", {
profile: "prod",
});

You can also set the profile globally (for all resources in the App):

await alchemy("my-app", {
profile: "prod",
})

The profile configuration and credential files are stored in your ~/.alchemy directory:

Terminal window
# Configuration file (no sensitive data)
~/.alchemy/config.json
# Credentials file (sensitive data)
~/.alchemy/credentials/default/cloudflare.json

The alchemy configure command will create or update the config.json file with the profile configuration. No sensitive data is stored in this file.

For example, the below config.json contains two profiles each with a Cloudflare provider configured to use OAuth:

{
"version": 1,
"profiles": {
// The default profile
"default": {
"cloudflare": {
"method": "oauth",
"metadata": {
"id": "<account-id>",
"name": "<account-name>"
},
"scopes": [
"account:read",
"user:read",
"workers:write"
]
}
},
// A named profile (e.g. alchemy configure --profile prod)
"prod": {
"cloudflare": {
"method": "api-token",
"metadata": {
"id": "<account-id>",
"name": "<account-name>"
}
}
}
}
}

The alchemy login command will create or update the credentials/<profile>/<provider>.json file with the provider’s credentials.

For example, the below credentials/prod/cloudflare.json contains the OAUth access and refresh tokens for the Cloudflare provider configured in the prod profile:

{
"type": "oauth",
"access": "<access token>",
"refresh": "<refresh token>",
"expires": 1758577621359
}