0
Create Post
One script reply has been approved by the moderators Verified

Use this endpoint to create a new post on your account.

Created by hugo697 2 days ago Viewed 139 times
0
Submitted by hugo697 Bun
Verified 2 days ago
1
//native
2
type Beamer = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	resource: Beamer,
8
	body: {
9
		title: string[]
10
		content: string[]
11
		category: string
12
		publish?: boolean
13
		archive?: boolean
14
		pinned?: boolean
15
		showInWidget?: boolean
16
		showInStandalone?: boolean
17
		enableFeedback?: boolean
18
		enableReactions?: boolean
19
		enableSocialShare?: boolean
20
		autoOpen?: boolean
21
		sendPushNotification?: boolean
22
		userEmail?: string
23
		fixedBoostedAnnouncement?: boolean
24
	}
25
) {
26
	const url = new URL(`https://api.getbeamer.com/v0/posts`)
27

28
	const response = await fetch(url, {
29
		method: 'POST',
30
		headers: {
31
			'Beamer-Api-Key': resource.apiKey,
32
			'Content-Type': 'application/json'
33
		},
34
		body: JSON.stringify(body)
35
	})
36

37
	if (!response.ok) {
38
		const text = await response.text()
39
		throw new Error(`HTTP error! status: ${response.status} - ${text}`)
40
	}
41

42
	const data = await response.json()
43

44
	return data
45
}
46