1

How do I add and/or modify a database schema?

Things that seem to be possible;

  • Adding a subpage to a page.
  • Adding a subpage to a database.
  • Modify the property values.

Though in each of these scenarios, the database schema has to stay the same. From the docs.

If the parent is a database, the property values of the new page in the properties parameter must conform to the parent database's property schema.

I can confirm that this is the case as I get an error with extra property values using the create page endpoint.

If I create a plugin that uses tables, it's quite a bad user experience to expect someone to build out the entire schema and then point the plugin at it.

It does not seem to be possible to;

  • Add a new property to a database.
  • Modify or delete an existing property.
silvergasp
  • 1,517
  • 12
  • 23

2 Answers2

1

The documentation you are referring to is specifically for creating a page within a database. This is separate from modifying the database itself.

The Notion API does not currently (Notion-Version: 2021-05-13) support creating or modifying databases. You can only retrieve or query a database.

In future iterations of the API there may be a POST database or PATCH database endpoint.

adlopez15
  • 3,449
  • 2
  • 14
  • 19
1

You can now use the update database endpoint with a properties object:

PATCH /v1/databases/database_id HTTP/1.1
Accept: application/json
Notion-Version: 2022-06-28
Content-Type: application/json
Host: api.notion.com

{
  "properties": {
    ...
  }
}
Nick McCurdy
  • 17,658
  • 5
  • 50
  • 82