0

Update an activity

by
Published Oct 17, 2025

Updates the properties of an activity.

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 an activity
7
 * Updates the properties of an activity.
8
 */
9
export async function main(
10
  auth: Pipedrive,
11
  id: string,
12
  body: {
13
    subject?: string;
14
    type?: string;
15
    owner_id?: number;
16
    deal_id?: number;
17
    lead_id?: string;
18
    person_id?: number;
19
    org_id?: number;
20
    project_id?: number;
21
    due_date?: string;
22
    due_time?: string;
23
    duration?: string;
24
    busy?: false | true;
25
    done?: false | true;
26
    location?: {
27
      value?: string;
28
      country?: string;
29
      admin_area_level_1?: string;
30
      admin_area_level_2?: string;
31
      locality?: string;
32
      sublocality?: string;
33
      route?: string;
34
      street_number?: string;
35
      postal_code?: string;
36
    };
37
    participants?: { person_id?: number; primary?: false | true }[];
38
    attendees?: {
39
      email?: string;
40
      name?: string;
41
      status?: string;
42
      is_organizer?: false | true;
43
      person_id?: number;
44
      user_id?: number;
45
    }[];
46
    public_description?: string;
47
    priority?: number;
48
    note?: string;
49
  },
50
) {
51
  const url = new URL(`https://api.pipedrive.com/api/v2/activities/${id}`);
52

53
  const response = await fetch(url, {
54
    method: "PATCH",
55
    headers: {
56
      "Content-Type": "application/json",
57
      "x-api-token": auth.apiToken,
58
    },
59
    body: JSON.stringify(body),
60
  });
61
  if (!response.ok) {
62
    const text = await response.text();
63
    throw new Error(`${response.status} ${text}`);
64
  }
65
  return await response.json();
66
}
67