Skip to main content

create

create tokens

🔑 Create a new API token for the current user.

This command creates a new API token for the current user. The token can be used to authenticate with the ComputeSphere API.

The token can be created with a specific name, scope, and expiry date. Name should be 1-50 characters long and can contain letters, numbers, and underscores. Expiry date should be in the date time format YYYY-MM-DD HH:MM:SS. Scope of the token determines the level of access that the token has. The token can have one of the following scopes:

  • full: The token has full access to all accounts and projects.
  • account: The token has access to all resources in the specified accounts.
  • project: The token has access to all resources in the specified projects.

To specify the accounts or projects that the token has access to, use the --restrictions flag. The flag should be a comma-separated list of account or project IDs. Type of resources should be specified in the --scope flag.

Both interactive and non-interactive modes respond with the token value only. The token value is a secret and should be stored securely.

This command supports reading input from a file. Files can be supplied via the --file flag or piped into the command.

Example of file structure
{
"expiry": "0001-01-01T00:00:00Z",
"name": "My Token",
"scope": "full"
}

Usage​

csph auth token create [flags]

Aliases​

auth token create, auth token new, auth tokens create, auth tokens new, auth api-token create, auth api-token new, auth api-tokens create, auth api-tokens new

Options​

Command Specific​

--account <string>
account ID
--expiry <string>
expiry as date time '2025-01-02 15:04:05' (required)
--file <string>
specify a payload file [json|yaml], has precedence over other flags
--name <string>
token name, 1-50 characters: letters and numbers, with hyphens or underscores in the middle (required)
--restrictions <strings>
account or project IDs, depending on the scope, comma separated

--scope <string> (default "full")

scope of the token: [full|account|project] (required)

Inherited​

--config <string>
config file (default is $HOME/.config/computesphere/configuration.yaml)
--debug
enable debug logging

-h, --help

show this help message

-i, --interactive

run interactively (prompts, pickers, table browser)
--log-level <string>
log level: [trace|debug|info|warn|error|fatal|panic|disabled||api]
--no-color
disable color output
--no-input
disable interactive mode

Examples​

# start a prompt to create a new token
> csph auth token create

# create a new token directly, with a name, full scope, and expiry date
> csph auth token create \
--name my-token \
--scope full \
--expiry "2027-12-31 23:59:59"

# create a new token directly, with a name, account scope, and expiry date
> csph auth token create \
--name my-token \
--scope account \
--restrictions <account-id>,<account-id> \
--expiry "2027-12-31 23:59:59"

# create a new token directly, with a name, project scope, and expiry date
> csph auth token create \
--name my-token \
--scope project \
--restrictions <project-id>,<project-id> \
--expiry "2027-12-31 23:59:59"

See also​