# Update rows in bulk: a value per row, or set/set_expr over a selector

> Source: https://elaichi.ai/docs/api-reference/collections/collection/updatecollectionrows/

`POST /collection/{id}/rows/update`

Resource: **Collection** · API: **Collections**

## Path parameters

- **`id`** _(string, required)_
  Resource id

## Request body

- **`rows`** _(array<object>)_
  - **`id`** _(string)_
  - **`fields`** _(object)_
  - **`expected_version`** _(integer)_
- **`row_ids`** _(array<string>)_
- **`filter`** _(unknown)_
- **`q`** _(string)_
- **`all`** _(boolean)_
  Allowed: `true`
- **`limit`** _(integer)_
- **`cursor`** _(string)_
- **`set`** _(object)_
- **`set_expr`** _(object)_
  JSONata per field, evaluated per row over { id, fields, created_at, updated_at }.
- **`typecast`** _(boolean)_

## Response body

- **`updated`** _(integer)_
- **`unchanged`** _(integer)_
- **`errors`** _(array<object>)_
  - **`id`** _(string)_
  - **`code`** _(string)_
  - **`message`** _(string)_
- **`next_cursor`** _(string,null)_

## Code examples

### curl

```bash
curl -X POST 'https://api.elaichi.ai/collection/<id>/rows/update' \
  -H 'Authorization: Bearer $ELAICHI_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"rows":[],"row_ids":[],"q":"your_q","all":true,"limit":0,"cursor":"your_cursor","set":{},"set_expr":{},"typecast":true}'
```

### JavaScript

```javascript
const body = {
  "rows": [],
  "row_ids": [],
  "q": "your_q",
  "all": true,
  "limit": 0,
  "cursor": "your_cursor",
  "set": {},
  "set_expr": {},
  "typecast": true
};

const response = await fetch('https://api.elaichi.ai/collection/<id>/rows/update', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + process.env.ELAICHI_API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import os
import requests

url = "https://api.elaichi.ai/collection/<id>/rows/update"
headers = {
    "Authorization": f"Bearer {os.environ['ELAICHI_API_TOKEN']}",
    "Content-Type": "application/json",
}
payload = {
    "rows": [],
    "row_ids": [],
    "q": "your_q",
    "all": True,
    "limit": 0,
    "cursor": "your_cursor",
    "set": {},
    "set_expr": {},
    "typecast": True
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```
