Skip to main content

Update a Block

This custom action enables makers to update an existing block of any type in their Notion data source.

For additional details regarding the Notion API reference for this action, see Update a block 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 Updating, then select the second dropdown and select Block. When finished, select Create. The window closes and the Custom Action General screen displays.

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

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

    update_block_request_select.png
  6. In the Path field, select the method dropdown and select PATCH, then enter the endpoint URL: v1/blocks/[block_id]

    update_block_request_path.png
  7. Create an action param for the block ID. Enter "Block ID" in the available field in the Actions Params section, then select + Add Param.

    update_block_request_add_block_id_param.png
  8. Replace the placeholder [block_id] value in the endpoint with the newly-created action param. Remove [block_id] in the endpoint, then select the insert field button, insert_field.png, and choose the Block ID field.

    update_block_request_insert_block_id_field.png

    The complete endpoint path should display as follows:

    update_block_request_endpoint_complete.png
  9. In the Body field, enter the request body with the block you want to update.

    The parent element in the example below (heading_2) is specific to the type of block you want to update. Refer to the Notion API documentation for information regarding the specific block type you want to update.

    {
        "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 example of the action, only a Heading param is required.

    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:

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

    add_page_add_header_select.png
  11. 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.

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

    • Block ID - The ID for the block to update.

      The block ID must be specific to the block object type you want to update. That is, if your request body includes a paragraph object type, the corresponding block ID must be that of a paragraph block.

    • Heading - The new heading value.

    update_block_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.

    update_block_test_run_test.png

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

    update_block_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 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.

The Update a Block custom action is complete and ready to use in a module.