content/shared/influxdb-v2/admin/tokens/create-token.md
Create API tokens using the InfluxDB user interface (UI), the influx
command line interface (CLI), or the InfluxDB API.
{{% note %}}
To follow best practices for secure API token generation and retrieval, InfluxDB enforces access restrictions on API tokens.
We recommend the following for managing your tokens:
{{% /note %}}
To manage InfluxDB API Tokens in the InfluxDB UI, navigate to the API Tokens management page.
{{% show-in "v2" %}}
In the navigation menu on the left, select Data (Load Data) > API Tokens.
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
In the navigation menu on the left, select Load Data > API Tokens.
{{% /show-in %}}
{{< nav-icon "load-data" >}}
{{% show-in "v2" %}}
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
To create a token with the same authorizations as an existing token, clone the existing token.
{{% /show-in %}}
Use the influx auth create command to create a token.
Include flags with the command to grant specific permissions to the token.
See the available flags.
Only tokens with the write: authorizations permission can create tokens.
# Syntax
influx auth create -o <org-name> [permission-flags]
Create an All Access token to grant permissions to all resources in an organization.
influx auth create \
--org my-org \
--all-access
{{% show-in "v2" %}}
Create an operator token to grant permissions to all resources in all organizations.
influx auth create \
--org my-org \
--operator
{{% note %}}
To view or create an operator token with the InfluxDB UI, api/v2 API, or influx CLI after the setup process is completed, you must use an existing operator token.
To create a new operator token without using an existing one, see how to use the influxd recovery auth CLI.
{{% /note %}}
{{% /show-in %}}
influx auth create \
--org my-org \
--read-bucket 03a2bbf46309a000 \
--read-bucket 3a87c03ace269000 \
--read-dashboards \
--read-tasks \
--read-telegrafs \
--read-user
influx auth create \
--org ORG_NAME \
--user USERNAME \
--read-authorizations \
--write-authorizations \
--read-buckets \
--write-buckets \
--read-dashboards \
--write-dashboards \
--read-tasks \
--write-tasks \
--read-telegrafs \
--write-telegrafs \
--read-users \
--write-users
See the influx auth create documentation for information about other available flags.
Use the /api/v2/authorizations InfluxDB API endpoint to create a token.
{{< api-endpoint method="POST" endpoint="http://localhost:8086/api/v2/authorizations" api-ref="/influxdb/version/api/#operation/PostAuthorizations" >}}
Include the following in your request:
| Requirement | Include by |
|---|---|
API token with the write: authorizations permission | Use the Authorization header and the {{% show-in "v2" %}}Bearer or {{% /show-in %}}Token scheme. |
| Organization | Pass as orgID in the request body. |
| Permissions list | Pass as a permissions array in the request body. |
{{% get-shared-text "api/v2.0/auth/oss/token-create.sh" %}}
To scope a token to a user other than the token creator, pass the userID property in the request
body.
{{% get-shared-text "api/v2.0/auth/oss/tokens-create-with-user.sh" %}}
See the
POST /api/v2/authorizations documentation
for more information about options.