0

List installments added to a list of deals

by
Published Oct 17, 2025

Lists installments attached to a list of deals. Only available in Advanced and above plans.

Script pipedrive Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Pipedrive = {
3
  apiToken: string;
4
};
5
/**
6
 * List installments added to a list of deals
7
 * Lists installments attached to a list of deals.
8

9
Only available in Advanced and above plans.
10

11
 */
12
export async function main(
13
  auth: Pipedrive,
14
  deal_ids: string | undefined,
15
  cursor: string | undefined,
16
  limit: string | undefined,
17
  sort_by: "id" | "billing_date" | "deal_id" | undefined,
18
  sort_direction: "asc" | "desc" | undefined,
19
) {
20
  const url = new URL(`https://api.pipedrive.com/api/v2/deals/installments`);
21
  for (const [k, v] of [
22
    ["deal_ids", deal_ids],
23
    ["cursor", cursor],
24
    ["limit", limit],
25
    ["sort_by", sort_by],
26
    ["sort_direction", sort_direction],
27
  ]) {
28
    if (v !== undefined && v !== "" && k !== undefined) {
29
      url.searchParams.append(k, v);
30
    }
31
  }
32
  const response = await fetch(url, {
33
    method: "GET",
34
    headers: {
35
      "x-api-token": auth.apiToken,
36
    },
37
    body: undefined,
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45