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

6
export async function main(
7
	auth: Actimo,
8
	id: string,
9
	body: { contacts?: number[]; groups?: number[]; scheduled?: string }
10
) {
11
	const url = new URL(`https://actimo.com/api/v1/academy/${id}/send`)
12

13
	const response = await fetch(url, {
14
		method: 'POST',
15
		headers: {
16
			'api-key': auth.apiKey,
17
			'Content-Type': 'application/json'
18
		},
19
		body: JSON.stringify(body)
20
	})
21

22
	if (!response.ok) {
23
		const text = await response.text()
24
		throw new Error(`${response.status} ${text}`)
25
	}
26

27
	return await response.json()
28
}
29