0

Update a category

by
Published Oct 17, 2025

Update an existing category in 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 category
4
 * Update an existing category in 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
	section: 'guides' | 'reference' = 'guides',
12
	title: string,
13
	branch: string,
14
	body: Body
15
) {
16
	const url = new URL(`https://api.readme.com/v2/branches/${branch}/categories/${section}/${title}`)
17

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

33
/* eslint-disable */
34
/**
35
 * This file was automatically generated by json-schema-to-typescript.
36
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
37
 * and run json-schema-to-typescript to regenerate this file.
38
 */
39

40
export interface Body {
41
	/**
42
	 * The category's name.
43
	 */
44
	title?: string
45
	/**
46
	 * The section of your documentation where the category resides.
47
	 */
48
	section?: 'guide' | 'reference'
49
	/**
50
	 * The position of the category in your project's sidebar.
51
	 */
52
	position?: number
53
}
54