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

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

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

5
export async function main(
6
  resource: Apollo,
7
  accountIds: string[],
8
  accountStageId: string
9
) {
10
  const endpoint = "https://api.apollo.io/v1/accounts/bulk_update";
11
  const body = {
12
    account_ids: accountIds,
13
    account_stage_id: accountStageId,
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.accounts;
33
}
34