Delete Live Collection Items

Remove an item or multiple items (up to 100 items) from the live site. Deleting published items will unpublish the items from the live site and set them to draft. **Note:** If the `cmsLocaleId` parameter is undefined or empty and the items are localized, items will be unpublished only in the primary locale. Required scope | `CMS:write`

Script webflow Verified

by hugo697 ยท 11/5/2024

The script

Submitted by hugo697 Bun
Verified 564 days ago
1
//native
2
type Webflow = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Webflow,
8
	collection_id: string,
9
	body: { items?: { itemId: string; cmsLocaleIds?: string[] }[] }
10
) {
11
	const url = new URL(`https://api.webflow.com/v2/collections/${collection_id}/items/live`)
12

13
	const response = await fetch(url, {
14
		method: 'DELETE',
15
		headers: {
16
			'Content-Type': 'application/json',
17
			Authorization: 'Bearer ' + auth.token
18
		},
19
		body: JSON.stringify(body)
20
	})
21

22
	if (!response.ok) {
23
		const text = await response.text()
24
		throw new Error(`${response.status} ${text}`)
25
	}
26

27
	return await response.text()
28
}
29