In this tutorial, we will learn how to update the icon emoji value of a Notion page using the Notion API. Before we begin, make sure you have already initialized the Notion client.
import { Client } from '@notionhq/client'
//...
const notion = new Client({ auth: process.env.NOTION_API_KEY })
Assuming that the page ID is stored in the page_id
variable, you can follow these steps to set the value of the page icon to a new emoji:
await notion.pages.update({
page_id: page_id,
icon: {
type: 'emoji',
emoji: '✅',
},
})
This code snippet will update the icon of the specified Notion page to the emoji of a check mark (✅).
To update the icon, we use the update
method of the pages
endpoint. The update
method takes an object as its argument, where we provide the page_id
and the new icon emoji value.
That’s it! You have successfully updated the icon emoji of a Notion page using the Notion API.
Tags: Notion API, page icon, emoji, update