0
People Enrichment
One script reply has been approved by the moderators Verified

Enriches a person's information, the more information you pass in, the more likely we can find a match. See the documentation

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

5
export async function main(
6
  resource: Apollo,
7
  body: {
8
    first_name?: string;
9
    last_name?: string;
10
    email?: string;
11
    organization_name?: string;
12
  }
13
) {
14
  const endpoint = "https://api.apollo.io/v1/people/match";
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.person;
33
}
34