Check for previous automations

Script actimo Verified

by hugo697 ยท 11/5/2024

The script

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

6
export async function main(
7
	auth: Actimo,
8
	body: { decisionGraphId?: number; messageIds?: number[] }
9
) {
10
	const url = new URL(`https://actimo.com/api/v1/decisiongraphs/anyPreviousAutomations`)
11

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

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

26
	return await response.json()
27
}
28