0

Change a branch cluster configuration

by
Published Oct 17, 2025

### Authorization A service token must have at least one of the following access in order to use this API endpoint: **Service Token Accesses** `write_database`

Script planetscale Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Planetscale = {
3
  serviceTokenId: string;
4
  serviceToken: string;
5
};
6
/**
7
 * Change a branch cluster configuration
8
 * 
9
### Authorization
10
A service token   must have at least one of the following access   in order to use this API endpoint:
11

12
**Service Token Accesses**
13
 `write_database`
14

15

16
 */
17
export async function main(
18
  auth: Planetscale,
19
  organization: string,
20
  database: string,
21
  name: string,
22
  body: { cluster_size: string },
23
) {
24
  const url = new URL(
25
    `https://api.planetscale.com/v1/organizations/${organization}/databases/${database}/branches/${name}/cluster`,
26
  );
27

28
  const response = await fetch(url, {
29
    method: "PATCH",
30
    headers: {
31
      "Content-Type": "application/json",
32
      Authorization: `${auth.serviceTokenId}:${auth.serviceToken}`,
33
    },
34
    body: JSON.stringify(body),
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.text();
41
}
42