Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Record version

Restore an old record version

Returns

Returns a Job ID. You can then poll for the completion of the job that will eventually return an array of resource objects of type item

Examples

The response contains the ID of the asynchronous job that started:

1
POST https://site-api.datocms.com/versions/:item_version_id/restore HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
Terminal window
1
curl -g 'https://site-api.datocms.com/versions/:item_version_id/restore' \
2
-X POST \
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3"
1
await fetch("https://site-api.datocms.com/versions/:item_version_id/restore", {
2
method: "POST",
3
headers: {
4
Authorization: "Bearer YOUR-API-TOKEN",
5
Accept: "application/json",
6
"X-Api-Version": "3",
7
},
8
});
1
HTTP/1.1 202 Accepted
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"type": "job",
10
"id": "4235"
11
}
12
}

To get the asynchronous job result, poll the job result endpoint. While the task is in progress, the endpoint returns a 404 status code. When the job completes, the status changes to 200 OK:

1
GET https://site-api.datocms.com/job-results/:job_result_id HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
Terminal window
1
curl -g 'https://site-api.datocms.com/job-results/:job_result_id' \
2
\
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3"
1
await fetch("https://site-api.datocms.com/job-results/:job_result_id", {
2
headers: {
3
Authorization: "Bearer YOUR-API-TOKEN",
4
Accept: "application/json",
5
"X-Api-Version": "3",
6
},
7
});
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"type": "job_result",
10
"id": "34",
11
"attributes": {
12
"status": 200,
13
"payload": {
14
"data": [
15
{
16
"type": "item",
17
"id": "hWl-mnkWRYmMCSTq4z_piQ",
18
"relationships": {
19
"item_type": {
20
"data": {
21
"type": "item_type",
22
"id": "DxMaW10UQiCmZcuuA-IkkA"
23
}
24
}
25
},
26
"attributes": {
27
"title": "My first blog post!",
28
"content": "Lorem ipsum dolor sit amet...",
29
"category": "24",
30
"image": {
31
"alt": "Alt text",
32
"title": "Image title",
33
"custom_data": {},
34
"focal_point": null,
35
"upload_id": "20042921"
36
}
37
},
38
"meta": {
39
"created_at": "2020-04-21T07:57:11.124Z",
40
"updated_at": "2020-04-21T07:57:11.124Z",
41
"published_at": "2020-04-21T07:57:11.124Z",
42
"first_published_at": "2020-04-21T07:57:11.124Z",
43
"publication_scheduled_at": "2020-04-21T07:57:11.124Z",
44
"unpublishing_scheduled_at": "2020-04-21T07:57:11.124Z",
45
"status": "published",
46
"is_current_version_valid": true,
47
"is_published_version_valid": true,
48
"current_version": "4234",
49
"stage": null
50
}
51
}
52
]
53
}
54
}
55
}
56
}