0

Update a organization

by
Published Oct 17, 2025

Updates the properties of a organization.

Script pipedrive Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Pipedrive = {
3
  apiToken: string;
4
};
5
/**
6
 * Update a organization
7
 * Updates the properties of a organization.
8
 */
9
export async function main(
10
  auth: Pipedrive,
11
  id: string,
12
  body: {
13
    name?: string;
14
    owner_id?: number;
15
    add_time?: string;
16
    update_time?: string;
17
    visible_to?: number;
18
    label_ids?: number[];
19
  },
20
) {
21
  const url = new URL(`https://api.pipedrive.com/api/v2/organizations/${id}`);
22

23
  const response = await fetch(url, {
24
    method: "PATCH",
25
    headers: {
26
      "Content-Type": "application/json",
27
      "x-api-token": auth.apiToken,
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