# Restore a row to an earlier version (one table)

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

`POST /collection/{id}/table/{tableKey}/rows/{rowId}/restore`

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

## Path parameters

- **`id`** _(string, required)_
  Resource id
- **`tableKey`** _(string, required)_
  Table key; `main` is the default table.
- **`rowId`** _(string, required)_
  Row id

## Request body

- **`version`** _(integer)_
- **`expected_version`** _(integer)_

## Response body

- **`row`** _(object)_
- **`restored_from`** _(integer)_
- **`dropped_fields`** _(array<string>)_
- **`cleared_fields`** _(array<string>)_

## Code examples

### curl

```bash
curl -X POST 'https://api.elaichi.ai/collection/<id>/table/<tableKey>/rows/<rowId>/restore' \
  -H 'Authorization: Bearer $ELAICHI_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"version":0,"expected_version":0}'
```

### JavaScript

```javascript
const body = {
  "version": 0,
  "expected_version": 0
};

const response = await fetch('https://api.elaichi.ai/collection/<id>/table/<tableKey>/rows/<rowId>/restore', {
  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>/table/<tableKey>/rows/<rowId>/restore"
headers = {
    "Authorization": f"Bearer {os.environ['ELAICHI_API_TOKEN']}",
    "Content-Type": "application/json",
}
payload = {
    "version": 0,
    "expected_version": 0
}

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