# Device Environment Variable

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

> \## Device Environment Variable Resource Fields\
> \
> \| Field |\
> \| :--- |\
> \| \`id\` |\
> \| \`created\_at\` |\
> \| \`device\` |\
> \| \`name\` |\
> \| \`value\` |\
> \
> \
> \---\
> \
> \`GET /v7/device\_environment\_variable\`\
> \
> \
> \### Usage Variations\
> \
> \--- \
> \#### Get all device environment variables for a device by ID\
> \`GET /v7/device\_environment\_variable?$filter=device eq \<DEVICE ID>\`

```json
{"openapi":"3.0.0","info":{"title":"Balena API Spec","version":"7.0.0"},"servers":[{"url":"https://api.balena-cloud.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"paths":{"/v7/device_environment_variable":{"get":{"tags":["Device Environment Variable"],"summary":"Get all device environment variables for a device by UUID","description":"## Device Environment Variable Resource Fields\n\n| Field |\n| :--- |\n| `id` |\n| `created_at` |\n| `device` |\n| `name` |\n| `value` |\n\n\n---\n\n`GET /v7/device_environment_variable`\n\n\n### Usage Variations\n\n--- \n#### Get all device environment variables for a device by ID\n`GET /v7/device_environment_variable?$filter=device eq <DEVICE ID>`"}}}}
```

## Create a device environment variable

> \`POST /v7/device\_environment\_variable\`\
> \
> \*\*Request Body:\*\*\
> \`\`\`json\
> {\
> &#x20;   "device": \<DEVICE ID>,\
> &#x20;   "name": \<NAME>,\
> &#x20;   "value": \<VALUE>\
> }\
> \`\`\`

````json
{"openapi":"3.0.0","info":{"title":"Balena API Spec","version":"7.0.0"},"servers":[{"url":"https://api.balena-cloud.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"paths":{"/v7/device_environment_variable":{"post":{"tags":["Device Environment Variable"],"summary":"Create a device environment variable","description":"`POST /v7/device_environment_variable`\n\n**Request Body:**\n```json\n{\n    \"device\": <DEVICE ID>,\n    \"name\": <NAME>,\n    \"value\": <VALUE>\n}\n```","requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}}}}}}
````

## Remove a device environment variable

> \`DELETE /v7/device\_environment\_variable(\<ID>)\`

```json
{"openapi":"3.0.0","info":{"title":"Balena API Spec","version":"7.0.0"},"servers":[{"url":"https://api.balena-cloud.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"paths":{"/v7/device_environment_variable({ID})":{"delete":{"tags":["Device Environment Variable"],"summary":"Remove a device environment variable","description":"`DELETE /v7/device_environment_variable(<ID>)`","parameters":[{"name":"ID","in":"path","required":true}]}}}}
```

## Update a device environment variable

> \`PATCH /v7/device\_environment\_variable(\<ID>)\`\
> \
> \*\*Request Body:\*\*\
> \`\`\`json\
> {\
> &#x20;   "value": \<NEW VALUE>\
> }\
> \`\`\`

````json
{"openapi":"3.0.0","info":{"title":"Balena API Spec","version":"7.0.0"},"servers":[{"url":"https://api.balena-cloud.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"paths":{"/v7/device_environment_variable({ID})":{"patch":{"tags":["Device Environment Variable"],"summary":"Update a device environment variable","description":"`PATCH /v7/device_environment_variable(<ID>)`\n\n**Request Body:**\n```json\n{\n    \"value\": <NEW VALUE>\n}\n```","parameters":[{"name":"ID","in":"path","required":true}],"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}}}}}}
````
