0

Validate company data

by
Published Apr 8, 2025

This endpoint requires at least 1 query parameter and will check if the parameters and their combinations are valid.

Script foxentry Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Foxentry = {
3
  apiKey: string;
4
};
5
/**
6
 * Validate company data
7
 * This endpoint requires at least 1 query parameter and will check if the parameters and their combinations are valid.
8
 */
9
export async function main(
10
  auth: Foxentry,
11
  api_version: string | undefined,
12
  foxentry_include_request_details: string | undefined,
13
  body: {
14
    request: {
15
      customId?: string;
16
      query: {
17
        name?: string;
18
        country?: string;
19
        registrationNumber?: string;
20
        taxNumber?: string;
21
        vatNumber?: string;
22
      };
23
      options?: {
24
        dataScope?: "basic" | "extended" | "full";
25
        dataSource?: string[];
26
        includeTerminatedSubjects?: false | true;
27
        zipFormat?: false | true;
28
        cityFormat?: "basic" | "extended" | "minimal";
29
        countryFormat?:
30
          | "alpha2"
31
          | "alpha3"
32
          | "local"
33
          | "localShortened"
34
          | "international"
35
          | "internationalShortened";
36
        legalFormType?: "juridical" | "physical" | "any";
37
      };
38
      client?: {
39
        ip?: string;
40
        country?: string;
41
        location?: { lat?: number; lon?: number };
42
      };
43
    };
44
  },
45
) {
46
  const url = new URL(`https://api.foxentry.com/company/validate`);
47

48
  const headers: Record<string, string> = {
49
    "Content-Type": "application/json",
50
    Authorization: "Bearer " + auth.apiKey,
51
  };
52

53
  if (api_version) {
54
    headers["api-version"] = api_version;
55
  }
56
  if (foxentry_include_request_details) {
57
    headers["foxentry-include-request-details"] = foxentry_include_request_details;
58
  }
59

60
  const response = await fetch(url, {
61
    method: "POST",
62
    headers,
63
    body: JSON.stringify(body),
64
  });
65
  if (!response.ok) {
66
    const text = await response.text();
67
    throw new Error(`${response.status} ${text}`);
68
  }
69
  return await response.json();
70
}
71