0

Update an existing recipe

by
Published Oct 17, 2025

Update an existing recipe 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 an existing recipe
4
 * Update an existing recipe 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(auth: RT.Readme, branch: string, slug: string, body: Body) {
10
	const url = new URL(`https://api.readme.com/v2/branches/${branch}/recipes/${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
	appearance?: {
36
		/**
37
		 * The color of the recipe card.
38
		 */
39
		background_color?: string
40
		emoji?: string
41
	}
42
	connections?: {
43
		references?: {
44
			/**
45
			 * URI of the API reference page that this recipe will be connected to. The API reference and recipe must exist within the same version.
46
			 */
47
			uri?: string
48
		}[]
49
	}
50
	content?: {
51
		steps?: {
52
			/**
53
			 * Title of the step.
54
			 */
55
			title?: string
56
			body?: string
57
			/**
58
			 * Line numbers to highlight in the code snippet. (e.g. `["1-5", "10"]).
59
			 */
60
			line_numbers?: string[]
61
		}[]
62
		snippet?: {
63
			/**
64
			 * Array of code snippets to display in the recipe.
65
			 */
66
			code_options?: {
67
				code?: string
68
				/**
69
				 * Language of the code snippet.
70
				 */
71
				language?: string
72
				name?: string
73
				highlighted_syntax?: string
74
			}[]
75
		}
76
		response?: string
77
	}
78
	description?: string
79
	privacy?: {
80
		/**
81
		 * Who can view the recipe.
82
		 */
83
		view?: 'public' | 'anyone_with_link'
84
	}
85
	title?: string
86
	/**
87
	 * The position where this recipe should be displayed on your recipe landing page.
88
	 */
89
	position?: number
90
}
91