Documentation

influxdb3 create token --admin

Create an operator token or named admin token.

Usage

influxdb3 create token --admin [OPTIONS]

Options

OptionDescription
--regenerateRegenerates the operator token. Requires --token and the current operator token
--nameName of the token
--expiryExpires in duration–for example, 10d for 10 days 1y for 1 year
--hostThe host URL of the running InfluxDB 3 server [env: INFLUXDB3_HOST_URL=] [default: http://127.0.0.1:8181]
--tokenAn existing admin token for the InfluxDB 3 server
--tls-caAn optional arg to use a custom ca for useful for testing with self signed certs
--formatOutput format for token [possible values: json, text]
--offlineGenerate token without connecting to server (for automation)
--output-fileFile path to save the token (required with --offline)
-h, --helpPrint help information
--help-allPrint more detailed help information

Examples

Create an operator token

The operator token is a special token that has full administrative privileges on the InfluxDB server and doesn’t expire. The first admin token you create becomes the operator token for the instance. You can create an operator token using the --admin flag without any additional options.

influxdb3 create token --admin

The output is the raw token string you can use to authenticate future CLI commands and API requests. For CLI commands, use the --token option or the INFLUXDB3_AUTH_TOKEN environment variable to pass the token string.

Use the operator token to create a named admin token

influxdb3 create token \
  --admin \
  --token 
OPERATOR_TOKEN
\
--name
TOKEN_NAME
\
--expiry DURATION

Replace the following:

  • OPERATOR_TOKEN: Your operator token for the server
  • TOKEN_NAME: Name for your new admin token
  • DURATION: Duration for the token to remain valid, in humantime format (for example, 10d for 10 days or 1y for 1 year).

Use the token to create a database

influxdb3 create database \
  --token ADMIN_TOKEN \
  
DATABASE_NAME

Replace the following:

  • ADMIN_TOKEN: Your InfluxDB admin token
  • DATABASE_NAME: Name for your new database

Use CLI environment variables

Set the token as an environment variable to simplify repeated CLI commands:

export INFLUXDB3_AUTH_TOKEN=ADMIN_TOKEN

Generate an offline admin token

Generate an offline admin token file to use if no tokens exist when the server starts. Once started, you can interact with the server using the provided token. Offline admin tokens are designed to help with automated deployments.

Include the following options:

  • --offline (Required)
  • --output-file (Required)
  • --name (default is _admin)
  • --expiry (Optional)
influxdb3 create token --admin \
  --name 
TOKEN_NAME
\
--expiry
DURATION
\
--offline \ --output-file
path/to/admin-token.json

Replace the following:

  • TOKEN_NAME: Name for your offline admin token
  • DURATION: Duration for the token to remain valid, in humantime format (for example, 10d for 10 days or 1y for 1 year).
  • path/to/admin-token.json: File path to use for the generated token file

View example offline admin token file


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

New in InfluxDB 3.4

Key enhancements in InfluxDB 3.4 and the InfluxDB 3 Explorer 1.2.

See the Blog Post

InfluxDB 3.4 is now available for both Core and Enterprise, which introduces offline token generation for use in automated deployments and configurable license type selection that lets you bypass the interactive license prompt. InfluxDB 3 Explorer 1.2 is also available, which includes InfluxDB cache management and other new features.

For more information, check out: