# Values

> List, read, create, change and delete the values your workflows keep between runs, and list, add, replace or remove the rows of a table.

Web page: https://docs.lodol.com/docs/api/values

A value is data kept for workflows to read and save between runs: a setting, a counter, a list, a record or a table of rows. Workflows read one as `@values.NAME`. Reading values requires the `values:read` scope, changing them `values:write`, and deleting them `values:delete`.

Secrets, such as API keys and passwords, aren't values here: they're never listed, and they're added and changed only on the **Secrets** page in Lodol.

## The value object

```json
{
  "id": "66b3d5f7a9c1e3f5a7b9c1d2",
  "name": "approval_threshold",
  "type": "number",
  "applies_to": "all_workflows",
  "workflows": [],
  "workflows_can_change": false,
  "updated_at": "2026-11-30T19:50:02.495000+00:00",
  "value": 250
}
```

A table has its `columns` and `row_count` in place of `value`. Its rows are a list of their own: see [List a table's rows](#list-a-tables-rows).

```json
{
  "id": "66b3d5f7a9c1e3f5a7b9c1d3",
  "name": "customers",
  "type": "table",
  "applies_to": "chosen_workflows",
  "workflows": [{ "id": "665f1a2b3c4d5e6f7a8b9c0d", "name": "Monthly Client Report" }],
  "workflows_can_change": true,
  "updated_at": "2026-11-30T19:50:02.240000+00:00",
  "columns": ["name", "email", "plan"],
  "row_count": 2
}
```

<Fields title="Fields">
<Field id="id" type="string" description="The value's ID." />
<Field id="name" type="string" description="Its name, which workflows read it by. It can't be changed." />
<Field id="type" type="string" description="What it holds, in the workflow format's words: text, number, boolean, list, object, null, or table." />
<Field id="applies_to" type="string" description="Which workflows can use it: all_workflows, or chosen_workflows for the ones in workflows." />
<Field id="workflows" type="array" description="With chosen_workflows, the workflows that can use it, each with its id and name. Empty otherwise." />
<Field id="workflows_can_change" type="boolean" description="Whether running workflows may change it, such as a counter they add to or a table they add rows to. Otherwise they only read it." />
<Field id="updated_at" type="string or null" description="When it last changed, in ISO 8601. null in List values." />
<Field id="value" type="any" description="What a value that isn't a table holds. List values leaves it out: Get a value has it." />
<Field id="columns" type="array" description="For a table: its column names, in order." />
<Field id="row_count" type="integer" description="For a table: how many rows it has." />
</Fields>

A value can hold text and records of up to 60 KB, and a table up to 5,000 rows and 1 MB.

---

## List values

<Endpoint method="GET" path="/api/v1/values" />

Returns the values the member who created the key can see, in order of name, a page at a time. Requires the `values:read` scope.

<Fields title="Query parameters">
<Field id="search" type="string" description="Only values whose name contains this text, in any case." />
<Field id="limit" type="integer" description="How many to return, from 1 to 100." facts="Default: `50`." />
<Field id="cursor" type="string" description="For the next page: the next_cursor of the page you have." />
</Fields>

```bash tab="cURL" tab-group="lang"
curl "https://api-prod.lodol.com/api/v1/values?search=customers" \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

```js tab="JavaScript"
const response = await fetch('https://api-prod.lodol.com/api/v1/values?search=customers', {
  headers: { Authorization: `Bearer ${process.env.LODOL_API_KEY}` },
});
const { values, next_cursor } = await response.json();
```

```python tab="Python"
response = requests.get(
    "https://api-prod.lodol.com/api/v1/values",
    headers={"Authorization": f"Bearer {os.environ['LODOL_API_KEY']}"},
    params={"search": "customers"},
)
values = response.json()["values"]
```

**Response `200`:** a page of [values](#the-value-object), each without what it holds and with `updated_at` set to `null`: [Get a value](#get-a-value) has both. `next_cursor` gets the next page; see [Paging through lists](https://docs.lodol.com/docs/api.md#paging-through-lists).

```json
{
  "values": [
    {
      "id": "66b3d5f7a9c1e3f5a7b9c1d3",
      "name": "customers",
      "type": "table",
      "applies_to": "chosen_workflows",
      "workflows": [{ "id": "665f1a2b3c4d5e6f7a8b9c0d", "name": "Monthly Client Report" }],
      "workflows_can_change": true,
      "updated_at": null,
      "columns": ["name", "email", "plan"],
      "row_count": 2
    }
  ],
  "next_cursor": null
}
```

---

## Get a value

<Endpoint method="GET" path="/api/v1/values/:id" />

Returns one [value](#the-value-object), with what it holds. Requires the `values:read` scope. A value that doesn't exist, or that the key's member can't see, returns `404`.

```bash
curl https://api-prod.lodol.com/api/v1/values/66b3d5f7a9c1e3f5a7b9c1d2 \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

**Response `200`:**

```json
{
  "id": "66b3d5f7a9c1e3f5a7b9c1d2",
  "name": "approval_threshold",
  "type": "number",
  "applies_to": "all_workflows",
  "workflows": [],
  "workflows_can_change": false,
  "updated_at": "2026-11-30T19:50:02.495000+00:00",
  "value": 250
}
```

---

## Create a value

<Endpoint method="POST" path="/api/v1/values" />

Creates a value. Requires the `values:write` scope. The member who created the key needs the role permission to manage the workspace's values, or, for a value only one workflow can use, permission to edit workflows and edit access to that workflow.

<Fields title="Headers">
<Field id="Idempotency-Key" type="string" description="Makes the request safe to retry. See Idempotency." />
</Fields>

<Fields title="Body">
<Field id="name" type="string" description="Its name, up to 100 characters: letters, numbers and underscores, starting with a letter or an underscore. Names are shared by the workspace, and can't be changed later." facts="Required." />
<Field id="applies_to" type="string" description="all_workflows, or chosen_workflows for the ones in workflow_ids." facts="Required." />
<Field id="workflow_ids" type="array" description="With chosen_workflows: the IDs of the workflows that can use it, up to 50." />
<Field id="value" type="any" description="What it holds: text, a number, true or false, a list, a record, or a table as a list of rows, each an object of column name to cell. Required unless you give columns." />
<Field id="columns" type="array" description="To start an empty table: its column names, in order, up to 100. Leave value out." />
<Field id="workflows_can_change" type="boolean" description="Whether running workflows may change it." facts="Default: `false`." />
</Fields>

```bash tab="cURL" tab-group="lang"
curl -X POST https://api-prod.lodol.com/api/v1/values \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "customers",
    "applies_to": "chosen_workflows",
    "workflow_ids": ["665f1a2b3c4d5e6f7a8b9c0d"],
    "columns": ["name", "email", "plan"],
    "workflows_can_change": true
  }'
```

```js tab="JavaScript"
const response = await fetch('https://api-prod.lodol.com/api/v1/values', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LODOL_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'approval_threshold', applies_to: 'all_workflows', value: 250 }),
});
const value = await response.json();
```

```python tab="Python"
response = requests.post(
    "https://api-prod.lodol.com/api/v1/values",
    headers={"Authorization": f"Bearer {os.environ['LODOL_API_KEY']}"},
    json={"name": "approval_threshold", "applies_to": "all_workflows", "value": 250},
)
value = response.json()
```

**Response `201`:** the new [value](#the-value-object).

```json
{
  "id": "66b3d5f7a9c1e3f5a7b9c1d3",
  "name": "customers",
  "type": "table",
  "applies_to": "chosen_workflows",
  "workflows": [{ "id": "665f1a2b3c4d5e6f7a8b9c0d", "name": "Monthly Client Report" }],
  "workflows_can_change": true,
  "updated_at": "2026-11-30T19:49:41.106000+00:00",
  "columns": ["name", "email", "plan"],
  "row_count": 0
}
```

A name that's already in use returns `400`, naming the value that has it.

---

## Change a value

<Endpoint method="PATCH" path="/api/v1/values/:id" />

Changes what a value holds, which workflows can use it, or whether they may change it. Requires the `values:write` scope, and the role permissions [Create a value](#create-a-value) needs; changing which workflows can use it takes the permission to manage the workspace's values. Giving `value` replaces everything it holds, rows a workflow saved included: to change a table a row at a time, use the [row endpoints](#add-rows-to-a-table).

<Fields title="Body" description="At least one of value, applies_to and workflows_can_change.">
<Field id="value" type="any" description="What it now holds, as for Create a value." />
<Field id="applies_to" type="string" description="all_workflows, or chosen_workflows for the ones in workflow_ids." />
<Field id="workflow_ids" type="array" description="With applies_to chosen_workflows: the workflows that can use it." />
<Field id="workflows_can_change" type="boolean" description="Whether running workflows may change it." />
</Fields>

```bash
curl -X PATCH https://api-prod.lodol.com/api/v1/values/66b3d5f7a9c1e3f5a7b9c1d2 \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value": 300}'
```

**Response `200`:** the [value](#the-value-object) as it now is.

```json
{
  "id": "66b3d5f7a9c1e3f5a7b9c1d2",
  "name": "approval_threshold",
  "type": "number",
  "applies_to": "all_workflows",
  "workflows": [],
  "workflows_can_change": false,
  "updated_at": "2026-11-30T19:50:02.495000+00:00",
  "value": 300
}
```

---

## Delete a value

<Endpoint method="DELETE" path="/api/v1/values/:id" />

Deletes a value for good, a table with all its rows. It can't be restored, and a workflow step that reads it finds nothing after. Requires the `values:delete` scope (**Delete values**, which you tick when you create the key), and the role permissions [Create a value](#create-a-value) needs.

```bash
curl -X DELETE https://api-prod.lodol.com/api/v1/values/66b3d5f7a9c1e3f5a7b9c1d2 \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

**Response `200`:**

```json
{ "id": "66b3d5f7a9c1e3f5a7b9c1d2", "deleted": true, "restorable_until": null }
```

A value that doesn't exist, or has already been deleted, returns `404`.

---

## List a table's rows

<Endpoint method="GET" path="/api/v1/values/:id/rows" />

Returns a table's rows, in order, a page at a time. Requires the `values:read` scope.

<Fields title="Query parameters">
<Field id="limit" type="integer" description="How many rows to return, from 1 to 100." facts="Default: `50`." />
<Field id="cursor" type="string" description="For the next page: the next_cursor of the page you have." />
</Fields>

```bash
curl "https://api-prod.lodol.com/api/v1/values/66b3d5f7a9c1e3f5a7b9c1d3/rows?limit=2" \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

**Response `200`:** each row with its `index`, counting from 0, which replacing and removing a row take, and its `data`, an object of column name to cell.

```json
{
  "rows": [
    { "index": 0, "data": { "name": "Ada Lovelace", "email": "ada@example.com", "plan": "Pro" } },
    { "index": 1, "data": { "name": "Grace Hopper", "email": "grace@example.com", "plan": "Builder" } }
  ],
  "next_cursor": null
}
```

---

## Add rows to a table

<Endpoint method="POST" path="/api/v1/values/:id/rows" />

Adds rows to the end of a table, in order. Rows workflows add meanwhile are kept. Requires the `values:write` scope.

<Fields title="Body">
<Field id="rows" type="array" description="1 to 50 rows, each an object of column name to cell. A column the table doesn't have yet is added." facts="Required." />
</Fields>

```bash
curl -X POST https://api-prod.lodol.com/api/v1/values/66b3d5f7a9c1e3f5a7b9c1d3/rows \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rows": [
    {"name": "Ada Lovelace", "email": "ada@example.com", "plan": "Pro"},
    {"name": "Grace Hopper", "email": "grace@example.com", "plan": "Builder"}
  ]}'
```

**Response `201`:** the table, as a [value](#the-value-object), with its new `row_count`.

```json
{
  "id": "66b3d5f7a9c1e3f5a7b9c1d3",
  "name": "customers",
  "type": "table",
  "applies_to": "chosen_workflows",
  "workflows": [{ "id": "665f1a2b3c4d5e6f7a8b9c0d", "name": "Monthly Client Report" }],
  "workflows_can_change": true,
  "updated_at": "2026-11-30T19:50:02.240000+00:00",
  "columns": ["name", "email", "plan"],
  "row_count": 2
}
```

If a row can't be added, the rows before it stay added, and the message says how many were.

---

## Replace a table row

<Endpoint method="PUT" path="/api/v1/values/:id/rows/:index" />

Replaces one row of a table. `:index` is the row's `index` as [List a table's rows](#list-a-tables-rows) returned it. Requires the `values:write` scope.

Send the row's `data` as you last read it in `current`. If a workflow or a person has changed that row since, nothing is changed and the request gets `409` with the code `row_changed`: read the rows again and use the row as it is now.

<Fields title="Body">
<Field id="current" type="object" description="The row's data exactly as List a table's rows returned it." facts="Required." />
<Field id="row" type="object" description="The row to put in its place." facts="Required." />
</Fields>

```bash
curl -X PUT https://api-prod.lodol.com/api/v1/values/66b3d5f7a9c1e3f5a7b9c1d3/rows/1 \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "current": {"name": "Grace Hopper", "email": "grace@example.com", "plan": "Builder"},
    "row": {"name": "Grace Hopper", "email": "grace@example.com", "plan": "Pro"}
  }'
```

**Response `200`:** the row as it now is.

```json
{ "index": 1, "data": { "name": "Grace Hopper", "email": "grace@example.com", "plan": "Pro" } }
```

**Response `409`,** when the row changed since you read it:

```json
{
  "error": "That row has changed since you read it (a workflow or a person changed the table), so it was left as it is. Read the table again with GET /api/v1/values/<value_id>/rows and use the row as it is now.",
  "error_code": "row_changed"
}
```

---

## Remove a table row

<Endpoint method="DELETE" path="/api/v1/values/:id/rows/:index" />

Removes one row from a table, for good. Rows after it move up one place, so their indexes change. Like replacing a row, it takes the row's `data` as you last read it, in a JSON body, and removes nothing, answering `409` with the code `row_changed`, if the row has changed since. Requires the `values:write` scope.

<Fields title="Body">
<Field id="current" type="object" description="The row's data exactly as List a table's rows returned it." facts="Required." />
</Fields>

```bash
curl -X DELETE https://api-prod.lodol.com/api/v1/values/66b3d5f7a9c1e3f5a7b9c1d3/rows/0 \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"current": {"name": "Ada Lovelace", "email": "ada@example.com", "plan": "Pro"}}'
```

**Response `200`:**

```json
{ "index": 0, "deleted": true, "restorable_until": null }
```
