medium severityNotion API database query endpoint (/v1/databases/{id}/query)
API returns 400 Bad Request with \"validation_error\": \"body failed validation. Fix one: body.filter.and[X].or[Y].[property_type] should be defined, instead was `undefined`.\" (repeating for multiple types). Happens with complex/nested filters; simple filters work.
Root cause
Notion API enforces undocumented size/complexity limits on the database query request body, particularly the 'filter' object. Exceeding these (e.g., too many nested 'and'/'or' conditions, large compound filters) triggers JSON schema validation failure. Official docs specify 2-level nesting max for compounds but no explicit array size; general request limits (500KB payload) may apply. Deep nesting >2 levels fails with validation errors as seen in community reports.
Notion APIdatabase queryvalidation_errorfilter_conditionscompound filternesting limit