From 80de38933c346454557ea9f37c09aef37c5380e9 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Mon, 21 Apr 2025 13:51:10 -0500 Subject: [PATCH] feat(influxdb3): Core and Enterprise: add create admin token API examples --- .../core/admin/tokens/admin/create.md | 6 +++ .../enterprise/admin/tokens/admin/create.md | 6 +++ .../influxdb3-admin/tokens/admin/create.md | 38 +++++++++++++++---- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/content/influxdb3/core/admin/tokens/admin/create.md b/content/influxdb3/core/admin/tokens/admin/create.md index 6b2038e36..fe1abbe5e 100644 --- a/content/influxdb3/core/admin/tokens/admin/create.md +++ b/content/influxdb3/core/admin/tokens/admin/create.md @@ -14,6 +14,12 @@ list_code_example: | ```bash influxdb3 create token --admin ``` + #### HTTP API + ```bash + curl -X POST "http://{{< influxdb/host >}}/api/v3/configure/token/admin" \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json' + ``` alt_links: cloud-dedicated: /influxdb3/cloud-dedicated/admin/tokens/create-token/ cloud-serverless: /influxdb3/cloud-serverless/admin/tokens/create-token/ diff --git a/content/influxdb3/enterprise/admin/tokens/admin/create.md b/content/influxdb3/enterprise/admin/tokens/admin/create.md index 3ccbca9e7..c073c622d 100644 --- a/content/influxdb3/enterprise/admin/tokens/admin/create.md +++ b/content/influxdb3/enterprise/admin/tokens/admin/create.md @@ -14,6 +14,12 @@ list_code_example: | ```bash influxdb3 create token --admin ``` + #### HTTP API + ```bash + curl -X POST "http://{{< influxdb/host >}}/api/v3/enterprise/configure/token/admin" \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json' + ``` alt_links: cloud-dedicated: /influxdb3/cloud-dedicated/admin/tokens/create-token/ cloud-serverless: /influxdb3/cloud-serverless/admin/tokens/create-token/ diff --git a/content/shared/influxdb3-admin/tokens/admin/create.md b/content/shared/influxdb3-admin/tokens/admin/create.md index f3e77323e..cba3c7def 100644 --- a/content/shared/influxdb3-admin/tokens/admin/create.md +++ b/content/shared/influxdb3-admin/tokens/admin/create.md @@ -9,14 +9,17 @@ An admin token grants full access to all actions for your InfluxDB 3 instance. > > Token strings are returned _only_ on token creation. > We recommend storing database tokens in a **secure secret store**. +> Anyone with access to the admin token has full control over your {{< product-name >}} instance. > If you lose the admin token string, you must regenerate the token. ## Create an admin token -- [Use the influxdb3 CLI](#use-the-influxdb3-cli) -- [Use the HTTP API](#use-the-http-api) - -### Use the influxdb3 CLI +{{< tabs-wrapper >}} +{{% tabs %}} +[CLI](#use-the-influxdb3-cli) +[HTTP API](#use-the-http-api) +{{% /tabs %}} +{{% tab-content %}} Use the `influxdb3 create token --admin` command: @@ -24,10 +27,31 @@ Use the `influxdb3 create token --admin` command: influxdb3 create token --admin ``` -The command returns the token string in plain text. +The output contains the token string in plain text. To use the token as the default for later commands, and to persist the token across sessions, assign the token string to the `INFLUXDB3_AUTH_TOKEN` environment variable. +{{% /tab-content %}} +{{% tab-content %}} +Use the following endpoint to create an admin token: -> [!Caution] -> Protect your admin token. Anyone with access to the admin token has full control over your {{< product-name >}} instance. \ No newline at end of file +{{% show-in "core" %}} +{{% api-endpoint method="POST" endpoint="/api/v3/configure/token/admin" api-ref="/influxdb3/version/api/v3/#operation/PostCreateAdminToken" %}} + +```bash +curl -X POST "http://{{< influxdb/host >}}/api/v3/configure/token/admin" \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' +``` +{{% /show-in %}} +{{% show-in "enterprise" %}} +{{% api-endpoint method="POST" endpoint="/api/v3/enterprise/configure/token/admin" api-ref="/influxdb3/version/api/v3/#operation/PostCreateAdminToken" %}} + +```bash +curl -X POST "http://{{< influxdb/host >}}/api/v3/{{< product-key >}}/configure/token/admin" \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' +``` +{{% /show-in %}} +{{% /tab-content %}} +{{< /tabs-wrapper >}}