How to add a child page to a database using Notion API?

Hey everyone, I’m stuck trying to add a subpage to my Notion database using their API. I’m working with Python and following the docs, but it’s not quite working as expected.

When I create a new page, it shows up as a subpage when I open the parent, but it doesn’t appear in the database view like my other subpages do. I’ve tried updating the ‘Parent item’ property, but no luck there either.

Here’s a quick example of what I’ve tried:

payload = {
    'properties': {
        'Parent item': {
            'relation': [{
                'id': 'parent_page_id_here'
            }]
        }
    }
}

response = notion.pages.update(page_id='new_page_id_here', **payload)

The API returns a 200 OK, but the subpage still doesn’t show up in the database view. Am I missing something obvious? Any ideas on how to make this work?

I’d really appreciate any help or insights you can offer. Thanks in advance!

hey mate, i had the same problem. turns out you gotta create the page directly in the database, not as a separate page. try this:

notion.pages.create(
parent={‘database_id’: ‘your_db_id’},
properties={
‘Name’: {‘title’: [{‘text’: {‘content’: ‘New Page’}}]},
‘Your_Relation’: {‘relation’: [{‘id’: ‘parent_id’}]}
}
)

should work like a charm. lemme know if you need more help!

I’ve encountered a similar issue when working with the Notion API. The key is to understand that adding a child page to a database is different from creating a regular subpage. For database entries, you need to create the page directly within the database, not as a separate page that you then try to link.

Instead of updating an existing page, try creating a new page within the database like this:

notion.pages.create(
    parent={'database_id': 'your_database_id'},
    properties={
        'Name': {'title': [{'text': {'content': 'Your Page Title'}}]},
        'Your_Relation_Property_Name': {'relation': [{'id': 'parent_page_id_here'}]}
    }
)

This approach should create a new entry in your database view, properly linked to the parent item. Make sure to replace ‘Your_Relation_Property_Name’ with the actual name of your relation property in the database.

I’ve been using the Notion API for a while now, and I can tell you that creating child pages in databases can be tricky. One thing that’s not immediately obvious is that you need to set the ‘parent’ parameter correctly when creating the page.

Try this approach:

new_page = notion.pages.create(
    parent={'database_id': 'your_database_id'},
    properties={
        'Name': {'title': [{'text': {'content': 'New Child Page'}}]},
        'Parent': {'relation': [{'id': 'parent_page_id'}]}
    }
)

Make sure ‘Parent’ matches the exact name of your relation property in the database. Also, double-check that you’re using the correct database ID and parent page ID.

If this doesn’t work, it might be worth checking your database schema to ensure the relation property is set up correctly. Sometimes, the issue lies in the database configuration rather than the API call itself.