Sandbox API Tokens in SePay CLI

Create, view, disable and delete sandbox API Tokens with SePay CLI so your integration can call SePay API in the sandbox without opening my.sepay.vn.

||
Sandbox only

SePay CLI manages sandbox API Tokens only, with simulated data that never touches production. A production API Token has access to the whole company, so it is created and revoked only in my.sepay.vn, see Create an API Token; the CLI doesn't create, view or revoke production tokens.

Your integration calls SePay API with an API Token sent in the Authorization: Bearer <API Token> header. In the sandbox, create and manage that token with the sepay apikey commands (short form sepay ak). The CLI itself signs in with sepay login and never uses an API Token.

apikey create

Creates a sandbox API Token:

$ sepay apikey create --name "dev-server"

The command prints Created API key <xid>., then the token details; the Key row is the full token.

FlagTypeRequiredDescription
--namestringYesToken name, up to 200 characters
--activeboolNoDefaults to true. --active=false creates the token disabled
Save the token when you create it

apikey create is the only command that prints the full token; every other command shows it masked. Store it in an environment variable or your project's secret store right away. If you lose it, create a new token and delete the old one.

apikey list and apikey get

Lists your company's sandbox API Tokens. The KEY column shows each token masked:

$ sepay apikey list

Shows one token by xid. Leave the xid out and the CLI lets you pick from a list:

$ sepay apikey get <xid>

apikey update

Disables a token without deleting it, for example while a test environment is paused:

$ sepay apikey update <xid> --active=false

Turn it back on with --active, rename it with --name "<new name>".

apikey delete

Deletes a token:

$ sepay apikey delete <xid> --yes

The command always asks for confirmation; in a script it needs --yes. A deleted token can't be restored, and SePay rejects code that still uses it.

Error messages

MessageCauseFix
apikey list is sandbox-only; drop --env productionAn apikey command run with --env productionDrop --env production; production tokens are created in my.sepay.vn
an API key xid is requiredget, update or delete run in a script without an xidPass the xid from apikey list
--name is requiredcreate run in a script without --nameAdd --name "<name>"
nothing to update; pass --name and/or --activeupdate without --name or --activeAdd the flag you want to change
no API keys yet; create one with: sepay apikey create --name <name>Your company has no sandbox API Token yetCreate one with apikey create