I’m trying to create a new page in my Notion database using the API. I’ve got the basic structure down for the properties, but I can’t figure out how to add the actual page content. Here’s what my request body looks like right now:
{
"parent": {
"database_id": "example_id"
},
"properties": {
"Title": {
"title": [{
"text": {
"content": "My New Page"
}
}]
},
"Category": {
"rich_text": [{
"text": {
"content": "Important Info"
}
}]
}
}
}
I tried adding a “description” block to include the page content, but it resulted in errors. The API docs don’t seem to cover this. Any ideas on how to add the main content of the page? Thanks for any help!
yo, u need to add a ‘children’ array to ur json. that’s where the page content goes. it’s like:
"children": [
{
"object": "block",
"type": "paragraph",
"paragraph": {
"rich_text": [{"text": {"content": "ur content here"}}]
}
}
]
add that to ur existing json and it should work. good luck!
To include page content in your Notion API request, you need to use the ‘children’ array in your JSON body. This array allows you to add various block types like paragraphs, headings, and lists to your page. Here’s an example of how you can modify your request:
{
"parent": { "database_id": "example_id" },
"properties": {
"Title": { "title": [{ "text": { "content": "My New Page" } }] },
"Category": { "rich_text": [{ "text": { "content": "Important Info" } }] }
},
"children": [
{
"object": "block",
"type": "paragraph",
"paragraph": {
"rich_text": [{ "type": "text", "text": { "content": "Your page content goes here." } }]
}
}
]
}
This structure allows you to add multiple blocks of content. You can include different block types like headings, lists, or even nested blocks for more complex layouts. Remember to adjust the content and block types according to your specific needs.
I’ve been working with the Notion API for a while now, and I can tell you that adding page content can be a bit tricky at first. The key is using the ‘children’ array, as others have mentioned. But here’s a pro tip: you can mix and match different block types to create more dynamic pages. For instance, you could do something like this:
"children": [
{
"object": "block",
"type": "heading_2",
"heading_2": {
"rich_text": [{ "text": { "content": "Introduction" } }]
}
},
{
"object": "block",
"type": "paragraph",
"paragraph": {
"rich_text": [{ "text": { "content": "Your main content here..." } }]
}
},
{
"object": "block",
"type": "bulleted_list_item",
"bulleted_list_item": {
"rich_text": [{ "text": { "content": "An important point" } }]
}
}
]
This approach gives you much more flexibility in structuring your page content. Just remember to escape your quotes properly in the actual API request. Hope this helps!