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

Creates a new account in Apollo.io. See the documentation

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

5
export async function main(
6
  resource: Apollo,
7
  body: {
8
    name: string;
9
    domain: string;
10
    phone_number?: string;
11
    raw_address?: string;
12
  }
13
) {
14
  const endpoint = "https://api.apollo.io/v1/accounts";
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.account;
33
}
34