0

Create a reference page

by
Published Oct 17, 2025

Create a 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
 * Create a reference page
4
 * Create a 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, body: Body) {
10
	const url = new URL(`https://api.readme.com/v2/branches/${branch}/reference`)
11

12
	const response = await fetch(url, {
13
		method: 'POST',
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
	position?: number
107
	api_config?: 'authentication' | 'getting-started' | 'my-requests'
108
	api?: {
109
		/**
110
		 * The endpoint HTTP method.
111
		 */
112
		method?: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace'
113
		/**
114
		 * The endpoint path.
115
		 */
116
		path?: string
117
		schema?: {
118
			[k: string]: unknown
119
		}
120
		/**
121
		 * OpenAPI features that are utilized within this API operation.
122
		 */
123
		stats?: {
124
			/**
125
			 * This API operation uses `additionalProperties` for handling extra schema properties.
126
			 */
127
			additional_properties?: boolean
128
			/**
129
			 * This API operation has `callbacks` documented.
130
			 */
131
			callbacks?: boolean
132
			/**
133
			 * This API operation contains `$ref` schema pointers that resolve to itself.
134
			 */
135
			circular_references?: boolean
136
			/**
137
			 * This API operation utilizes common parameters set at the path level.
138
			 */
139
			common_parameters?: boolean
140
			/**
141
			 * This API operation utilizes `discriminator` for discriminating between different parts in a polymorphic schema.
142
			 */
143
			discriminators?: boolean
144
			/**
145
			 * This API operation has `links` documented.
146
			 */
147
			links?: boolean
148
			/**
149
			 * This API operation contains polymorphic schemas.
150
			 */
151
			polymorphism?: boolean
152
			/**
153
			 * This API operation, after being dereferenced, has `x-readme-ref-name` entries defining what the original `$ref` schema pointers were named.
154
			 */
155
			references?: boolean
156
			/**
157
			 * This API operation has composable variables configured for its server definition.
158
			 */
159
			server_variables?: boolean
160
			/**
161
			 * This API operation has parameters that have specific `style` serializations.
162
			 */
163
			style?: boolean
164
			/**
165
			 * This API definition has `webhooks` documented.
166
			 */
167
			webhooks?: boolean
168
			/**
169
			 * This API operation has request bodies that accept XML.
170
			 */
171
			xml_requests?: boolean
172
			/**
173
			 * This API operation has response payloads that return XML.
174
			 */
175
			xml_responses?: boolean
176
			/**
177
			 * This API operation has parameters or schemas that can serialize to XML.
178
			 */
179
			xml_schemas?: boolean
180
		}
181
		source?:
182
			| 'api'
183
			| 'apidesigner'
184
			| 'apieditor'
185
			| 'bidi'
186
			| 'form'
187
			| 'postman'
188
			| 'rdme'
189
			| 'rdme_github'
190
			| 'url'
191
		uri?: string
192
	}
193
}
194