0

Update an organization

by
Published Oct 17, 2025

### Authorization A OAuth token must have at least one of the following scopes in order to use this API endpoint: **OAuth Scopes** | Resource | Scopes | | :------- | :---------- | | Organization | `write_organization` |

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
 * Update an organization
8
 * 
9
### Authorization
10
A   OAuth token must have at least one of the following   scopes in order to use this API endpoint:
11

12
**OAuth Scopes**
13

14
 | Resource | Scopes |
15
| :------- | :---------- |
16
| Organization | `write_organization` |
17
 */
18
export async function main(
19
  auth: Planetscale,
20
  name: string,
21
  body: {
22
    billing_email?: string;
23
    idp_managed_roles?: false | true;
24
    invoice_budget_amount?: number;
25
  },
26
) {
27
  const url = new URL(`https://api.planetscale.com/v1/organizations/${name}`);
28

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