0
Update Contact Stage
One script reply has been approved by the moderators Verified

Updates the stage of one or more contacts in Apollo.io. See the documentation

Created by hugo697 24 days ago Viewed 10 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 24 days ago
1
type Apollo = {
2
  apiKey: string;
3
};
4

5
export async function main(
6
  resource: Apollo,
7
  contactIds: string[],
8
  contactStageId: string
9
) {
10
  const endpoint = "https://api.apollo.io/v1/contacts/update_stages";
11
  const body = {
12
    contact_ids: contactIds,
13
    contact_stage_id: contactStageId,
14
  };
15

16
  const response = await fetch(endpoint, {
17
    method: "POST",
18
    headers: {
19
      "Content-Type": "application/json",
20
      "Cache-Control": "no-cache",
21
      "X-Api-Key": resource.apiKey,
22
    },
23
    body: JSON.stringify(body),
24
  });
25

26
  if (!response.ok) {
27
    throw new Error(`HTTP error! status: ${response.status}`);
28
  }
29

30
  const data = await response.json();
31

32
  return data.contacts;
33
}
34