0

Update stage details

by
Published Oct 17, 2025

Updates the properties of a stage.

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 stage details
7
 * Updates the properties of a stage.
8
 */
9
export async function main(
10
  auth: Pipedrive,
11
  id: string,
12
  body: {
13
    name?: string;
14
    pipeline_id?: number;
15
    deal_probability?: number;
16
    is_deal_rot_enabled?: false | true;
17
    days_to_rotten?: number;
18
  },
19
) {
20
  const url = new URL(`https://api.pipedrive.com/api/v2/stages/${id}`);
21

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