How can I filter entries using a unique property in Notion API?

I can now assign a unique property to a database in Notion, but I’m unsure how to retrieve an entry by that property. My API request fails even though I use the correct property name. Below is an example of my modified JSON filter:

{
  "criteria": {
    "field": "UniqueCode",
    "numeric_value": {
      "equals": 92
    }
  }
}

Any insights on resolving the error would be appreciated.

In my experience with the Notion API, the key is ensuring that the property name you use in your filter exactly matches the property name defined in your database schema. Sometimes the API expects the property filter to be placed within a ‘filter’ object instead of under a ‘criteria’ key. It’s also important to verify that the property type aligns with the filter method; for instance, if it’s a number, confirm that your filter expects a numerical comparison rather than a text match. Rereading the official documentation often helps uncover such nuances.

Based on my experience working with Notion’s API, the challenge might be coming from the exact formatting of your filter structure rather than the property name itself. An important point to note is that the API documentation specifies using a ‘filter’ object with sub-keys that directly map properties to their filters. Adjusting your JSON to follow their standard can help resolve the error. It was also useful for me to ensure that the property type in the database aligns with what is expected in the filter. Testing these small changes ultimately helped refine my approach.

hey, try replacing ‘criteria’ with ‘filter’. i solved a similar issue by matching the exact key and type in my schema. sometimes even small naming mix-ups cause problems. hope it helps!

My experience with the Notion API has taught me that even small differences in the expected JSON structure can lead to errors. I discovered that the error in my case was due to using outdated key names. The API now requires a specific format where the filter is structured with the property name as one of the keys and the filter conditions nested accordingly. It may require a switch from the old ‘criteria’ to something like a ‘filter’ property, with proper nesting of the type-specific sub-objects. Revisiting the latest documentation and using debugging tools enabled me to pinpoint these discrepancies and fix them, allowing me to successfully filter entries by unique properties.