Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Record

Delete 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
DELETE https://site-api.datocms.com/items/:item_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/items/:item_id' \
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/items/:item_id", {
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": "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
}
52
}
53
}
54
}