influxdb.api() function

influxdb.api() is experimental and subject to change at any time.

influxdb.api() submits an HTTP request to the specified InfluxDB API path and returns a record containing the HTTP status code, response headers, and the response body.

Note: influxdb.api() uses the authorization of the specified token or, if executed from the InfluxDB UI, the authorization of the InfluxDB user that invokes the script. Authorization permissions and limits apply to each request.

Response format

influxdb.api() returns a record with the following properties:

  • statusCode: HTTP status code returned by the GET request (int).
  • headers: HTTP response headers (dict).
  • body: HTTP response body (bytes).
Function type signature
    method: string,
    path: string,
    ?body: bytes,
    ?headers: [string:string],
    ?host: string,
    ?query: [string:string],
    ?timeout: duration,
    ?token: string,
) => {statusCode: int, headers: [string:string], body: bytes}
For more information, see Function type signatures.



(Required) HTTP request method.


(Required) InfluxDB API path.


InfluxDB host URL (Required when executed outside of InfluxDB). Default is "".


InfluxDB API token (Required when executed outside of InfluxDB). Default is "".


HTTP request headers.


URL query parameters.


HTTP request timeout. Default is 30s.


HTTP request body as bytes.


Retrieve the health of an InfluxDB OSS instance

import "experimental/influxdb"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "INFLUX_TOKEN")

response = influxdb.api(method: "get", path: "/health", host: "http://localhost:8086", token: token)

string(v: response.body)

Create a bucket through the InfluxDB Cloud API

import "experimental/influxdb"
import "json"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "INFLUX_TOKEN")

    method: "post",
    path: "/api/v2/buckets",
    host: "",
    token: token,
            v: {
                name: "example-bucket",
                description: "This is an example bucket.",
                orgID: "x000X0x0xx0X00x0",
                retentionRules: [],

Was this page helpful?

Thank you for your feedback!

Linux Package Signing Key Rotation

All signed InfluxData Linux packages have been resigned with an updated key. If using Linux, you may need to update your package configuration to continue to download and verify InfluxData software packages.

For more information, see the Linux Package Signing Key Rotation blog post.

State of the InfluxDB Cloud (IOx) documentation

The new documentation for InfluxDB Cloud backed by InfluxDB IOx is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.