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

Action summary

Notion -> Database: 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.

Notion → Database: Create

Overview

This Xano action creates a new database in Notion using the Notion API. It uses the Notion API's POST method to create a database with specified properties, title, icon, and cover.


Inputs

Name Type Description
notion_api_key registry text
database_id text The unique identifier for the new database
parent text The parent page ID where database will be created
icon text The icon for the database (optional)
cover text The cover image for the database (optional)
title text The title of the database
properties json The properties schema for the database

Function Stack

  1. Prepare body params

    • Create Variable parent_obj: Prepare parent object
    • Create Variable icon_obj: Prepare icon object if icon is provided
    • Create Variable cover_obj: Prepare cover object if cover is provided
    • Create Variable title_obj: Prepare title object
    • Create Variable body: Combine all parameters
  2. Notion API Request

    • API Endpoint: https://api.notion.com/v1/databases
    • HTTP Method: POST
    • Headers:
      • Authorization: Bearer <notion_api_key>
      • Notion-Version: 2022-06-28
  3. Precondition

    • Ensures that the HTTP request was successful
    • Condition: notion_api_response.status == 200
    • If this condition fails, execution halts and an error is thrown

Response

Key Value
As Self Returns notion_api_response.result

Overview

This Xano action moves a Notion page to trash using its unique identifier (page_id). It uses the Notion API's PATCH method to archive the page.


Inputs

Name Type Description
notion_api_key registry text
page_id text The unique identifier of the page to trash

Function Stack

  1. Notion API Request

    • API Endpoint: https://api.notion.com/v1/pages/%s
    • HTTP Method: PATCH
    • Headers:
      • Authorization: Bearer <notion_api_key>
      • Notion-Version: 2022-06-28
    • Replace %s in the endpoint with the provided page_id
  2. Precondition

    • Ensures that the HTTP request was successful
    • Condition: notion_api_response.status == 200
    • If this condition fails, execution halts and an error is thrown

Response

Key Value
As Self Returns notion_api_response.result

Example

Input

{
  "parent": "98ad959b-2b6a-4774-80ee-00246fb0ea9b",
  "icon": "📝",
  "cover": "https://website.domain/images/image.png",
  "title": "abcd",
  "properties": {
        "Name": {
            "title": {}
        },
        "Description": {
            "rich_text": {}
        }
  }
}

Output

{
    "object": "database",
    "id": "bc1211ca-e3f1-4939-ae34-5260b16f627c",
    "created_time": "2021-07-08T23:50:00.000Z",
    "last_edited_time": "2021-07-08T23:50:00.000Z",
    "icon": {
        "type": "emoji",
        "emoji": "🎉"
    },
    "cover": {
        "type": "external",
        "external": {
            "url": "https://website.domain/images/image.png"
        }
    },
    .
    .
    .
    {
      .
      .
      .
        "Name": {
            "id": "title",
            "name": "Name",
            "type": "title",
            "title": {}
        }
    },
    "parent": {
        "type": "page_id",
        "page_id": "98ad959b-2b6a-4774-80ee-00246fb0ea9b"
    },
    "archived": false,
    "is_inline": false
}

Version notes

2025-02-03 18:05:26
Current
2025-04-15T22:44:40.000+00:00