Skip to main content

Create a Page

This custom action enables makers to create a new page in an existing database in their Notion data source.

For additional details regarding the Notion API reference for this action, see Create a page in the Notion developer documentation.

Configure the Request

  1. In Tonkean, navigate to your Notion data source and select Actions in the data source configuration panel. The Actions screen displays.

    actions_select.png
  2. Select Create New Custom Action in the upper right. The New HTTP Custom Action window displays.

    create_new_custom_action_select.png
  3. In the The action will be field, select the first dropdown and select Creating, then select the second dropdown and select Page. When finished, select Create. The window closes and the Custom Action General screen displays.

    action_will_be_creating_page.png
  4. Enter a unique Display Name for the action. This is the title of the action that displays to other makers.

    add_page_rename_custom_action.png
  5. In the Settings panel, select Request. The Request screen displays.

    custom_action_general_request_select.png
  6. In the Path field, ensure the method dropdown is set to POST, then enter the endpoint URL: v1/pages.

    add_page_request_path.png
  7. In the Body field, enter the request body with all required fields.

    {
        "parent": {
           "database_id": ""
       },
       "properties": {
           "title": {
               "title": [
                   {
                       "type": "text",
                       "text": {
                           "content": ""
                       }
                   }
               ]
           }
       },
       "children": [
           {
               "object": "block",
               "type": "heading_2",
               "heading_2": {
                   "rich_text": [
                       {
                           "type": "text",
                           "text": {
                               "content": ""
                           }
                       }
                   ]
               }
           }
       ]
    }
    

    For each required dynamic value, create a new param and include it in the body. For this action, Parent ID, Page Title, and Block Header are all dynamic values you must create pararms for.

    To create a param, follow the steps below:

    1. In the Actions Params section, enter a param name in the available field, then select + Add Param.

      add_page_request_add_param.png
    2. Repeat step #1 for each param you want to create.

    3. For each value where you must include a param, place your cursor between the quotes, then select the insert field button, insert_field.png, and choose the action param to insert.

    When finished, the Body field should appear as in the image below, with the appropriate params included:

    add_page_request_body_filled.png
  8. In the Headers section, select + Add Header. A new Header Name and Header Value fields display.

    add_page_add_header_select.png
  9. Enter the following values:

    • Header Name - Notion-Version

    • Header Value - 2022-06-28

    add_page_add_header_values.png

The request is complete and ready for testing.

Test the Request

  1. Select Test Request. The Test Action window displays.

    add_page_test_request_select.png
  2. Enter values for each action param:

    • Parent ID - {Your database page ID}

      If you're using Notion in a web browser, you can locate the 32-character database ID in the URL. When on the relevant database page, the database ID is located after the workspace name and before any query parameters (that is, before the question mark "?"). If you're using the Notion desktop app, select Share, copy and paste the URL into a web browser, then extract the database ID from the URL.

    • Page Title - The title of the new page.

    • Block Header - The heading for the block.

    add_page_test_action_params.png
  3. Select Run Test. The request runs with the param values you provided and the Response section populates, including a notification with the HTTP response code. The Response Body and Headers tabs in the Response section display the response from the endpoint.

    add_page_test_run_test.png

    If the test is successful, a 200 Success response code displays.

    add_page_test_success.png

    If you don't receive the expected response, or your test request fails, close the Test Action window and return to the Request screen to troubleshoot the problem.

    Some common errors with Notion custom actions are caused by a particular entity not being shared with Tonkean. In Notion, navigate to the relevant entity (in this case, a database page) and select Share in the upper right. Ensure the Tonkean integration has edit permissions.

  4. If the test is successful and you receive the response you expect, close the Test Action window and select Save Action Changes in the upper right of the Request screen.

Handle the Response

  1. In the Settings panel, select Response Handling. The Response Handling screen displays, including the response you received in your previous test.

    add_page_response_handling_select.png
  2. In the Response Body tab, locate and select the id key-value pair. The location of the key-value pair displays in the JSON Path field below the body.

    add_page_response_id_select.png
  3. Select Copy to copy the path, then paste the path into the Pages ID field.

    add_page_response_copypasta_json_path.png
  4. When finished, select Save Action Changes in the upper right.

The Create Page custom action is complete and ready to use in a module.