Two environments
The sandbox uses Test mode data, with no real money. Production is live data and real transactions. The two are fully separate: an xid created in the sandbox doesn't exist in production.
Select an environment
Add --env production or --env sandbox to pick the environment for a single command. Without --env, a command runs in the default environment, which is the sandbox unless you change it.
Make the sandbox the default for every command:
$ sepay config set default_env sandboxMake production the default. The CLI asks for confirmation before saving it:
$ sepay config set default_env productiondefault_env is stored in config.yml. If the value there is invalid, the CLI prints a warning and runs in the sandbox.
Active environment
Commands that work with your SePay data print which environment they're using, so you can tell sandbox from production at a glance. The line is left out when you pass --json, -o yaml or --quiet.
env: sandboxRun commands on production
A command that changes data on production runs only when you confirm it on your own terminal. An AI does not confirm it for you: it hands you the command to run yourself.
The command must have --env production right on the command line; default_env: production does not count. It prints env: production, then ! live: ... targets PRODUCTION, and asks for confirmation before it runs.
For example, renaming a webhook on production:
$ sepay webhook update 5f0e2a7b-xxxx-xxxx-xxxx-fa163e2f7c98 --name "Webhook don hang" --env productionenv: production! live: update webhook targets PRODUCTION? update webhook on production? [y/N]Type y and press Enter to run it. Press Enter (the default is No) or n and the command is cancelled with Error: update webhook cancelled. Ctrl+C or Esc cancels it too, with exit code 130 and no error message.
With no terminal to answer the prompt, the command exits with exit code 2. A script you write yourself can run it with --env production, the resource id and --yes; a command without an id runs only in a terminal (full rule). To preview what the command would send, add --dry-run (Dry run). Exit code 5 means the token lacks the scope the command needs: sign in again and grant it.
Sandbox-only commands
The commands in this table exit with exit code 2 if you run them with --env production:
$ sepay va issue --env productionError: va issue is sandbox-only; drop --env productionRun 'sepay va issue --help' for usage.When default_env is production and the command has no --env, the sandbox, pg, bankhub and einvoice groups and webhook test still run on sandbox; the other commands in the table exit with code 2.
| Command group | Description |
|---|---|
sandbox | Manage sandbox data: create and reset. |
pg | Payment Gateway (sandbox). |
bankhub | Bank Hub (sandbox). |
einvoice | eInvoice (sandbox). |
apikey | Manage sandbox API tokens. Production API Tokens are created and revoked in my.sepay.vn. |
bank-account (create, delete) | Create and delete sandbox bank accounts. |
va (issue, revoke) | Manage sandbox virtual accounts (VA). |
webhook (listen, test, create/update --listen-only) | Manage sandbox webhooks. |
Configuration files
| Operating system | Configuration directory |
|---|---|
| Linux | ~/.config/sepay/ (or $XDG_CONFIG_HOME/sepay/) |
| macOS | ~/Library/Application Support/sepay/ |
| Windows | %AppData%\sepay\ |
The two main files in this directory both have 0600 permissions. config.yml keeps the default environment and is written by sepay config set. hosts.yml keeps your signed-in profiles, plus the token when you signed in with --insecure-storage, and is written by sepay login and the sepay auth ... commands.
When you signed in with --insecure-storage, or ran sepay pg auth, sepay bankhub auth or sepay einvoice auth with that flag, credentials for pg, bankhub and einvoice go into products.yml in the same directory. On a machine with no usable keychain, sepay login saves the token in hosts.yml as --insecure-storage would and prints a warning; that profile keeps using the file afterwards.
Point the CLI at a different, existing configuration file with --config <file> (the CLI also reads hosts.yml from that file's folder), or move the whole directory with SEPAY_CONFIG_DIR, for example to give each agent its own credentials.
Environment variables
| Variable | Description |
|---|---|
SEPAY_CONFIG_DIR | The configuration and profile directory. |
SEPAY_PROFILE | The profile to use (same as --profile). |
NO_COLOR | Set to 1 to turn off colors. |
SEPAY_NO_UPDATE_NOTIFIER | Set to 1 to turn off the notice about a newer or deprecated version (Install SePay CLI). Setting CI also turns it off. |
SEPAY_LANG | Language of the sepay login screen: vi or en. Unset, it follows your locale (Sign-in screen language). |
The CLI checks the value of NO_COLOR and SEPAY_NO_UPDATE_NOTIFIER: 0, false, no, off and an empty value all mean off, so NO_COLOR=0 keeps colors on.
No environment variable takes a token: credentials only reach the CLI through sepay login. If the machine can't open a browser, see Sign in on a machine without a browser.