Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Schema Menu Item

Reorders a set of schema menu items

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 schema_menu_item

Examples

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

1
POST https://site-api.datocms.com/schema-menu-items/reorder HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
5
Content-Type: application/vnd.api+json
6
7
{
8
"data": [
9
{
10
"id": "uinr2zfqQLeCo_1O0-ao-Q",
11
"type": "schema_menu_item",
12
"attributes": {
13
"position": 1
14
},
15
"relationships": {
16
"parent": {
17
"data": null
18
}
19
}
20
}
21
]
22
}
Terminal window
1
curl -g 'https://site-api.datocms.com/schema-menu-items/reorder' \
2
-X POST \
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3" \
6
-H "Content-Type: application/vnd.api+json" \
7
--data-binary '{"data":[{"id":"uinr2zfqQLeCo_1O0-ao-Q","type":"schema_menu_item","attributes":{"position":1},"relationships":{"parent":{"data":null}}}]}'
1
await fetch("https://site-api.datocms.com/schema-menu-items/reorder", {
2
method: "POST",
3
headers: {
4
Authorization: "Bearer YOUR-API-TOKEN",
5
Accept: "application/json",
6
"X-Api-Version": "3",
7
"Content-Type": "application/vnd.api+json",
8
},
9
body: JSON.stringify({
10
data: [
11
{
12
id: "uinr2zfqQLeCo_1O0-ao-Q",
13
type: "schema_menu_item",
14
attributes: { position: 1 },
15
relationships: { parent: { data: null } },
16
},
17
],
18
}),
19
});
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": "schema_menu_item",
17
"id": "uinr2zfqQLeCo_1O0-ao-Q",
18
"relationships": {
19
"item_type": {
20
"data": {
21
"type": "item_type",
22
"id": "DxMaW10UQiCmZcuuA-IkkA"
23
}
24
},
25
"parent": {
26
"data": null
27
},
28
"children": {
29
"data": [
30
{
31
"type": "schema_menu_item",
32
"id": "uinr2zfqQLeCo_1O0-ao-Q"
33
}
34
]
35
}
36
},
37
"attributes": {
38
"label": "Posts",
39
"position": 1,
40
"kind": "item_type"
41
}
42
}
43
]
44
}
45
}
46
}
47
}