Update Account Stage

Updates the stage of one or more accounts in Apollo.io. [See the documentation](https://apolloio.github.io/apollo-api-docs/?shell#update-account-stage)

Script apollo Verified

by hugo697 ยท 8/26/2024

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 650 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