ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Notion -> Page: Create
Readonly
How to Get a Notion API Key

Action summary

Notion -> Page: Create

Xano / Notion

How to Get a Notion API Key

  1. Create an Integration

    • Go to the Notion Developers Portal.
    • Click "New Integration", name it, select a workspace, and submit.
  2. Get Your API Key

    • Copy the Internal Integration Token from the integration settings page.
  3. Grant Database Access

    • Open your Notion database.
    • Click the three button dropdown at the top right of your screen, click Connections, and then select your integration.
  4. Use the API Key

    • Add it to your Xano Actions in the Settings Registry input option:

For more details, see the Notion API Docs.

Xano Action: Create a Notion Page

Description

This Xano Action creates a new page in a Notion database or under a specified parent page using the Notion API. The input parameters allow customization of the page's title, icon, cover, and additional properties.


Inputs

Parameter Type Description
notion_api_key Text The API key for authenticating requests to the Notion API.
database_id Text The ID of the Notion database where the page will be created.
page_id Text The ID of the parent page (used if database_id is not provided).
title Text The title of the page.
icon Text The emoji or URL for the page's icon.
cover Text The URL for the page's cover image.
properties JSON A JSON object defining the properties of the page.

Function Stack

  1. Prepare Body Params

    • Create Variable: parent_obj
      Determines the parent of the page. Uses database_id if provided; otherwise, it uses page_id.
      $input.page_id == null ? 
          ($input.database_id == null ? 
              {} : {"database_id": $input.database_id }) : 
          {"page_id": $input.page_id }
      
    • Create Variable: icon_obj
      Prepares the icon object based on the input. Defaults to null if no icon is provided.
      $input.icon == null ? null : { "type": "emoji", "emoji": $input.icon }
      
    • Create Variable: cover_obj
      Prepares the cover object based on the input. Defaults to null if no cover is provided.
      $input.cover == null ? null : { "type": "external", "external": { "url": $input.cover } }
      
    • Create Variable: title_obj
      Prepares the title object using the provided title.
      $input.title == null ? null : { "type": "text", "text": { "content": $input.title, "link": null } }
      
    • Create Variable: properties_obj
      Uses the input properties if provided; otherwise, defaults to null.
      $input.properties == null ? {} : $input.properties
      
    • Update Variable: properties_obj
      Updates the properties object as needed.
  2. Notion API Request
    Sends a POST request to the Notion API endpoint /pages with the prepared body parameters.

    POST https://api.notion.com/v1/pages
    
  3. Precondition
    Validates the response status from the Notion API to ensure the request was successful (status = 200).

Outputs

Key Description
As Self Returns the response from the Notion API.

Example

Here’s an example of a request body to create a Notion page with structured content:

Input

{
  "database_id": "",
  "page_id": "173a64ee3b6580158b06fc4ee9510c07",
  "icon": "😻",
  "cover": "https://upload.wikimedia.org/wikipedia/commons/0/0e/Big_Raven_Plateau_2023.jpg",
  "title": "Cool Page",
  "children": [
    {
      "object": "block",
      "type": "heading_2",
      "heading_2": {
        "rich_text": [
          {
            "type": "text",
            "text": {
              "content": "Lacinato kale"
            }
          }
        ]
      }
    },
    {
      "object": "block",
      "type": "paragraph",
      "paragraph": {
        "rich_text": [
          {
            "type": "text",
            "text": {
              "content": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
              "link": {
                "url": "https://en.wikipedia.org/wiki/Lacinato_kale"
              }
            }
          }
        ]
      }
    }
  ],
  "properties": {}
}

Response

{
  "object": "page",
  "id": "17aa64ee-3b65-81fe-8366-f6973a4866fb",
  "created_time": "2025-01-13T09:58:00.000Z",
  "last_edited_time": "2025-01-13T09:58:00.000Z",
  "created_by": {
    "object": "user",
    "id": "85e350a9-2764-4de2-a6e1-b076f120c6eb"
  },
  "last_edited_by": {
    "object": "user",
    "id": "85e350a9-2764-4de2-a6e1-b076f120c6eb"
  },
  "cover": {
    "type": "external",
    "external": {
      "url": "https://upload.wikimedia.org/wikipedia/commons/0/0e/Big_Raven_Plateau_2023.jpg"
    }
  },
  "icon": {
    "type": "emoji",
    "emoji": "😻"
  },
  "parent": {
    "type": "page_id",
    "page_id": "173a64ee-3b65-8015-8b06-fc4ee9510c07"
  },
  "archived": false,
  "in_trash": false,
  "properties": {
    "title": {
      "id": "title",
      "type": "title",
      "title": [
        {
          "type": "text",
          "text": {
            "content": "Cool Page",
            "link": null
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "Cool Page",
          "href": null
        }
      ]
    }
  },
  "url": "https://www.notion.so/Cool-Page-17aa64ee3b6581fe8366f6973a4866fb",
  "public_url": null,
  "request_id": "a67e7151-fa92-4b7f-8132-16acb01e239a"
}

Version notes

2025-01-13 14:18:27
Current
2025-04-15T22:44:37.000+00:00