0

Update a person

by
Published Oct 17, 2025

Updates the properties of a person.

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 person
7
 * Updates the properties of a person.
8
 */
9
export async function main(
10
  auth: Pipedrive,
11
  id: string,
12
  body: {
13
    name?: string;
14
    owner_id?: number;
15
    org_id?: number;
16
    add_time?: string;
17
    update_time?: string;
18
    emails?: { value?: string; primary?: false | true; label?: false | true }[];
19
    phones?: { value?: string; primary?: false | true; label?: false | true }[];
20
    visible_to?: number;
21
    label_ids?: number[];
22
  },
23
) {
24
  const url = new URL(`https://api.pipedrive.com/api/v2/persons/${id}`);
25

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