---
title: Variables
description: Create and manage variables for use in InfluxDB Cloud dashboards.
url: https://docs.influxdata.com/influxdb/cloud/api/variables/
estimated_tokens: 19555
product: InfluxDB Cloud (TSM)
version: cloud
---

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

Create and manage variables for use in InfluxDB Cloud 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 \
  "https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/variables" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

200 A 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"
      ]
    }
  ]
}
```

400 Non 2XX error response from server.

`code` required string

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.

default Non 2XX error response from server.

`code` required string

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 body required

Variable to create

Content-Type: `application/json`

`arguments` required string

`createdAt` string <date-time>

`description` string

`id` string

`labels` string

`links` object

`labels` string <uri>

`org` string <uri>

`self` string <uri>

`name` required string

`orgID` required string

`selected` string\[\]

`sort_order` integer

`updatedAt` string <date-time>

Example request [Ask AI about this](#)

```sh
curl --request POST \
  "https://us-east-1-1.aws.cloud2.influxdata.com/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"
  ],
  "sort_order": 0,
  "updatedAt": "UPDATEDAT"
}'
```

#### Responses

201 Variable created

`arguments` required string

`createdAt` string <date-time>

`description` string

`id` string

`labels` string

`links` object

`labels` string <uri>

`org` string <uri>

`self` string <uri>

`name` required string

`orgID` required string

`selected` string\[\]

`sort_order` integer

`updatedAt` string <date-time>

default Non 2XX error response from server.

`code` required string

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` required string

The variable ID.

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

Example request [Ask AI about this](#)

```sh
curl --request GET \
  "https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/variables/{variableID}" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

200 Variable found

`arguments` required string

`createdAt` string <date-time>

`description` string

`id` string

`labels` string

`links` object

`labels` string <uri>

`org` string <uri>

`self` string <uri>

`name` required string

`orgID` required string

`selected` string\[\]

`sort_order` integer

`updatedAt` string <date-time>

404 Non 2XX error response from server.

`code` required string

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.

default Non 2XX error response from server.

`code` required string

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` required string

The variable ID.

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

#### Request body required

Variable to replace

Content-Type: `application/json`

`arguments` required string

`createdAt` string <date-time>

`description` string

`id` string

`labels` string

`links` object

`labels` string <uri>

`org` string <uri>

`self` string <uri>

`name` required string

`orgID` required string

`selected` string\[\]

`sort_order` integer

`updatedAt` string <date-time>

Example request [Ask AI about this](#)

```sh
curl --request PUT \
  "https://us-east-1-1.aws.cloud2.influxdata.com/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"
  ],
  "sort_order": 0,
  "updatedAt": "UPDATEDAT"
}'
```

#### Responses

200 Variable updated

`arguments` required string

`createdAt` string <date-time>

`description` string

`id` string

`labels` string

`links` object

`labels` string <uri>

`org` string <uri>

`self` string <uri>

`name` required string

`orgID` required string

`selected` string\[\]

`sort_order` integer

`updatedAt` string <date-time>

default Non 2XX error response from server.

`code` required string

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` required string

The variable ID.

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

#### Request body required

Variable update to apply

Content-Type: `application/json`

`arguments` required string

`createdAt` string <date-time>

`description` string

`id` string

`labels` string

`links` object

`labels` string <uri>

`org` string <uri>

`self` string <uri>

`name` required string

`orgID` required string

`selected` string\[\]

`sort_order` integer

`updatedAt` string <date-time>

Example request [Ask AI about this](#)

```sh
curl --request PATCH \
  "https://us-east-1-1.aws.cloud2.influxdata.com/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"
  ],
  "sort_order": 0,
  "updatedAt": "UPDATEDAT"
}'
```

#### Responses

200 Variable updated

`arguments` required string

`createdAt` string <date-time>

`description` string

`id` string

`labels` string

`links` object

`labels` string <uri>

`org` string <uri>

`self` string <uri>

`name` required string

`orgID` required string

`selected` string\[\]

`sort_order` integer

`updatedAt` string <date-time>

default Non 2XX error response from server.

`code` required string

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` required string

The variable ID.

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

Example request [Ask AI about this](#)

```sh
curl --request DELETE \
  "https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/variables/{variableID}" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

204 Variable deleted

default Non 2XX error response from server.

`code` required string

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` required string

The variable ID.

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

Example request [Ask AI about this](#)

```sh
curl --request GET \
  "https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/variables/{variableID}/labels" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

200 A list of all labels for a variable

`labels` string

`links` string

default Unexpected error

`code` required string

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` required string

The variable ID.

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

#### Request body required

Label to add

Content-Type: `application/json`

`labelID` required string

A label ID. Specifies the label to attach.

Example request [Ask AI about this](#)

```sh
curl --request POST \
  "https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/variables/{variableID}/labels" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "labelID": "LABELID"
}'
```

#### Responses

201 The newly added label

`label` string

`links` string

default Unexpected error

`code` required string

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` required string

The variable ID.

`labelID` required string

The label ID to delete.

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

Example request [Ask AI about this](#)

```sh
curl --request DELETE \
  "https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/variables/{variableID}/labels/{labelID}" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

204 Delete has been accepted

404 Variable not found

`code` required string

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.

default Unexpected error

`code` required string

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.
