---
title: var Requests - API Reference - 5.x
description: Provides a simple interface for managing data stored in DB Notefiles.
source_url: https://dev.blues.io/api-reference/notecard-api/var-requests/5-x/
canonical_url: https://dev.blues.io/api-reference/notecard-api/var-requests/latest/
markdown_url: https://dev.blues.io/api-reference/notecard-api/var-requests/5-x.md
---

# var Requests

The `var` APIs provide a simple abstraction over the existing [note.update](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-update), [note.get](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-get), and [note.delete](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-update) APIs for managing data stored in [DB Notefiles](https://dev.blues.io/notecard/notecard-walkthrough/inbound-requests-and-shared-data.md#using-database-files-for-replicated-state).

## var.delete {#var-delete}

Supported on

(Cell, Cell+WiFi, LoRa, Skylo, WiFi)

> **Note:**
>
> This request is not available in the currently selected Notecard firmware version.

## var.get {#var-get}

Supported on

(Cell, Cell+WiFi, LoRa, Skylo, WiFi)

> **Note:**
>
> This request is not available in the currently selected Notecard firmware version.

## var.set {#var-set}

Supported on

(Cell, Cell+WiFi, LoRa, Skylo, WiFi)

Adds or updates a Note in a **DB Notefile**, replacing the existing body with the specified key-value pair where text, value, or flag is the key. Provides a simpler interface to the [note.update](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-update) API.

Arguments

### `flag` {#var-set--flag}

*boolean (optional)*

The boolean value to be stored in the DB Notefile.

### `name` {#var-set--name}

*string*

The unique Note ID.

### `sync` {#var-set--sync}

*boolean (optional)*

Set to `true` to immediately sync any changes.

### `text` {#var-set--text}

*string (optional)*

The string-based value to be stored in the DB Notefile.

### `value` {#var-set--value}

*number (optional)*

The numeric value to be stored in the DB Notefile.

**Set Text Variable**

**JSON**

```json
{
  "req": "var.set",
  "name": "status",
  "text": "open"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.set");
JAddStringToObject(req, "name", "status");
JAddStringToObject(req, "text", "open");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.set"}
req["name"] = "status"
req["text"] = "open"
rsp = card.Transaction(req)
```

Set a text variable named `"status"` to `"open"` in the default `vars.db` DB Notefile.

**Set Numeric Variable**

**JSON**

```json
{
  "req": "var.set",
  "name": "temperature",
  "value": 23.5,
  "file": "sensors.db"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.set");
JAddStringToObject(req, "name", "temperature");
JAddNumberToObject(req, "value", 23.5);
JAddStringToObject(req, "file", "sensors.db");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.set"}
req["name"] = "temperature"
req["value"] = 23.5
req["file"] = "sensors.db"
rsp = card.Transaction(req)
```

Set a numeric variable named `"temperature"` to `23` in a specific DB Notefile.

**Set Boolean Variable with Sync**

**JSON**

```json
{
  "req": "var.set",
  "name": "active",
  "flag": true,
  "sync": true
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.set");
JAddStringToObject(req, "name", "active");
JAddBoolToObject(req, "flag", true);
JAddBoolToObject(req, "sync", true);

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.set"}
req["name"] = "active"
req["flag"] = True
req["sync"] = True
rsp = card.Transaction(req)
```

Set a boolean variable named `"active"` to `true` and immediately sync changes.

**Response Members**

None: an empty object `{}` means success.

Related Articles

- [Storing Simple Values with the var API](https://dev.blues.io/guides-and-tutorials/notecard-guides/storing-device-state-with-db-notefiles.md#storing-simple-values-with-the-var-api)
- [Simplifying DB Notefiles with the var API](https://dev.blues.io/notecard/notecard-walkthrough/inbound-requests-and-shared-data.md#simplifying-db-notefiles-with-the-var-api)

[ntn Requests](https://dev.blues.io/api-reference/notecard-api/ntn-requests/latest.md "ntn Requests") [web Requests](https://dev.blues.io/api-reference/notecard-api/web-requests/latest.md "web Requests")
