Installation & Profiles
Environment Sync connects to your instances through profiles: named entries like staging or production that pair an instance URL with a credential. The URLs are project configuration you commit; the credentials never are.
Install the CLI
npm install -g @directus/cli
Verify the install:
d6s --version
The project file
Profiles live in directus.config.json in your project root, next to the directories a pull writes. Adding a profile records its name and URL there. The credential is stored separately.
directus.config.json never contains tokens, so committing it cannot leak credentials. Commit it so everyone on the project resolves the same profile names.Because the URL is the part of a profile that gets committed, one rule is enforced:
https://admin:secret@staging.example.com embeds a credential in a value that lands in directus.config.json. The CLI refuses it. Tokens belong in the credential store or the environment, never in a committed file.Where credentials live
When a command needs to authenticate against a profile, the credential resolves in order:
- A
--tokenflag, on the commands that accept one (profile addandprofile test). - A
DIRECTUS_<PROFILE>_TOKENenvironment variable. For a profile namedstaging, that'sDIRECTUS_STAGING_TOKEN. - The saved credential store at
~/.directus/credentials.json, written with owner-only file permissions (mode0600).
In CI (any environment where the CI variable is set) the credential store is never consulted. The sync commands take no --token flag, so in CI their tokens come from the environment variables.
Adding a profile
d6s profile add
The prompts walk you through it: name the profile, give it a URL, and authenticate by pasting a static token or logging in with your email and password to save a session. Saved sessions are refreshed automatically before requests when they are close to expiring.
You can also pass everything directly:
d6s profile add staging --url https://staging.example.com --token <your-token>
Testing a profile
d6s profile test staging
This connects to the instance and prints who you are on it, confirming the URL is reachable and the credential works. Like the sync commands, it refreshes an expiring saved session.
Next step
With a profile added and tested, snapshot your first instance: Pulling.
Get once-a-month release notes & real‑world code tips...no fluff. 🐰
Overview
Move schema and configuration between Directus instances through files you commit to git, using the Directus CLI.
Pulling
Snapshot schema and configuration from a source instance into files you commit. Scope a pull by resource or by collection, or skip schema entirely for configuration-only projects.