/

Updating a Checkbox Value in a Notion Database Using the Notion API

Updating a Checkbox Value in a Notion Database Using the Notion API

In this tutorial, we will learn how to update a checkbox value in a Notion database using the Notion API. Each entry in the database is treated as a page, and we will assume that you have the entry stored in a variable called page with its unique ID available as page.id. Additionally, we will assume that you have already initialized the Notion client.

To begin, make sure you have imported the required Client module from '@notionhq/client' and properly initialized the Notion client by providing your authentication token stored in the process.env.NOTION_API_KEY.

1
2
3
4
5
import { Client } from '@notionhq/client'

//...

const notion = new Client({ auth: process.env.NOTION_API_KEY })

To update the value of a checkbox named “Ready” to true, use the following code snippet:

1
2
3
4
5
6
7
8
await notion.pages.update({
page_id: page.id,
properties: {
Ready: {
checkbox: true,
},
},
})

With this code, you can programmatically update the checkbox value in your Notion database using the Notion API.

tags: [“Notion API”, “checkbox”, “database update”]