Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Field

Delete 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
DELETE https://site-api.datocms.com/fields/:field_id_or_api_key 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' \
2
-X DELETE \
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/fields/:field_id_or_api_key", {
2
method: "DELETE",
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": "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
}
59
}
60
}
61
}