0
Creates an Aero based on the Aero Template with the Id provided.
One script reply has been approved by the moderators Verified
Created by hugo697 40 days ago Viewed 3 times
0
Submitted by hugo697 Bun
Verified 40 days ago
1
//native
2
type Aero_workflow = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Aero_workflow,
8
	accountid: string,
9
	id: string,
10
	body: {
11
		scheduledStartDate: string
12
		scheduledTotalHours: number
13
		scheduledHours: number
14
		scheduledMinutes: number
15
		dueDate?: string
16
		customerId?: number
17
		teamMemberId?: number
18
		aeroGroupId?: number
19
		contactId?: number
20
	}
21
) {
22
	const url = new URL(
23
		`https://api.aeroworkflow.com/api/${accountid}/v1/AeroTasks/FromTemplate/${id}`
24
	)
25

26
	const response = await fetch(url, {
27
		method: 'POST',
28
		headers: {
29
			'Content-Type': 'application/json',
30
			apikey: auth.apiKey
31
		},
32
		body: JSON.stringify(body)
33
	})
34

35
	if (!response.ok) {
36
		const text = await response.text()
37
		throw new Error(`${response.status} ${text}`)
38
	}
39

40
	return await response.json()
41
}
42