0

Get details of an activity

by
Published Oct 17, 2025

Returns the details of a specific 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
 * Get details of an activity
7
 * Returns the details of a specific activity.
8
 */
9
export async function main(
10
  auth: Pipedrive,
11
  id: string,
12
  include_fields: "attendees" | undefined,
13
) {
14
  const url = new URL(`https://api.pipedrive.com/api/v2/activities/${id}`);
15
  for (const [k, v] of [["include_fields", include_fields]]) {
16
    if (v !== undefined && v !== "" && k !== undefined) {
17
      url.searchParams.append(k, v);
18
    }
19
  }
20
  const response = await fetch(url, {
21
    method: "GET",
22
    headers: {
23
      "x-api-token": auth.apiToken,
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33