I’m getting a validation error when I try to create a new record in my Notion database through their API. My database has two custom fields that I want to populate. The first one is called Status and it’s a select field with options like High, Medium, Low. The second field is Assignee which lets me pick from team members in my workspace.
The error message says:
APIResponseError: body failed validation. Fix one:
body.properties.Status.type should be not present, instead was “Select”.
body.properties.Status.select should be not present, instead was {“value”:“High”}.
body.properties.Status.name should be defined, instead was undefined.
body.properties.Status.start should be defined, instead was undefined.
Here’s my code:
const recordData = {
title: [{
text: {
content: "New Task"
}
}],
Status: {
id: "abc123",
type: "Select",
select: {
value: "High"
}
},
Assignee: {
people: [{
email: "[email protected]"
}]
}
};
What am I doing wrong with the property structure?
You’re defining database properties instead of actual values. When creating records via API, just pass the values - skip the field metadata. Your select property uses value but needs name instead. For people fields, you need the user’s UUID, not their email. Hit the users endpoint first to grab those IDs. Don’t forget the parent parameter with your database ID - the API needs this to know where to create the page. Property names must match your database exactly (case sensitive). I’d start with just the title field to test the basic structure, then add your custom properties once that works.
yeah, i had the same issue. just keep it simple with properties - use name for select fields, not value. also, wrap everything in parent and properties or notion won’t accept it. for people fields, you gotta use user ID, which is kinda annoying, but that’s how it is.
You’re mixing up the database schema format with the page creation format. When creating a page, just include the property values - skip the field definitions like type and id.
Here’s how your properties object should look:
const recordData = {
parent: { database_id: "your-database-id" },
properties: {
"title": {
"title": [{
"text": {
"content": "New Task"
}
}]
},
"Status": {
"select": {
"name": "High"
}
},
"Assignee": {
"people": [{
"object": "user",
"id": "user-id-here"
}]
}
}
};
Couple things to remember: select fields use name instead of value, and people properties need the actual user ID, not their email. Don’t forget to wrap everything under a properties key and include the parent database reference.