Secrets Store
Interact with Secret Store using Wrangler.
Use the following commands to manage your account secrets.
Create a secret within a store
npx wrangler secrets-store secret create [STORE-ID]pnpm wrangler secrets-store secret create [STORE-ID]yarn wrangler secrets-store secret create [STORE-ID]-
[STORE-ID]string requiredID of the store in which the secret resides
-
--namestring requiredName of the secret
-
--valuestringValue of the secret (Note: Only for testing. Not secure as this will leave secret value in plain-text in terminal history, exclude this flag and use automatic prompt instead)
-
--scopesstring requiredScopes for the secret (comma-separated list of scopes eg:"workers")
-
--commentstringComment for the secret
-
--remoteboolean default: falseExecute command against remote Secrets Store
-
--persist-tostringDirectory for local persistence
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
The following is an example of using the create command to create an account-level secret.
npx wrangler secrets-store secret create 8f7a1cdced6342c18d223ece462fd88d --name ServiceA_key-1 --scopes workers --remoteโ Enter a secret value: โบ ***
๐ Creating secret... (Name: ServiceA_key-1, Value: REDACTED, Scopes: workers, Comment: undefined)โ Select an account: โบ My accountโ
Created secret! (ID: 13bc7498c6374a4e9d13be091c3c65f1)Update a secret within a store
npx wrangler secrets-store secret update [STORE-ID]pnpm wrangler secrets-store secret update [STORE-ID]yarn wrangler secrets-store secret update [STORE-ID]-
[STORE-ID]string requiredID of the store in which the secret resides
-
--secret-idstring requiredID of the secret to update
-
--valuestringUpdated value of the secret (Note: Only for testing. Not secure as this will leave secret value in plain-text in terminal history, exclude this flag and use automatic prompt instead)
-
--scopesstringUpdated scopes for the secret (comma-separated list of scopes eg:"workers")
-
--commentstringUpdated comment for the secret
-
--remoteboolean default: falseExecute command against remote Secrets Store
-
--persist-tostringDirectory for local persistence
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Duplicate a secret within a store
npx wrangler secrets-store secret duplicate [STORE-ID]pnpm wrangler secrets-store secret duplicate [STORE-ID]yarn wrangler secrets-store secret duplicate [STORE-ID]-
[STORE-ID]string requiredID of the store in which the secret resides
-
--secret-idstring requiredID of the secret to duplicate the secret value of
-
--namestring requiredName of the new secret
-
--scopesstring requiredScopes for the new secret
-
--commentstringComment for the new secret
-
--remoteboolean default: falseExecute command against remote Secrets Store
-
--persist-tostringDirectory for local persistence
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Get a secret within a store
npx wrangler secrets-store secret get [STORE-ID]pnpm wrangler secrets-store secret get [STORE-ID]yarn wrangler secrets-store secret get [STORE-ID]-
[STORE-ID]string requiredID of the store in which the secret resides
-
--secret-idstring requiredID of the secret to retrieve
-
--remoteboolean default: falseExecute command against remote Secrets Store
-
--persist-tostringDirectory for local persistence
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
The following is an example with the expected output:
npx wrangler secrets-store secret get 8f7a1cdced6342c18d223ece462fd88d --secret-id 13bc7498c6374a4e9d13be091c3c65f1 --remote๐ Getting secret... (ID: 13bc7498c6374a4e9d13be091c3c65f1)โ Select an account: โบ My account| Name | ID | StoreID | Comment | Scopes | Status | Created | Modified ||-----------------------------|-------------------------------------|-------------------------------------|---------|---------|---------|------------------------|------------------------|| ServiceA_key-1 | 13bc7498c6374a4e9d13be091c3c65f1 | 8f7a1cdced6342c18d223ece462fd88d | | workers | active | 4/9/2025, 10:06:01 PM | 4/15/2025, 09:13:05 AM |Delete a secret within a store
npx wrangler secrets-store secret delete [STORE-ID]pnpm wrangler secrets-store secret delete [STORE-ID]yarn wrangler secrets-store secret delete [STORE-ID]-
[STORE-ID]string requiredID of the store in which the secret resides
-
--secret-idstring requiredID of the secret to delete
-
--remoteboolean default: falseExecute command against remote Secrets Store
-
--persist-tostringDirectory for local persistence
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
List secrets within a store
npx wrangler secrets-store secret list [STORE-ID]pnpm wrangler secrets-store secret list [STORE-ID]yarn wrangler secrets-store secret list [STORE-ID]-
[STORE-ID]string requiredID of the store in which to list secrets
-
--pagenumber default: 1Page number of secrets listing results, can configure page size using "per-page"
-
--per-pagenumber default: 10Number of secrets to show per page
-
--remoteboolean default: falseExecute command against remote Secrets Store
-
--persist-tostringDirectory for local persistence
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Use the following commands to manage your store.
Create a store within an account
npx wrangler secrets-store store create [NAME]pnpm wrangler secrets-store store create [NAME]yarn wrangler secrets-store store create [NAME]-
[NAME]string requiredName of the store
-
--remoteboolean default: falseExecute command against remote Secrets Store
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
The following is an example of using the create command to create a store.
npx wrangler secrets-store store create default --remote๐ Creating store... (Name: default)โ
Created store! (Name: default, ID: 2e2a82d317134506b58defbe16982d54)Delete a store within an account
npx wrangler secrets-store store delete [STORE-ID]pnpm wrangler secrets-store store delete [STORE-ID]yarn wrangler secrets-store store delete [STORE-ID]-
[STORE-ID]string requiredID of the store
-
--remoteboolean default: falseExecute command against remote Secrets Store
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
The following is an example of using the delete command to delete a store.
npx wrangler secrets-store store delete d2dafaeac9434de2b6d08b292ce08211 --remote๐ Deleting store... (Name: d2dafaeac9434de2b6d08b292ce08211)โ
Deleted store! (ID: d2dafaeac9434de2b6d08b292ce08211)List stores within an account
npx wrangler secrets-store store listpnpm wrangler secrets-store store listyarn wrangler secrets-store store list-
--pagenumber default: 1Page number of stores listing results, can configure page size using "per-page"
-
--per-pagenumber default: 10Number of stores to show per page
-
--remoteboolean default: falseExecute command against remote Secrets Store
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
The following is an example of using the list command to list stores.
npx wrangler secrets-store store list --remote๐ Listing stores...โโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ Name โ ID โ AccountID โ Created โ Modified โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโคโ default โ 8876bad33f164462bf0743fe8adf98f4 โ REDACTED โ 4/9/2025, 1:11:48 PM โ 4/9/2025, 1:11:48 PM โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโ