0
Create contact
One script reply has been approved by the moderators Verified
Created by hugo697 2 days ago Viewed 0 times
0
Submitted by hugo697 Bun
Verified 2 days ago
1
//native
2
type Actimo = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Actimo,
8
	body: {
9
		addr_city?: string
10
		addr_country?: string
11
		addr_line_1?: string
12
		addr_line_2?: string
13
		addr_state?: string
14
		addr_zip?: string
15
		company?: string
16
		company_reg?: string
17
		country_code?: string
18
		data1?: string
19
		data2?: string
20
		data3?: string
21
		department?: string
22
		email?: string
23
		employee_id?: number
24
		first_name?: string
25
		last_name?: string
26
		manager_id?: number
27
		manager_name?: string
28
		manager_type?: string
29
		phone_number?: string
30
		timezone?: string
31
		title?: string
32
		'{data3-data20}'?: string
33
	}
34
) {
35
	const url = new URL(`https://actimo.com/api/v1/contacts`)
36

37
	const response = await fetch(url, {
38
		method: 'POST',
39
		headers: {
40
			'api-key': auth.apiKey,
41
			'Content-Type': 'application/json'
42
		},
43
		body: JSON.stringify(body)
44
	})
45

46
	if (!response.ok) {
47
		const text = await response.text()
48
		throw new Error(`${response.status} ${text}`)
49
	}
50

51
	return await response.json()
52
}
53