Insert a Text Block at a Specific Position in a Notion Page

Hello everyone,

I’m working on updating Notion pages via n8n and need some guidance. My goal is to insert a new text block underneath a specific existing block on a Notion page. However, as we know, the Notion API currently only allows appending new blocks at the end of a parent’s children.

My proposed approach is as follows:

  1. Retrieve the Full Page Content:
    Get Block Children to fetch the entire JSON structure of the page.
  2. Find the Target Block:
    Find the block where I want to insert the new text
  3. Modify the JSON:
    Once the target is found, modify the JSON data to insert the new text block immediately after it. Essentially, this involves rebuilding the block array with the new block inserted at the desired index.
  4. Clear and Rebuild the Notion Page:
    Since there’s no native API method to remove all blocks at once, my idea is either to:
  • Archive/delete each block one by one via a PATCH (I am not sure it will work)
  1. Re-Inject the Updated Blocks:
    Finally, use the “Append Block Children” to recreate the updated page structure with the new block in its correct position.

I’d like to know:

  • Has anyone tried this approach successfully?
  • Are there better or more efficient alternative methods to manipulate the order of blocks on a Notion page using n8n?

Any insights, tips, or documented examples would be highly appreciated!

Thanks in advance for your help.

hello @Nicolas_N

you can use the Block - Append After operation for that. You will need to get the page blocks to find the proper block ID and then use it to append a block after it.

Your top level block id is the page id, which you always has on a page

Thank you for your answer
I tried this solution but I have the issue ‘Block does not support children.’

According to the API, adding a child to the heading 2 block should be possible.

Hi,
Thank you for the info
I am able to append a block to Heading when is a toggle
I can only append after but I am looking to Append right after the heading. (I am try to automate a release page so I need the new info on top of the previous one)

So you have another block before the Heading one (e.g. Page). Have you tried to use the parent.page_id as a block to append after?

If I use the Append after and the {{parent_id}}. The text will be at the end of the page
If I use the Append after and the {{id}} of the heading, the text will be at the end of the Toggle :sob:

Then, I suppose, the easiest one would be to use the Archive page method and then Create page

That will not work for my use case because I connected the page to a Zendesk support page so the page needs to stay the same :slight_smile:
I think my situation is not a usual use case for Notion API
Thank you for your help !!

Well… you can try an update page method to rewrite the content, but you will need an HTTP node with creds from the notion, as the notion node doesn’t have that method. I can’t advice how the request will be, as the docs are not very clear about the properties section

I found the answer using the documentation !
We can the use the Http Requestion :
PATCH
https://api.notion.com/v1/blocks/{{ $json.parent_id }}/children

Example for the children :

{{ [
    {
      "object": "block",
      "type": "paragraph",
      "paragraph": {
        "rich_text": [
          {
            "type": "text",
            "text": {
              "content": "Test new Text"
            }
          }
        ]
      }
    }
  ] }}

Only works if we are not using toggle

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.