SePay CLI environments and configuration

Pick the sandbox or production environment for SePay CLI commands, change the default for every command, and find where the CLI keeps config and credentials.

||

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 sandbox

Make production the default. The CLI asks for confirmation before saving it:

$ sepay config set default_env production

default_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: sandbox

Run 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 groupDescription
sandboxManage sandbox data: create and reset.
pgPayment Gateway (sandbox).
bankhubBank Hub (sandbox).
einvoiceeInvoice (sandbox).
apikeyManage 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 systemConfiguration 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

VariableDescription
SEPAY_CONFIG_DIRThe configuration and profile directory.
SEPAY_PROFILEThe profile to use (same as --profile).
NO_COLORSet to 1 to turn off colors.
SEPAY_NO_UPDATE_NOTIFIERSet to 1 to turn off the notice about a newer or deprecated version (Install SePay CLI). Setting CI also turns it off.
SEPAY_LANGLanguage 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.