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

Updates an existing account in Apollo.io. See the documentation

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

5
export async function main(
6
  resource: Apollo,
7
  accountId: string,
8
  updateData: {
9
    name?: string;
10
    domain?: string;
11
    phone_number?: string;
12
  }
13
) {
14
  const endpoint = `https://api.apollo.io/v1/accounts/${accountId}`;
15
  const body = updateData;
16

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

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

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

33
  return data.account;
34
}
35