---
title: Variables
description: Create and manage variables for use in InfluxDB OSS v2 dashboards.
url: https://docs.influxdata.com/influxdb/v2/api/variables/
estimated_tokens: 3913
product: InfluxDB OSS v2
version: v2
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb/v2/api/variables/
---

[Download InfluxDB API Spec](/openapi/influxdb-oss-v2-api.yml)

Create and manage variables for use in InfluxDB OSS v2 dashboards.

GET`/api/v2/variables`

### List all variables

#### Parameters

##### Query parameters

`org`string

The name of the organization.

`orgID`string

The organization ID.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

Example request[Ask AI about this](#)

```sh
curl --request GET \
  "http://localhost:8086/api/v2/variables" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

200A list of variables for an organization

`variables`object[]

Example request body

```json
{
  "variables": [
    {
      "arguments": {
        "type": "constant",
        "values": [
          "howdy",
          "hello",
          "hi",
          "yo",
          "oy"
        ]
      },
      "id": "1221432",
      "name": ":ok:",
      "selected": [
        "hello"
      ]
    },
    {
      "arguments": {
        "type": "map",
        "values": {
          "a": "fdjaklfdjkldsfjlkjdsa",
          "b": "dfaksjfkljekfajekdljfas",
          "c": "fdjksajfdkfeawfeea"
        }
      },
      "id": "1221432",
      "name": ":ok:",
      "selected": [
        "c"
      ]
    },
    {
      "arguments": {
        "language": "flux",
        "query": "from(bucket: \"foo\") |\u003e showMeasurements()",
        "type": "query"
      },
      "id": "1221432",
      "name": ":ok:",
      "selected": [
        "host"
      ]
    }
  ]
}
```

400Non 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

defaultNon 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

POST`/api/v2/variables`

### Create a variable

#### Parameters

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

#### Request bodyrequired

Variable to create

Content-Type:`application/json`

`arguments`requiredstring

`createdAt`string \<date-time\>

`description`string

`id`string

`labels`string

`links`object

`labels`string \<uri\>

`org`string \<uri\>

`self`string \<uri\>

`name`requiredstring

`orgID`requiredstring

`selected`string[]

`updatedAt`string \<date-time\>

Example request[Ask AI about this](#)

```sh
curl --request POST \
  "http://localhost:8086/api/v2/variables" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "arguments": {},
  "createdAt": "CREATEDAT",
  "description": "DESCRIPTION",
  "id": "ID",
  "labels": [],
  "links": {},
  "name": "NAME",
  "orgID": "ORGID",
  "selected": [
    "example"
  ],
  "updatedAt": "UPDATEDAT"
}'
```

#### Responses

201Variable created

`arguments`requiredstring

`createdAt`string \<date-time\>

`description`string

`id`string

`labels`string

`links`object

`labels`string \<uri\>

`org`string \<uri\>

`self`string \<uri\>

`name`requiredstring

`orgID`requiredstring

`selected`string[]

`updatedAt`string \<date-time\>

defaultNon 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

GET`/api/v2/variables/{variableID}`

### Retrieve a variable

#### Parameters

##### Path parameters

`variableID`requiredstring

The variable ID.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

Example request[Ask AI about this](#)

```sh
curl --request GET \
  "http://localhost:8086/api/v2/variables/{variableID}" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

200Variable found

`arguments`requiredstring

`createdAt`string \<date-time\>

`description`string

`id`string

`labels`string

`links`object

`labels`string \<uri\>

`org`string \<uri\>

`self`string \<uri\>

`name`requiredstring

`orgID`requiredstring

`selected`string[]

`updatedAt`string \<date-time\>

404Non 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

defaultNon 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

PUT`/api/v2/variables/{variableID}`

### Replace a variable

#### Parameters

##### Path parameters

`variableID`requiredstring

The variable ID.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

#### Request bodyrequired

Variable to replace

Content-Type:`application/json`

`arguments`requiredstring

`createdAt`string \<date-time\>

`description`string

`id`string

`labels`string

`links`object

`labels`string \<uri\>

`org`string \<uri\>

`self`string \<uri\>

`name`requiredstring

`orgID`requiredstring

`selected`string[]

`updatedAt`string \<date-time\>

Example request[Ask AI about this](#)

```sh
curl --request PUT \
  "http://localhost:8086/api/v2/variables/{variableID}" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "arguments": {},
  "createdAt": "CREATEDAT",
  "description": "DESCRIPTION",
  "id": "ID",
  "labels": [],
  "links": {},
  "name": "NAME",
  "orgID": "ORGID",
  "selected": [
    "example"
  ],
  "updatedAt": "UPDATEDAT"
}'
```

#### Responses

200Variable updated

`arguments`requiredstring

`createdAt`string \<date-time\>

`description`string

`id`string

`labels`string

`links`object

`labels`string \<uri\>

`org`string \<uri\>

`self`string \<uri\>

`name`requiredstring

`orgID`requiredstring

`selected`string[]

`updatedAt`string \<date-time\>

defaultNon 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

PATCH`/api/v2/variables/{variableID}`

### Update a variable

#### Parameters

##### Path parameters

`variableID`requiredstring

The variable ID.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

#### Request bodyrequired

Variable update to apply

Content-Type:`application/json`

`arguments`requiredstring

`createdAt`string \<date-time\>

`description`string

`id`string

`labels`string

`links`object

`labels`string \<uri\>

`org`string \<uri\>

`self`string \<uri\>

`name`requiredstring

`orgID`requiredstring

`selected`string[]

`updatedAt`string \<date-time\>

Example request[Ask AI about this](#)

```sh
curl --request PATCH \
  "http://localhost:8086/api/v2/variables/{variableID}" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "arguments": {},
  "createdAt": "CREATEDAT",
  "description": "DESCRIPTION",
  "id": "ID",
  "labels": [],
  "links": {},
  "name": "NAME",
  "orgID": "ORGID",
  "selected": [
    "example"
  ],
  "updatedAt": "UPDATEDAT"
}'
```

#### Responses

200Variable updated

`arguments`requiredstring

`createdAt`string \<date-time\>

`description`string

`id`string

`labels`string

`links`object

`labels`string \<uri\>

`org`string \<uri\>

`self`string \<uri\>

`name`requiredstring

`orgID`requiredstring

`selected`string[]

`updatedAt`string \<date-time\>

defaultNon 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

DELETE`/api/v2/variables/{variableID}`

### Delete a variable

#### Parameters

##### Path parameters

`variableID`requiredstring

The variable ID.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

Example request[Ask AI about this](#)

```sh
curl --request DELETE \
  "http://localhost:8086/api/v2/variables/{variableID}" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

204Variable deleted

defaultNon 2XX error response from server.

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

GET`/api/v2/variables/{variableID}/labels`

### List all labels for a variable

#### Parameters

##### Path parameters

`variableID`requiredstring

The variable ID.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

Example request[Ask AI about this](#)

```sh
curl --request GET \
  "http://localhost:8086/api/v2/variables/{variableID}/labels" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

200A list of all labels for a variable

`labels`string

`links`string

defaultUnexpected error

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

POST`/api/v2/variables/{variableID}/labels`

### Add a label to a variable

#### Parameters

##### Path parameters

`variableID`requiredstring

The variable ID.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

#### Request bodyrequired

Label to add

Content-Type:`application/json`

`labelID`requiredstring

A label ID.
Specifies the label to attach.

Example request[Ask AI about this](#)

```sh
curl --request POST \
  "http://localhost:8086/api/v2/variables/{variableID}/labels" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "labelID": "LABELID"
}'
```

#### Responses

201The newly added label

`label`string

`links`string

defaultUnexpected error

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

DELETE`/api/v2/variables/{variableID}/labels/{labelID}`

### Delete a label from a variable

#### Parameters

##### Path parameters

`variableID`requiredstring

The variable ID.

`labelID`requiredstring

The label ID to delete.

##### Header parameters

`Zap-Trace-Span`string

OpenTracing span context

Example request[Ask AI about this](#)

```sh
curl --request DELETE \
  "http://localhost:8086/api/v2/variables/{variableID}/labels/{labelID}" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

204Delete has been accepted

404Variable not found

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.

defaultUnexpected error

`code`requiredstring

code is the machine-readable error code.

Allowed:`internal error`, `not implemented`, `not found`, `conflict`, `invalid`, `unprocessable entity`, `empty value`, `unavailable`, `forbidden`, `too many requests`, `unauthorized`, `method not allowed`, `request too large`, `unsupported media type`

`err`string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message`string

Human-readable message.

`op`string

Describes the logical code operation when the error occurred. Useful for debugging.
