Update the content of an existing block.
1
//native
2
3
/**
4
* Update Block
5
* Update an existing block's content. `content` is keyed by the block's type and replaces the fields you give, e.g. {"paragraph": {"rich_text": [{"text": {"content": "New text"}}]}} or {"to_do": {"checked": true}}. The block type can't be changed.
6
*/
7
export async function main(
8
auth: RT.Notion,
9
block_id: string,
10
content: { [key: string]: any }
11
) {
12
const response = await fetch(`https://api.notion.com/v1/blocks/${block_id}`, {
13
method: "PATCH",
14
headers: {
15
Authorization: `Bearer ${auth.token}`,
16
"Content-Type": "application/json",
17
Accept: "application/json",
18
"Notion-Version": "2026-03-11",
19
},
20
body: JSON.stringify(content),
21
})
22
23
if (!response.ok) {
24
throw new Error(`${response.status} ${await response.text()}`)
25
}
26
27
return await response.json()
28
29