How to modify specific rows in a Notion database using row identifiers?

I’m working on a project to keep my database and Notion in sync. Right now, I can pull data from Notion into my database without any issues. But I’m stuck trying to push changes back to Notion.

I want to use the Notion row UUID (which I saved during the initial sync) to update the right row in Notion. However, I’m not sure how to set up the JSON filter for the API call to get a row using its Notion ID.

I’ve tried a few different ways to structure the filter, but I keep getting a ‘400 Client Error: Bad Request’ message. Here’s what I’ve attempted:

filter1 = {
    "filter": {
        "unique_id": {"equals": notion_row_id}
    }
}

filter2 = {
    "filter": {
        "unique_id": "unique_id",
        "unique_id": {"equals": notion_row_id}
    }
}

Does anyone know the correct way to structure this filter? Or should I be using a different approach to update specific rows in Notion? Any help would be great. Thanks!

I’ve been in your shoes, and I can tell you that working with the Notion API can be tricky at first. Here’s what I’ve found to be effective:

Instead of trying to use Notion’s internal row UUID, create a custom ‘External ID’ property in your database. This should be a text field that you populate with your own unique identifiers.

When you sync data from Notion initially, store both the Notion page ID and your custom External ID. Then, when you need to update a specific row, you can query like this:

filter = {
    "filter": {
        "property": "External ID",
        "rich_text": {
            "equals": your_external_id
        }
    }
}

This approach has worked consistently for me in similar projects. It gives you more control and reliability when syncing between systems. Just remember to always use your custom External ID for lookups, rather than relying on Notion’s internal IDs.

I’ve encountered a similar issue when working with the Notion API. The problem is that you’re trying to filter by the internal Notion UUID, which isn’t directly accessible through the API. Instead, you need to use a property in your database to uniquely identify rows.

Here’s what worked for me:

  1. Add a ‘Unique ID’ property to your Notion database (Text type).
  2. Populate it with a unique identifier for each row (this could be a generated UUID).
  3. Use this property in your filter:
filter = {
    "filter": {
        "property": "Unique ID",
        "text": {
            "equals": your_unique_id
        }
    }
}

Then, use this filter in your queryDatabase call. Once you have the page ID from the query result, you can use the updatePage endpoint to modify the row. This approach has been reliable in my experience.

hey there. i’ve seen this before. try adding a ‘UniqueID’ column to your notion db, fill it with unique values, then filter like this:

filter = {"property": "UniqueID", "text": {"equals": your_unique_id}}

hope that helps, lmk if u need more info.