0

Send message

by
Published Nov 5, 2024

Uses settings on the message itself. Update message first to control channels.

Script actimo Verified

The script

Submitted by hugo697 Bun
Verified 592 days ago
1
//native
2
type Actimo = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Actimo,
8
	id: string,
9
	api_key: string,
10
	body: {
11
		contacts?: number[]
12
		groups?: number[]
13
		id?: number
14
		isTest?: false | true
15
		scheduled?: false | true
16
		sendOptions?: { smsFromName?: false | true }
17
	}
18
) {
19
	const url = new URL(`https://actimo.com/api/v1/messages/${id}/send`)
20

21
	const response = await fetch(url, {
22
		method: 'POST',
23
		headers: {
24
			'api-key': auth.apiKey,
25
			'Content-Type': 'application/json'
26
		},
27
		body: JSON.stringify(body)
28
	})
29

30
	if (!response.ok) {
31
		const text = await response.text()
32
		throw new Error(`${response.status} ${text}`)
33
	}
34

35
	return await response.json()
36
}
37