Documentation

Manage tokens

Manage tokens to authenticate and authorize access to server actions, resources, and data in your InfluxDB 3 Core instance.

Provide your token

If you start the InfluxDB 3 Core server with authentication enabled (the default), future server actions (CLI commands and HTTP API requests) require a valid token for authorization.

The first admin token you create is the operator token (named _admin), which has full administrative privileges. You can use the operator token to authenticate your requests and manage additional authorization tokens.

The mechanism for providing your token depends on the client you use to interact with InfluxDB 3 Core–for example:

When using the influxdb3 CLI, you can set the INFLUXDB3_AUTH_TOKEN environment variable to automatically provide your authorization token to all influxdb3 commands–for example:

# Export your token as an environment variable
export INFLUXDB3_AUTH_TOKEN=
YOUR_AUTH_TOKEN
# Run an influxdb3 command influxdb3 query \ --database DATABASE_NAME \ "SELECT * FROM 'DATABASE_NAME' WHERE time > now() - INTERVAL '10 minutes'"
  • Copy
  • Fill window

To specify a token in the command and override the environment variable, pass the --token option with your authorization token–for example:

# Include the --token option in your influxdb3 command
influxdb3 query \
  --token 
YOUR_AUTH_TOKEN
\
--database DATABASE_NAME \ "SELECT * FROM 'DATABASE_NAME' WHERE time > now() - INTERVAL '10 minutes'"
  • Copy
  • Fill window

You can also set the INFLUXDB3_AUTH_TOKEN environment variable to automatically provide your authorization token to all influxdb3 commands.

# Add your token to the HTTP Authorization header
curl "http://localhost:8181/api/v3/query_sql" \
  --header "Authorization: Bearer 
YOUR_AUTH_TOKEN
"
\
--data-urlencode "db=DATABASE_NAME" \ --data-urlencode "q=SELECT * FROM 'DATABASE_NAME' WHERE time > now() - INTERVAL '10 minutes'"
  • Copy
  • Fill window

Replace the following with your values:

  • YOUR_AUTH_TOKEN: your token
  • DATABASE_NAME: the name of the database you want to query

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

Now Generally Available

InfluxDB 3 Core and Enterprise

Start fast. Scale faster.

Get the Updates

InfluxDB 3 Core is an open source, high-speed, recent-data engine that collects and processes data in real-time and persists it to local disk or object storage. InfluxDB 3 Enterprise builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries and optimized storage. A free tier of InfluxDB 3 Enterprise is available for non-commercial at-home or hobbyist use.

For more information, check out: