0

Get details of a person

by
Published Oct 17, 2025

Returns the details of a specific person. Fields `ims`, `postal_address`, `notes`, `birthday`, and `job_title` are only included if contact sync is enabled for the company.

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 a person
7
 * Returns the details of a specific person. Fields `ims`, `postal_address`, `notes`, `birthday`, and `job_title` are only included if contact sync is enabled for the company.
8
 */
9
export async function main(
10
  auth: Pipedrive,
11
  id: string,
12
  include_fields:
13
    | "next_activity_id"
14
    | "last_activity_id"
15
    | "open_deals_count"
16
    | "related_open_deals_count"
17
    | "closed_deals_count"
18
    | "related_closed_deals_count"
19
    | "participant_open_deals_count"
20
    | "participant_closed_deals_count"
21
    | "email_messages_count"
22
    | "activities_count"
23
    | "done_activities_count"
24
    | "undone_activities_count"
25
    | "files_count"
26
    | "notes_count"
27
    | "followers_count"
28
    | "won_deals_count"
29
    | "related_won_deals_count"
30
    | "lost_deals_count"
31
    | "related_lost_deals_count"
32
    | "last_incoming_mail_time"
33
    | "last_outgoing_mail_time"
34
    | "marketing_status"
35
    | "doi_status"
36
    | undefined,
37
  custom_fields: string | undefined,
38
) {
39
  const url = new URL(`https://api.pipedrive.com/api/v2/persons/${id}`);
40
  for (const [k, v] of [
41
    ["include_fields", include_fields],
42
    ["custom_fields", custom_fields],
43
  ]) {
44
    if (v !== undefined && v !== "" && k !== undefined) {
45
      url.searchParams.append(k, v);
46
    }
47
  }
48
  const response = await fetch(url, {
49
    method: "GET",
50
    headers: {
51
      "x-api-token": auth.apiToken,
52
    },
53
    body: undefined,
54
  });
55
  if (!response.ok) {
56
    const text = await response.text();
57
    throw new Error(`${response.status} ${text}`);
58
  }
59
  return await response.json();
60
}
61