0

Create List Entry

by
Published Oct 11, 2024

This endpoint creates a new entry in the specified list.

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
	listId: string,
10
	body: {
11
		recordId: string
12
		data?: Record<string, any>
13
	}
14
) {
15
	const endpoint = `https://api.zixflow.com/api/v1/list-entries/${listId}`
16

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

26
	if (!response.ok) {
27
		throw new Error(`HTTP error! status: ${response.status}`)
28
	}
29

30
	const data = await response.json()
31

32
	return data
33
}
34