Authentication

Depending on your workflow, use one of the following schemes to authenticate to the InfluxDB 3 API:

Authentication schemeWorks with
Bearer authenticationAll endpoints
Token authenticationv1 and v2 compatibility endpoints (/write, /query, /api/v2/write)
Basic authenticationv1 compatibility endpoints (/write, /query)
Querystring authenticationv1 compatibility endpoints (/write, /query)
See the Security Schemes section below for details on each authentication method.

Security Schemes

BasicAuthentication

Type
http
Scheme
basic

Use the Authorization header with the Basic scheme to authenticate v1 API requests. Works with v1 compatibility /write and /query endpoints in InfluxDB 3. When authenticating requests, InfluxDB 3 checks that the password part of the decoded credential is an authorized token and ignores the username part of the decoded credential.

Syntax

Authorization: Basic <base64-encoded [USERNAME]:AUTH_TOKEN>

Example

curl "http://localhost:8181/write?db=DATABASE_NAME&precision=s" \
  --user "":"AUTH_TOKEN" \
  --header "Content-type: text/plain; charset=utf-8" \
  --data-binary 'home,room=kitchen temp=72 1641024000'

Replace the following:

  • DATABASE_NAME: your InfluxDB 3 Enterprise database
  • AUTH_TOKEN: an admin token or database token authorized for the database

BearerAuthentication

Type
http
Scheme
bearer

Use the OAuth Bearer authentication scheme to provide an authorization token to InfluxDB 3. Bearer authentication works with all endpoints. In your API requests, send an Authorization header. For the header value, provide the word Bearer followed by a space and a database token.

Syntax

Authorization: Bearer AUTH_TOKEN

Example

curl http://localhost:8181/api/v3/query_influxql \
  --header "Authorization: Bearer AUTH_TOKEN"

QuerystringAuthentication

Type
apiKey
In
query
Parameter Name
u=&p=

Use InfluxDB 1.x API parameters to provide credentials through the query string for v1 API requests. Querystring authentication works with v1-compatible /write and /query endpoints. When authenticating requests, InfluxDB 3 checks that the p (password) query parameter is an authorized token and ignores the u (username) query parameter.

Syntax

https://localhost:8181/query/?[u=any]&p=AUTH_TOKEN
https://localhost:8181/write/?[u=any]&p=AUTH_TOKEN

Examples

curl "http://localhost:8181/write?db=DATABASE_NAME&precision=s&p=AUTH_TOKEN" \
  --header "Content-type: text/plain; charset=utf-8" \
  --data-binary 'home,room=kitchen temp=72 1641024000'

Replace the following:

  • DATABASE_NAME: your InfluxDB 3 Enterprise database
  • AUTH_TOKEN: an admin token or database token authorized for the database
#######################################
# Use an InfluxDB 1.x compatible username and password
# to query the InfluxDB v1 HTTP API
#######################################
# Use authentication query parameters:
#   ?p=AUTH_TOKEN
#######################################
curl --get "http://localhost:8181/query" \
  --data-urlencode "p=AUTH_TOKEN" \
  --data-urlencode "db=DATABASE_NAME" \
  --data-urlencode "q=SELECT * FROM MEASUREMENT"

Replace the following:

  • DATABASE_NAME: the database to query
  • AUTH_TOKEN: a database token with sufficient permissions to the database

TokenAuthentication

Type
apiKey
In
header
Parameter Name
Authorization

Use InfluxDB v2 Token authentication to provide an authorization token to InfluxDB 3. The v2 Token scheme works with v1 and v2 compatibility endpoints in InfluxDB 3. In your API requests, send an Authorization header. For the header value, provide the word Token followed by a space and a database token. The word Token is case-sensitive.

Syntax

Authorization: Token AUTH_TOKEN

Example

########################################################
# Use the Token authentication scheme with /api/v2/write
# to write data.
########################################################
curl --request post "http://localhost:8181/api/v2/write?bucket=DATABASE_NAME&precision=s" \
  --header "Authorization: Token AUTH_TOKEN" \
  --data-binary 'home,room=kitchen temp=72 1463683075'