# Device Environment Variable

## Available Fields

| Field        |
| ------------ |
| `id`         |
| `created_at` |
| `device`     |
| `name`       |
| `value`      |

***

## Examples

### Get all device environment variables for a device by UUID

```bash
GET "https://api.balena-cloud.com/v7/device_environment_variable?\$filter=device/any(d:d/uuid%20eq%20'<DEVICE_UUID>')" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTH_TOKEN>" 
```

### Get all device environment variables for a device by ID

```bash
GET "https://api.balena-cloud.com/v7/device_environment_variable?\$filter=device%20eq%20<DEVICE ID>" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTH_TOKEN>" 
```

### Create a device environment variable

```bash
POST "https://api.balena-cloud.com/v7/device_environment_variable" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTH_TOKEN>" \
--data '{
    "device": "<DEVICE ID>",
    "name": "<NAME>",
    "value": "<VALUE>"
}'
```

### Update a device environment variable

```bash
PATCH "https://api.balena-cloud.com/v7/device_environment_variable(<ID>)" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTH_TOKEN>" \
--data '{
    "value": "<NEW VALUE>"
}'
```

### Remove a device environment variable

```bash
DELETE "https://api.balena-cloud.com/v7/device_environment_variable(<ID>)" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTH_TOKEN>" 
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.balena.io/reference/api/resources/device_environment_variable.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
