0

Update a reference page

by
Published Oct 17, 2025

Updates an existing page in 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
 * Update a reference page
4
 * Updates an existing page in 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(auth: RT.Readme, branch: string, slug: string, body: Body) {
10
	const url = new URL(`https://api.readme.com/v2/branches/${branch}/reference/${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
	connections?: {
99
		recipes?: {
100
			/**
101
			 * URI of the recipe that this API reference is connected to. The recipe and API reference must exist within the same version.
102
			 */
103
			uri?: string
104
		}[]
105
	}
106
	/**
107
	 * Information about the API that this reference page is attached to. If you wish to detach this page from an API definition, making it a stand page, set `api.uri` to `null`.
108
	 */
109
	api?: {
110
		/**
111
		 * The endpoint HTTP method.
112
		 */
113
		method?: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace'
114
		/**
115
		 * The endpoint path.
116
		 */
117
		path?: string
118
		schema?: {
119
			[k: string]: unknown
120
		}
121
		/**
122
		 * OpenAPI features that are utilized within this API operation.
123
		 */
124
		stats?: {
125
			/**
126
			 * This API operation uses `additionalProperties` for handling extra schema properties.
127
			 */
128
			additional_properties?: boolean
129
			/**
130
			 * This API operation has `callbacks` documented.
131
			 */
132
			callbacks?: boolean
133
			/**
134
			 * This API operation contains `$ref` schema pointers that resolve to itself.
135
			 */
136
			circular_references?: boolean
137
			/**
138
			 * This API operation utilizes common parameters set at the path level.
139
			 */
140
			common_parameters?: boolean
141
			/**
142
			 * This API operation utilizes `discriminator` for discriminating between different parts in a polymorphic schema.
143
			 */
144
			discriminators?: boolean
145
			/**
146
			 * This API operation has `links` documented.
147
			 */
148
			links?: boolean
149
			/**
150
			 * This API operation contains polymorphic schemas.
151
			 */
152
			polymorphism?: boolean
153
			/**
154
			 * This API operation, after being dereferenced, has `x-readme-ref-name` entries defining what the original `$ref` schema pointers were named.
155
			 */
156
			references?: boolean
157
			/**
158
			 * This API operation has composable variables configured for its server definition.
159
			 */
160
			server_variables?: boolean
161
			/**
162
			 * This API operation has parameters that have specific `style` serializations.
163
			 */
164
			style?: boolean
165
			/**
166
			 * This API definition has `webhooks` documented.
167
			 */
168
			webhooks?: boolean
169
			/**
170
			 * This API operation has request bodies that accept XML.
171
			 */
172
			xml_requests?: boolean
173
			/**
174
			 * This API operation has response payloads that return XML.
175
			 */
176
			xml_responses?: boolean
177
			/**
178
			 * This API operation has parameters or schemas that can serialize to XML.
179
			 */
180
			xml_schemas?: boolean
181
		}
182
		source?:
183
			| 'api'
184
			| 'apidesigner'
185
			| 'apieditor'
186
			| 'bidi'
187
			| 'form'
188
			| 'postman'
189
			| 'rdme'
190
			| 'rdme_github'
191
			| 'url'
192
		uri?: string
193
	}
194
	position?: number
195
}
196