• Start
Sign In

surrealctl

/

Commands

auth

Reference for surrealctl auth — signing in, signing out, inspecting the stored credential, renewing it, and listing what it is permitted to do.

surrealctl auth signs in, signs out, and inspects credentials. Four of its five verbs work entirely from the local credential store; only login, refresh and auth status --verify touch the network.

Usage
surrealctl auth <COMMAND> [OPTIONS]
VerbPurpose
loginSign in to SurrealDB Cloud
logoutRemove the stored credentials for a profile
statusShow which credentials are in use
refreshRenew the stored credentials now
scopesShow what the current credential is permitted to do

Behaviour when nothing is signed in is deliberate and differs by verb: status and logout succeed with exit 0, while scopes and refresh exit 3. See Authentication for why.

Sign in to SurrealDB Cloud, storing a credential for the active profile.

Usage
surrealctl auth login [OPTIONS]

This command takes no positional arguments.

Options

NameDescription
--with-token
Read a personal access token from standard input instead of signing in. This is the only way to store a token.
--label<NAME>
A label to remember this personal access token by. Requires --with-token.
--flow<FLOW>
Which sign-in flow to use: browser, device or paste. Conflicts with --with-token.
--no-browser
Do not open a browser; show a code or a URL instead. Conflicts with --with-token and --flow.
--force
Sign in again even if this profile already has a credential.
--flow valueBehaviour
browserOpen a browser and listen on 127.0.0.1 for the redirect
deviceShow a code to type on another device, following RFC 8628
pastePrint a URL and take back the address the browser was redirected to

Left to itself the command tries browser, then device, then paste, and stops at the first one that can run. A flow named explicitly is used or it fails; there is no silent substitution.

Sign in interactively
surrealctl auth login
Sign in over SSH, where a local browser is no use
surrealctl auth login --flow device
Store a personal access token for a profile
echo "$CI_TOKEN" | surrealctl --profile ci auth login --with-token --label "build runner"

Refusals and short-circuits. A profile that already holds a credential is a no-op that exits 0 and names the remedy:

Profile `default` is already signed in as ana@acme.example.
Replace it with:
  surrealctl auth login --force

An interactive flow that does not complete exits 30. A session with nobody present and no way to prompt cannot start a flow at all, and says so rather than printing a device code nobody will read.

Only --with-token stores a credential. --token, --token-file and SURREALCTL_TOKEN are request-scoped and never written to disk.

Remove the stored credentials for a profile.

Usage
surrealctl auth logout [OPTIONS]

This command takes no positional arguments.

Options

NameDescription
--force
Do not ask for confirmation.
Sign out of the active profile
surrealctl auth logout
Tear down a profile in a script
surrealctl --profile ci auth logout --force --json

Logging out revokes the refresh token at the identity provider on a best-effort basis and removes only this profile's entry. A failed revocation warns but never blocks the local wipe.

Signing out when nothing is signed in still succeeds and still emits a document, so auth logout --json in a teardown script has the same shape on its second run as on its first:

Output
{
  "profile": "ci",
  "removed": false,
  "revoked": false
}

Declining the confirmation prints Nothing was changed. and exits 0.

Show which credentials are in use, without touching the network.

Usage
surrealctl auth status [OPTIONS]

This command takes no positional arguments.

Options

NameDescription
--verify
Also check the credential against the API. Adds one request.
What am I signed in as?
surrealctl auth status
Confirm the credential still works
surrealctl auth status --verify

The document has the same shape signed in and signed out, so a script can read one field without branching first. status warns when the machine's clock is more than five minutes out, and when SURREALCTL_CLOUD_TOKEN is supplying a session token.

For the API's own view of your identity, use whoami, which spends a request.

Renew the stored credentials now, rather than waiting for them to expire.

Usage
surrealctl auth refresh [OPTIONS]

This command takes no positional arguments.

Options

NameDescription
--all
Also renew the token for the account-management routes.
surrealctl auth refresh

The command forces both the access token and the Cloud session. --all additionally renews the token used for the account-management routes, which is the one the token commands need.

Refusals. With nothing signed in, this exits 3. On a personal access token it reports that a token does not expire on a schedule and cannot be refreshed, then exits 0 without sending anything.

Show what the current credential is permitted to do.

Usage
surrealctl auth scopes [OPTIONS]

This command takes no positional arguments.

Options

NameDescription
--no-header
Omit the header row.
Note

This is the one list-shaped command that carries only --no-header. It has no --columns, --wide, --sort, --reverse or --limit.

What may this token do?
surrealctl auth scopes
Output
SCOPE
read:cloud
write:cloud-instances

The single column is scope.

Refusals. With nothing signed in, this exits 3 — a script asking "what may this credential do" and getting an empty list would read it as "nothing is permitted" rather than "nothing is signed in".

On a login session the list is empty, and a sentence on stderr points at org permissions: identity scopes are not an authorisation model, and your role in the organisation is what decides what you may do.

For the catalogue of scopes a token can be granted, use token scopes.

Was this page helpful?