content/influxdb3/cloud-serverless/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.
- Tokens are visible to the user who created the token.
- InfluxDB only allows access to the API token value immediately after the token is created.
- You can't change access (read/write) permissions for an API token after it's created.
- Tokens stop working when the user who created the token is deleted.
We recommend the following for managing your tokens:
- Create a generic user to create and manage tokens for writing data.
- Store your tokens in a secure password vault for future access.
{{< tabs-wrapper >}} {{% tabs %}} InfluxDB UI influx CLI InfluxDB API {{% /tabs %}}
<!---------------------------------- BEGIN UI --------------------------------->{{% tab-content %}}
To create an InfluxDB API token in the InfluxDB UI, navigate to the API Tokens management page. In the navigation menu on the left, select Load Data > API Tokens.
{{< nav-icon "load-data" >}}
To create a token with the same authorizations as an existing token, clone the existing token.
{{% /tab-content %}}
<!----------------------------------- END UI ----------------------------------> <!--------------------------------- BEGIN CLI --------------------------------->{{% tab-content %}}
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.
Provide the following flags with the command:
--token: API token with permission to create new tokens--org: Organization name{{% code-placeholders "(API|ORG)_(TOKEN|NAME)" %}}
influx auth create \
--token API_TOKEN \
--org ORG_NAME \
--read-buckets \
--write-buckets \
--read-dbrps \
--write-dbrps
{{% /code-placeholders %}}
Create an All-Access token to grant permissions to all resources in an organization.
{{% code-placeholders "(API|ORG)_(TOKEN|NAME)" %}}
influx auth create \
--token API_TOKEN \
--org ORG_NAME \
--all-access
{{% /code-placeholders %}}
{{% code-placeholders "(API|ORG|BUCKET)_(TOKEN|NAME|ID)" %}}
influx auth create \
--token API_TOKEN \
--org ORG_NAME \
--read-bucket BUCKET_ID \
--read-bucket BUCKET_ID \
--read-dashboards \
--read-tasks \
--read-telegrafs \
--read-user
{{% /code-placeholders %}}
{{% code-placeholders "(API|ORG)_(TOKEN|NAME)|USERNAME" %}}
influx auth create \
--token API_TOKEN \
--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
{{% /code-placeholders %}}
See the influx auth create documentation
for information about other available flags.
{{% /tab-content %}}
<!---------------------------------- END CLI ----------------------------------> <!--------------------------------- BEGIN API --------------------------------->{{% tab-content %}}
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/v2/api/#operation/PostAuthorizations" >}}
Include the following in your request:
Token API_TOKEN
(API token with the write: authorizations permission)application/json{{% code-placeholders "(API|ORG|AUTHORIZATION)_(TOKEN|ID|DESCRIPTION)" %}}
{{% get-shared-text "api/cloud-serverless/auth/token-create.sh" %}}
{{% /code-placeholders %}}
To scope a token to a user other than the token creator, pass the userID property in the request
body.
{{% code-placeholders "(API|ORG)_(TOKEN|ID)" %}}
{{% get-shared-text "api/cloud-serverless/auth/tokens-create-with-user.sh" %}}
{{% /code-placeholders %}}
See the
POST /api/v2/authorizations documentation
for more information about options.
{{% /tab-content %}}
<!---------------------------------- END API ---------------------------------->{{< /tabs-wrapper >}}