added
Retrieve and update blocks with GET and PATCH /v1/blocks/:id
over 3 years ago by Alma Wang
You can now retrieve and update block objects with the Notion API! The PATCH
endpoint currently supports updating paragraph
, heading_1
, heading_2
, heading_3
, bulleted_list_item
, numbered_list_item
, toggle
and to_do
blocks.
Retrieve a Block
The Retrieve a Block endpoint returns a Block Object.
curl 'https://api.notion.com/v1/blocks/9bc30ad4-9373-46a5-84ab-0a7845ee52e6' \
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H 'Notion-Version: 2021-05-13'
{
"object": "block",
"id": "9bc30ad4-9373-46a5-84ab-0a7845ee52e6",
"created_time": "2021-03-16T16:31:00.000Z",
"last_edited_time": "2021-03-16T16:32:00.000Z",
"has_children": false,
"type": "to_do",
"to_do": {
"text": [
{
"type": "text",
"text": {
"content": "Lacinato kale",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "Lacinato kale",
"href": null
}
],
"checked": false
}
}
Update a Block
The new PATCH
/v1/blocks/:id
endpoint supports updating block content (the properties within the block type object) and returns the updated Block Object, same as the GET
endpoint shown above. See the Update a Block documentation for more detail.
curl https://api.notion.com/v1/blocks/9bc30ad4-9373-46a5-84ab-0a7845ee52e6 \
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H "Content-Type: application/json" \
-H "Notion-Version: 2021-05-13" \
-X PATCH \
--data '{
"to_do": {
"text": [{
"text": { "content": "Lacinato kale" }
}],
"checked": false
}
}'