• Start
Sign In

surrealctl

Global flags

The sixteen flags every surrealctl command accepts, the environment variable behind each one, the precedence chain that resolves them, and the duration syntax.

Sixteen flags are accepted by every surrealctl command. They may appear anywhere on the command line — before the group, between the group and the verb, or after the verb — so all three of these are the same invocation:

surrealctl --json instance list
surrealctl instance --json list
surrealctl instance list --json

--help groups them under four headings, and this page keeps those groups.

Context flags

NameDefaultEnvironment variableDescription
--profile<PROFILE>
defaultSURREALCTL_PROFILEThe configuration profile to use. A profile bundles a credential, an API base URL and a set of configuration values.
--config<PATH>
NoneSURREALCTL_CONFIGPath to the configuration file. Its directory also becomes the credential directory.
--org<ORG>
NoneSURREALCTL_ORGThe organisation to operate on, by id or name.

Authentication flags

NameDefaultEnvironment variableDescription
--token<TOKEN>
NoneSURREALCTL_TOKENPersonal access token to authenticate with. Conflicts with --token-file, and is never persisted.
--token-file<PATH>
NoneSURREALCTL_TOKEN_FILERead the personal access token from a file, or - for standard input. Conflicts with --token.
--api<URL>
https://api.surrealdb.comSURREALCTL_APIBase URL of the SurrealDB API. Must be absolute, http or https, name a host, and carry no path.

--token has no short form on purpose: -t reads as --type on the instance commands, and a credential belongs in the environment or a file rather than in argv. See Authentication.

A base URL with a path of its own is refused as a usage error, because the client appends its own routes and the path would be silently prepended to every one of them:

Ensure the API base has no path, such as https://api.surrealdb.com

Output flags

NameDefaultEnvironment variableDescription
--json, -j
NoneSURREALCTL_JSONEmit machine-readable JSON on stdout. See the output contract for what is guaranteed.
--plain
NoneSURREALCTL_PLAINDisable tables, spinners and relative times. Output becomes tab-separated and width-independent.
--color<WHEN>
autoNoneWhen to use colour in output: auto, always or never.
--quiet, -q
NoneNoneSuppress progress and informational output. The data payload on stdout is unaffected.
--yes, -y
NoneSURREALCTL_YESAssume yes for every confirmation in this invocation.
--no-input
NoneSURREALCTL_NO_INPUTNever prompt for input; fail instead. Also spelled --non-interactive.

--color is the one flag with no SURREALCTL_* variable. Colour also honours the NO_COLOR, FORCE_COLOR and CLICOLOR_FORCE conventions.

--json and --plain are independent axes: --json chooses the encoding, --plain the decoration. Passing both is accepted and --plain is ignored, because CI scripts pass both and erroring on that is hostile.

--help files the request timeout and the retry budget under this heading alongside the log level.

Logging flags

NameDefaultEnvironment variableDescription
--log<FILTER>
warnSURREALCTL_LOGThe logging level, or a full set of filter directives.
--debug
NoneSURREALCTL_DEBUGLog every API request and response to stderr, with the credential reduced to a digest. Also reports which precedence layer supplied each resolved value.
--timeout<DURATION>
30sSURREALCTL_TIMEOUTMaximum time to wait for a single API request.
--retries<N>
3SURREALCTL_RETRIESHow many times to retry a failed request. The number of attempts is one more than this.

The effective per-request timeout is never shorter than 21 seconds, because the API's own upstream timeout is 20 seconds and giving up sooner abandons requests that are still being worked on.

Every value that can come from more than one place is resolved once, before the command runs, in this order — highest first:

  1. A command-line flag

  2. An environment variable

  3. The profile in config.toml

  4. The persisted context, written by org use

  5. Your account's default organisation, as the API reports it

  6. The only candidate, when exactly one exists

  7. An interactive picker, when a person is present

  8. An error naming the flag that would have settled it

Layers 5 to 7 apply to the organisation specifically. Exactly one candidate is not a choice, so it is used silently; several candidates in a non-interactive session is an error rather than a guess:

Several organizations are available and none was chosen.
Pass --org, set SURREALCTL_ORG, or run `surrealctl org use <name>`.

Available:
  acme
  contoso

--debug prints which layer won each value, and context show reports it as part of its answer:

LayerReported as
Command-line flagcommand-line flag
Environment variableenvironment variable
Profile in config.tomlprofile in config.toml
Persisted contextpersisted context (org use)
Account defaultyour account's default organization
Single candidatethe only candidate
Interactive pickerinteractive choice

An organisation reference that already looks like an id is used with no lookup at all. A name or slug costs one request to resolve, and an unrecognised one is answered with did-you-mean candidates.

Note

A configured api value applies only when --api was not given. Because the flag has a default, the CLI cannot distinguish "absent" from "passed exactly the default", so passing --api https://api.surrealdb.com explicitly leaves the configured value unused.

--timeout, --wait-timeout and spectron access-token create --ttl all accept the same syntax. A bare number means seconds.

SuffixUnit
(none), s, sec, secs, second, secondsSeconds
msMilliseconds
m, min, mins, minute, minutesMinutes
h, hr, hrs, hour, hoursHours
d, day, daysDays
surrealctl --timeout 90 instance list
surrealctl instance create api --type shared-1 --region aws-euw1 --wait-timeout 5m
surrealctl spectron access-token create --ttl 2h

Every environment variable this CLI reads is prefixed SURREALCTL_, and never SURREAL_.

Reusing the sibling's prefix would be actively harmful rather than merely untidy. SURREAL_TOKEN in a shell means a database JWT for one instance; reading it as a control-plane credential would send database tokens to api.surrealdb.com on every command.

The only SURREAL_* variables involved are ones surrealctl sets for the surreal child process during the handoff: SURREAL_TOKEN, SURREAL_NAMESPACE and SURREAL_DATABASE.

VariableFlag
SURREALCTL_PROFILE--profile
SURREALCTL_CONFIG--config
SURREALCTL_ORG--org
SURREALCTL_TOKEN--token
SURREALCTL_TOKEN_FILE--token-file
SURREALCTL_API--api
SURREALCTL_JSON--json
SURREALCTL_PLAIN--plain
SURREALCTL_YES--yes
SURREALCTL_NO_INPUT--no-input
SURREALCTL_LOG--log
SURREALCTL_DEBUG--debug
SURREALCTL_TIMEOUT--timeout
SURREALCTL_RETRIES--retries
VariableEffect
SURREALCTL_CONFIG_DIROverrides the configuration and credential directory
SURREALCTL_SURREAL_BINARYPath to the surreal binary used by instance sql, import and export
SURREALCTL_AGENT1 or 0, forcing agent detection on or off
SURREALCTL_CLOUD_TOKENSupplies an already-minted Cloud session token, for support reproduction
SURREALCTL_AUTH_CLIENT_IDOverrides the OAuth client id, for a non-production tenant
SURREALCTL_AUTH_ISSUEROverrides the OAuth issuer, for a non-production tenant
VariableEffect
NO_COLORDisables colour
FORCE_COLOR, CLICOLOR_FORCEEnables colour, even when piped
CISelects plain, structural output. CI=false, CI=0 and an empty value all mean not CI
TERM=dumbSelects plain output with no colour
SSH_CONNECTION, SSH_TTYSkips the browser login flow
XDG_CONFIG_HOME, HOMELocate the configuration directory
HTTPS_PROXY, NO_PROXYProxy the API connection
EDITORUsed by config edit

Five values can be persisted per profile with config set. Each is outranked by its environment variable, and config set warns when that variable is exported.

KeyEnvironment variable
orgSURREALCTL_ORG
apiSURREALCTL_API
jsonSURREALCTL_JSON
plainSURREALCTL_PLAIN
surreal_binarySURREALCTL_SURREAL_BINARY

Was this page helpful?