Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Record

Duplicate a record

Returns

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

Examples

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

1
POST https://site-api.datocms.com/items/:item_id/duplicate 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/items/:item_id/duplicate' \
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/items/:item_id/duplicate", {
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
"type": "item",
16
"id": "hWl-mnkWRYmMCSTq4z_piQ",
17
"relationships": {
18
"item_type": {
19
"data": {
20
"type": "item_type",
21
"id": "DxMaW10UQiCmZcuuA-IkkA"
22
}
23
}
24
},
25
"attributes": {
26
"title": "My first blog post!",
27
"content": "Lorem ipsum dolor sit amet...",
28
"category": "24",
29
"image": {
30
"alt": "Alt text",
31
"title": "Image title",
32
"custom_data": {},
33
"focal_point": null,
34
"upload_id": "20042921"
35
}
36
},
37
"meta": {
38
"created_at": "2020-04-21T07:57:11.124Z",
39
"updated_at": "2020-04-21T07:57:11.124Z",
40
"published_at": "2020-04-21T07:57:11.124Z",
41
"first_published_at": "2020-04-21T07:57:11.124Z",
42
"publication_scheduled_at": "2020-04-21T07:57:11.124Z",
43
"unpublishing_scheduled_at": "2020-04-21T07:57:11.124Z",
44
"status": "published",
45
"is_current_version_valid": true,
46
"is_published_version_valid": true,
47
"current_version": "4234",
48
"stage": null
49
}
50
},
51
"included": [
52
{
53
"type": "item_type",
54
"id": "DxMaW10UQiCmZcuuA-IkkA",
55
"relationships": {
56
"singleton_item": {
57
"data": null
58
},
59
"fields": {
60
"data": [
61
{
62
"type": "field",
63
"id": "Pkg-oztERp6o-Rj76nYKJg"
64
}
65
]
66
},
67
"fieldsets": {
68
"data": [
69
{
70
"type": "fieldset",
71
"id": "93Y1C2sySkG4Eg0atBRIwg"
72
}
73
]
74
},
75
"title_field": {
76
"data": null
77
},
78
"image_preview_field": {
79
"data": null
80
},
81
"excerpt_field": {
82
"data": null
83
},
84
"ordering_field": {
85
"data": null
86
},
87
"workflow": {
88
"data": null
89
}
90
},
91
"attributes": {
92
"name": "Blog post",
93
"api_key": "post",
94
"singleton": false,
95
"sortable": true,
96
"modular_block": false,
97
"tree": false,
98
"ordering_direction": null,
99
"ordering_meta": "created_at",
100
"draft_mode_active": false,
101
"all_locales_required": false,
102
"collection_appearance": "compact",
103
"hint": "Blog posts will be shown in our website under the Blog section",
104
"inverse_relationships_enabled": false
105
},
106
"meta": {
107
"has_singleton_item": false
108
}
109
}
110
]
111
}
112
}
113
}
114
}