0

Create Collection Record

by
Published Oct 11, 2024

This endpoint creates a new collection record in the specified 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(resource: Zixflow, collectionId: string, body: Record<string, any>) {
8
	const endpoint = `https://api.zixflow.com/api/v1/collection-records/${collectionId}`
9

10
	const response = await fetch(endpoint, {
11
		method: 'POST',
12
		headers: {
13
			Authorization: `Bearer ${resource.apiKey}`,
14
			'Content-Type': 'application/json'
15
		},
16
		body: JSON.stringify(body)
17
	})
18

19
	if (!response.ok) {
20
		throw new Error(`HTTP error! status: ${response.status}`)
21
	}
22

23
	const data = await response.json()
24

25
	return data
26
}
27