Pular para o conteúdo principal
informação
Esta página ainda não foi traduzida. Você está lendo a versão em English.

envshed import

Import secrets from a file or migrate directly from another secrets platform.

Usage​

terminal
envshed import <file> [options] # from a file
envshed import --from doppler [options] # from Doppler

Supported file formats: .env, .json, .yaml, .yml, .csv. The format is auto-detected from the file extension; .env.production, .env.local and other .env.<name> files are read as env files. Use --format to override.

Setting up a project that already has .env files? envshed init finds them and imports each one into the right environment in a single step.

Supported external sources for --from: doppler. See Migrate from Doppler for the full walkthrough.

Moving a project with a coding agent? See Migrate with an agent: the agent plans and imports by key name and never sees a value.

Options​

OptionDescription
<file>Path to the file to import (omit when using --from)
--format <format>Format override: env, json, yaml, csv
--dry-runPrint the plan (key names only) without writing anything
--on-conflict <policy>What to do with keys that already exist with another value: skip, overwrite or fail. Required without a terminal when there are such keys
--create-envCreate the environment when it does not exist
--output jsonPrint the result as JSON: key names, the git state of the file, no values
--forceWrite every key without reading the environment first. Prefer --on-conflict overwrite
--from <source>Migrate from an external source. Currently supported: doppler
--token <token>API token for the --from source (Doppler service account token). Env: DOPPLER_TOKEN
--doppler-project <name>Doppler project to migrate (omit to migrate every accessible project)
--doppler-config <name>Doppler config to migrate. Requires --doppler-project
--doppler-api-url <url>Override the Doppler API base URL (defaults to https://api.doppler.com)
--config-map <pairs>Rename Doppler configs during import, e.g. prd=production,stg=staging
-o, --org <slug>Organization slug
-p, --project <slug>Project slug
-e, --env <slug>Target environment slug

Format Support​

.env files​

Standard KEY=VALUE format. Multiline values in double-quoted strings are supported:

terminal
DATABASE_URL=postgres://localhost/mydb
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAK...
-----END RSA PRIVATE KEY-----"

JSON files​

Flat key-value object:

json
{
"DATABASE_URL": "postgres://localhost/mydb",
"API_KEY": "secret123"
}

Also supports Infisical's export format (array of objects with key and value fields).

YAML files​

Flat key-value mapping:

yaml
DATABASE_URL: postgres://localhost/mydb
ENABLE_FEATURE: "no"

Note: Values that look like YAML booleans (yes, no, true, false, on, off) are always imported as strings. Use quotes if you want to be explicit.

CSV files​

CSV with a header row containing key and value columns:

csv
key,value
DATABASE_URL,postgres://localhost/mydb
API_KEY,secret123

Quoted fields containing commas or newlines are handled correctly.

Conflicts and dry run​

Before writing, the CLI reads the environment and sorts the file's keys into new, changed (the key exists with another value) and unchanged. Unchanged keys are not sent again. Only key names are printed, never values.

$ envshed import .env --dry-run
Import plan for acme/api/development (key names only):
New: OPENAI_API_KEY
Would be overwritten: DATABASE_URL
Unchanged: PORT
Some keys exist with another value: choose --on-conflict skip or overwrite.
Dry run: nothing was written.

When there are changed keys:

  • In a terminal, without --on-conflict, you are asked to confirm.
  • Without a terminal (a script, CI or a coding agent) and without --on-conflict, nothing is written and the command exits with code 2.
  • --on-conflict skip keeps the current values and writes only new keys. overwrite replaces them. fail writes nothing and exits with 2.

Exit codes: 0 imported (or nothing to do), 1 error, 2 changed keys need a policy and nothing was written.

After an import, the CLI says whether git tracks the file (its values are then in the repository history and need rotating) or does not ignore it, and suggests deleting it once envshed run works.

A file that cannot be parsed is reported with its line number at most. Parser messages are not shown, because they can quote a value. In a .env file, lines that are not KEY=value entries, comments or blank lines are skipped and reported by number (ignoredLines in JSON). Key names that are not letters, digits and _ stop the import before anything is written.

Migrating from Doppler​

terminal
# Dry run: list every project/config that would be migrated
envshed import --from doppler --token dp.sa.xxxx --org my-org --dry-run

# Full migration: create every matching Envshed project+env and push secrets
envshed import --from doppler --token dp.sa.xxxx --org my-org

# Migrate one Doppler project, rename its configs
envshed import --from doppler \
--token dp.sa.xxxx \
--org my-org \
--doppler-project backend \
--config-map "prd=production,stg=staging"

See Migrate from Doppler for the full guide, including how to generate a read-only Doppler service account token and map personal configs.

Examples​

terminal
# Import from a .env file (auto-detected)
envshed import .env

# Import a JSON export with explicit format
envshed import secrets.json --format json

# See the plan first, then import keeping existing values
envshed import .env.production --env production --dry-run
envshed import .env.production --env production --on-conflict skip

# Import into a new environment, as JSON for a script or an agent
envshed import .env.qa --env qa --create-env --on-conflict fail --output json

# Import from a different directory
envshed import /path/to/export.yaml