0

Create Activity

by
Published Oct 11, 2024

This endpoint creates an activity or task within a collection.

Script zixflow Verified

The script

Submitted by hugo697 Bun
Verified 606 days ago
1
// native
2

3
type Zixflow = {
4
	apiKey: string
5
}
6

7
export async function main(
8
	resource: Zixflow,
9
	body: {
10
		iconType: string
11
		iconValue: string
12
		name: string
13
		status: string
14
		scheduleAt: string
15
		description?: string
16
		associated?: string
17
	}
18
) {
19
	const endpoint = `https://api.zixflow.com/api/v1/collection-records/activity-list`
20

21
	const response = await fetch(endpoint, {
22
		method: 'POST',
23
		headers: {
24
			Authorization: `Bearer ${resource.apiKey}`,
25
			'Content-Type': 'application/json'
26
		},
27
		body: JSON.stringify(body)
28
	})
29

30
	if (!response.ok) {
31
		throw new Error(`HTTP error! status: ${response.status}`)
32
	}
33

34
	const data = await response.json()
35

36
	return data
37
}
38