0

Update Prospect

by
Published today

Updates attributes of an existing prospect.

Script outreach Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours ago
1
//native
2

3
/**
4
 * Update Prospect
5
 * Updates attributes of an existing prospect (e.g. { "title": "VP Sales", "occupation": "Sales" }).
6
 */
7
export async function main(
8
  auth: RT.Outreach,
9
  prospect_id: number,
10
  attributes: { [key: string]: any }
11
) {
12
  const response = await fetch(
13
    `https://api.outreach.io/api/v2/prospects/${prospect_id}`,
14
    {
15
      method: "PATCH",
16
      headers: {
17
        Authorization: `Bearer ${auth.token}`,
18
        "Content-Type": "application/vnd.api+json",
19
        Accept: "application/vnd.api+json",
20
      },
21
      body: JSON.stringify({
22
        data: { type: "prospect", id: prospect_id, attributes },
23
      }),
24
    }
25
  )
26

27
  if (!response.ok) {
28
    throw new Error(`${response.status} ${await response.text()}`)
29
  }
30

31
  return await response.json()
32
}
33