0

Update a guides page

by
Published Oct 17, 2025

Updates an existing page in the Guides 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
 * Update a guides page
4
 * Updates an existing page in the Guides 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(auth: RT.Readme, branch: string, slug: string, body: Body) {
10
	const url = new URL(`https://api.readme.com/v2/branches/${branch}/guides/${slug}`)
11

12
	const response = await fetch(url, {
13
		method: 'PATCH',
14
		headers: {
15
			'Content-Type': 'application/json',
16
			Authorization: 'Bearer ' + auth.apiKey
17
		},
18
		body: JSON.stringify(body)
19
	})
20
	if (!response.ok) {
21
		const text = await response.text()
22
		throw new Error(`${response.status} ${text}`)
23
	}
24
	return await response.json()
25
}
26

27
/* eslint-disable */
28
/**
29
 * This file was automatically generated by json-schema-to-typescript.
30
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
31
 * and run json-schema-to-typescript to regenerate this file.
32
 */
33

34
export interface Body {
35
	/**
36
	 * Allow indexing by robots.
37
	 */
38
	allow_crawlers?: 'enabled' | 'disabled'
39
	appearance?: {
40
		icon?: {
41
			name?: string
42
			type?: 'icon' | 'emoji'
43
		}
44
	}
45
	category?: {
46
		/**
47
		 * A URI to the category resource.
48
		 */
49
		uri?: string
50
	}
51
	content?: {
52
		body?: string
53
		excerpt?: string
54
		/**
55
		 * Information about where this page should redirect to; only available when `type` is `link`.
56
		 */
57
		link?: {
58
			url?: string
59
			new_tab?: boolean
60
		}
61
		next?: {
62
			description?: string
63
			pages?: (
64
				| {
65
						slug: string
66
						title: string
67
						type: 'basic' | 'endpoint'
68
				  }
69
				| {
70
						title: string
71
						type: 'link'
72
						url: string
73
				  }
74
			)[]
75
		}
76
	}
77
	metadata?: {
78
		description?: string
79
		keywords?: string
80
		title?: string
81
		image?: {
82
			uri?: string
83
		}
84
	}
85
	parent?: {
86
		uri?: string
87
	}
88
	privacy?: {
89
		view?: 'public' | 'anyone_with_link'
90
	}
91
	/**
92
	 * The accessible URL slug for the page.
93
	 */
94
	slug?: string
95
	state?: 'current' | 'deprecated'
96
	title?: string
97
	type?: 'api_config' | 'basic' | 'endpoint' | 'link' | 'webhook'
98
	position?: number
99
}
100