Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Field

Duplicate a field

Returns

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

Examples

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

1
POST https://site-api.datocms.com/fields/:field_id_or_api_key/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/fields/:field_id_or_api_key/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(
2
"https://site-api.datocms.com/fields/:field_id_or_api_key/duplicate",
3
{
4
method: "POST",
5
headers: {
6
Authorization: "Bearer YOUR-API-TOKEN",
7
Accept: "application/json",
8
"X-Api-Version": "3",
9
},
10
},
11
);
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": "field",
16
"id": "Pkg-oztERp6o-Rj76nYKJg",
17
"attributes": {
18
"label": "Title",
19
"field_type": "string",
20
"api_key": "title",
21
"localized": true,
22
"validators": {
23
"required": {}
24
},
25
"position": 1,
26
"hint": "This field will be used as post title",
27
"default_value": {
28
"en": "A default value",
29
"it": "Un valore di default"
30
},
31
"appearance": {
32
"editor": "single_line",
33
"parameters": {
34
"heading": false
35
},
36
"addons": [
37
{
38
"id": "1234",
39
"field_extension": "lorem_ipsum",
40
"parameters": {}
41
}
42
]
43
},
44
"deep_filtering_enabled": true
45
},
46
"relationships": {
47
"item_type": {
48
"data": {
49
"type": "item_type",
50
"id": "DxMaW10UQiCmZcuuA-IkkA"
51
}
52
},
53
"fieldset": {
54
"data": null
55
}
56
}
57
},
58
"included": [
59
{
60
"type": "item_type",
61
"id": "DxMaW10UQiCmZcuuA-IkkA",
62
"relationships": {
63
"singleton_item": {
64
"data": null
65
},
66
"fields": {
67
"data": [
68
{
69
"type": "field",
70
"id": "Pkg-oztERp6o-Rj76nYKJg"
71
}
72
]
73
},
74
"fieldsets": {
75
"data": [
76
{
77
"type": "fieldset",
78
"id": "93Y1C2sySkG4Eg0atBRIwg"
79
}
80
]
81
},
82
"title_field": {
83
"data": null
84
},
85
"image_preview_field": {
86
"data": null
87
},
88
"excerpt_field": {
89
"data": null
90
},
91
"ordering_field": {
92
"data": null
93
},
94
"workflow": {
95
"data": null
96
}
97
},
98
"attributes": {
99
"name": "Blog post",
100
"api_key": "post",
101
"singleton": false,
102
"sortable": true,
103
"modular_block": false,
104
"tree": false,
105
"ordering_direction": null,
106
"ordering_meta": "created_at",
107
"draft_mode_active": false,
108
"all_locales_required": false,
109
"collection_appearance": "compact",
110
"hint": "Blog posts will be shown in our website under the Blog section",
111
"inverse_relationships_enabled": false
112
},
113
"meta": {
114
"has_singleton_item": false
115
}
116
}
117
]
118
}
119
}
120
}
121
}