How to return Notion page ID on create

45 Views Asked by At

I want to create a new page and then print the unique page id once the page is created. I am able to create the page using the following code:

await notion.pages.create({
  parent: {
    database_id: process.env.EVENTS_DATABASE_ID,
  },
  properties: {
    Name: {
      title: [
        {
          text: {
            content: name,
          },
        },
      ],
    },
    Description: {
      rich_text: [
        {
          text: {
            content: "some words here...",
          },
        },
      ],
    },
  },
})

The database has automatic unique ids but I have no idea how to print them once the pages are created, since I only want to print the newest one that is created not all of the current IDs.

1

There are 1 best solutions below

0
On

const { id } = await notion.pages.create({

Learned I just needed to add this to the first line and it'll return the id :p