0

Move a site section group to a new position. (Deprecated) use sortSiteStructure instead.

by
Published Oct 17, 2025
Script gitbook Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Gitbook = {
3
  token: string;
4
};
5
/**
6
 * Move a site section group to a new position. (Deprecated) use sortSiteStructure instead.
7
 *
8
 */
9
export async function main(
10
  auth: Gitbook,
11
  organizationId: string,
12
  siteId: string,
13
  siteSectionGroupId: string,
14
  body: {
15
    position?: {
16
      before?: { type: "site-section" | "site-section-group"; id: string };
17
      after?: { type: "site-section" | "site-section-group"; id: string };
18
    };
19
  },
20
) {
21
  const url = new URL(
22
    `https://api.gitbook.com/v1/orgs/${organizationId}/sites/${siteId}/section-groups/${siteSectionGroupId}/move`,
23
  );
24

25
  const response = await fetch(url, {
26
    method: "POST",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Bearer " + auth.token,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39