0

Update account member

by
Published Oct 17, 2025
Script netlify Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Netlify = {
3
  token: string;
4
};
5
/**
6
 * Update account member
7
 *
8
 */
9
export async function main(
10
  auth: Netlify,
11
  account_slug: string,
12
  member_id: string,
13
  body: {
14
    role?: "Owner" | "Developer" | "Billing Admin" | "Reviewer";
15
    site_access?: "all" | "none" | "selected";
16
    site_ids?: string[];
17
  },
18
) {
19
  const url = new URL(
20
    `https://api.netlify.com/api/v1/${account_slug}/members/${member_id}`,
21
  );
22

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