0

I am trying to create a database using notion sdk and in this is what my payload looks like:

  parent: {
    type: "page_id",
    page_id: process.env.PAGE_ID,
  },
  icon: {
    type: "emoji",
    emoji: "",
  },
  title: [
    {
      type: "text",
      text: {
        content: "DB Title",
      },
    },
  ],
  properties: {
    "Prop-1": {
      date: {},
    },
    "Prop-2": {
      multi_select: {
        options: [
          {
            name: "option-1",
            color: "green",
          },
          {
            name: "option-2",
            color: "gray",
          },
          {
            name: "option-3",
            color: "pink",
          },
        ],
      },
    },
    "prop-3": {
      multi_select: {
        options: [],
      },
    },
  },

I have already added title which can be seen above however the response give 400 status code.

@notionhq/client warn: request fail { code: 'validation_error', message: 'Title is not provided' }

Can't figure our where am I going wrong.

DarthCucumber
  • 101
  • 1
  • 8

1 Answers1

1

You also need to add a title column to your properties. Look at the example payload in the docs, you will see a "Name" title column. https://developers.notion.com/reference/create-a-database

Jonas Scholz
  • 485
  • 5
  • 15
  • I know I should ask it as a separate question but, any idea how I can create a top-level database, like in the workspace? I see there is such property in parent here [https://developers.notion.com/reference/database#page-parent](https://developers.notion.com/reference/database#page-parent) Any idea on how to do that? – DarthCucumber Nov 30 '21 at 14:33
  • 1
    That is not possible at the moment – Jonas Scholz Nov 30 '21 at 15:08