0

Delete a reference page

by
Published Oct 17, 2025

Delete a page from the API Reference section of your ReadMe project. >📘 > This route is only available to projects that are using [ReadMe Refactored](https://docs.readme.com/main/docs/welcome-to-readme-refactored).

Script readme Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Delete a reference page
4
 * Delete a page from the API Reference section of your ReadMe project.
5

6
>📘
7
> This route is only available to projects that are using [ReadMe Refactored](https://docs.readme.com/main/docs/welcome-to-readme-refactored).
8
 */
9
export async function main(
10
	auth: RT.Readme,
11
	branch: string,
12
	slug: string,
13
	cleanup_definition?: string | undefined
14
) {
15
	const url = new URL(`https://api.readme.com/v2/branches/${branch}/reference/${slug}`)
16
	for (const [k, v] of [['cleanup_definition', cleanup_definition]]) {
17
		if (v !== undefined && v !== '') {
18
			url.searchParams.append(k, v)
19
		}
20
	}
21
	const response = await fetch(url, {
22
		method: 'DELETE',
23
		headers: {
24
			Authorization: 'Bearer ' + auth.apiKey
25
		},
26
		body: undefined
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.text()
33
}
34