How to Create a Notion Page Using iOS Shortcuts

Introduction

The issue with sharing text to Notion via the iOS Share Sheet is that the text would populate the page title field, not the page’s body:

The iOS Share Sheet, which shows the sharing of text, which states: 'The issue with sharing text to Notion via the iOS share sheet is that the text will populate the page title field'
The Notion pop-up in the iOS Share Sheet, which shows the sharing of text, which states: 'The issue with sharing text to Notion via the iOS share sheet is that the text will populate the page title field, not the page's body.'

So I wanted to make an iOS Shortcut in the Share Sheet that would let me share some text, create a page in the database, and add the shared text to it.

To make the shortcut, I considered using Nautomate, which adds Notion actions to Shortcuts. But it had trouble accessing a large Notion database, so I couldn’t use it, and I can’t recommend it for long-term use.

Instead, I used the Notion API directly, and created a shortcut that creates a page and adds text to it. You can download it here on RoutineHub, and you can use it now—it contains comments explaining how it works, as well as setup instructions.

But if you want to edit it further, here’s a more detailed guide on setting up iOS Shortcuts to work with Notion.

Setting Up the Notion API

If you don’t have a Notion integration and Internal Integration Secret yet, you need to make one first.

  1. Go to Notion’s integrations page.
  2. Click on “New integration”.
  3. Fill in the “Basic Information” form.
  4. Copy the Internal Integration Secret.

You now have the Internal Integration Secret of your new integration, which you can paste into your shortcut later.

But this integration will not have access to your whole workspace. To give it access to a database:

  1. Open your Notion database in the Notion app or browser.
  2. Click on the three dots on the top right.
  3. Click on “Add connections”.
  4. Click on your integration and click “Confirm”.

You can now access this database via the Notion API.

Checking the Database’s Properties

If we want to add page properties to the pages we create, we need to find out what properties the database has.

  1. Make sure that the database has at least one page.

  2. Download this shortcut from RoutineHub.

  3. In the block below “Internal Integration Secret”, enter your integration’s Internal Integration Secret.

  4. In the block below “Database ID”, enter your desired Notion database ID.

    You can find the database ID in the URL to your database. For example, in the URL https://www.notion.so/example/<long_hash_1>?v=<long_hash_2>, the database ID is <long_hash_1>.

    Let’s use this database as an example. It has the database URL https://www.notion.so/sarahmakmq-tutorials/e7bd26c59e084e0bbaab0045939e7a81?v=716517a8f10848268ab7a0f8c572429f, so the database ID is e7bd26c59e084e0bbaab0045939e7a81.

  5. Run the shortcut. It should print out something like this:

    {"has_more":true,"object":"list","results":[{"id":"1e93bf00-149c-41a5-8f83-05b3874a248c","created_time":"2023-08-01T16:33:00.000Z","last_edited_by":{"id":"e7c130fc-8107-44b0-a042-ed3c426a541e","object":"user"},"parent":{"type":"database_id","database_id":"e7bd26c5-9e08-4e0b-baab-0045939e7a81"},"created_by":{"id":"e7c130fc-8107-44b0-a042-ed3c426a541e","object":"user"},"url":"https:\/\/www.notion.so\/Bulbasaur-1e93bf00149c41a58f8305b3874a248c","archived":false,"public_url":"https:\/\/sarahmakmq-tutorials.notion.site\/Bulbasaur-1e93bf00149c41a58f8305b3874a248c","last_edited_time":"2023-08-01T16:33:00.000Z","object":"page","icon":null,"cover":null,"properties":{"Type":{"id":"~J%60%3E","type":"select","select":{"id":"2ea97cac-28d6-471a-9f80-7727a8d9575e","name":"Grass","color":"green"}},"Name":{"id":"title","type":"title","title":[{"annotations":{"code":false,"bold":false,"underline":false,"italic":false,"strikethrough":false,"color":"default"},"plain_text":"Bulbasaur","type":"text","href":null,"text":{"content":"Bulbasaur","link":null}}]}}}],"next_cursor":"8ca477c9-afc7-4081-adae-408c0bd0a3f7","type":"page_or_database","page_or_database":{}}
    
  6. It looks messy, so let’s make it more readable. Other than using a code editor, a quick way to format it is to copy the printed text and paste it into js-beautify.

    The beautified text should look like this:

    {
      "has_more": true,
      "object": "list",
      "results": [
        {
          "id": "1e93bf00-149c-41a5-8f83-05b3874a248c",
          "created_time": "2023-08-01T16:33:00.000Z",
          "last_edited_by": {
            "id": "e7c130fc-8107-44b0-a042-ed3c426a541e",
            "object": "user"
          },
          "parent": {
            "type": "database_id",
            "database_id": "e7bd26c5-9e08-4e0b-baab-0045939e7a81"
          },
          "created_by": {
            "id": "e7c130fc-8107-44b0-a042-ed3c426a541e",
            "object": "user"
          },
          "url": "https://www.notion.so/Bulbasaur-1e93bf00149c41a58f8305b3874a248c",
          "archived": false,
          "public_url": "https://sarahmakmq-tutorials.notion.site/Bulbasaur-1e93bf00149c41a58f8305b3874a248c",
          "last_edited_time": "2023-08-01T16:33:00.000Z",
          "object": "page",
          "icon": null,
          "cover": null,
          "properties": {
            "Type": {
              "id": "~J%60%3E",
              "type": "select",
              "select": {
                "id": "2ea97cac-28d6-471a-9f80-7727a8d9575e",
                "name": "Grass",
                "color": "green"
              }
            },
            "Name": {
              "id": "title",
              "type": "title",
              "title": [
                {
                  "annotations": {
                    "code": false,
                    "bold": false,
                    "underline": false,
                    "italic": false,
                    "strikethrough": false,
                    "color": "default"
                  },
                  "plain_text": "Bulbasaur",
                  "type": "text",
                  "href": null,
                  "text": {
                    "content": "Bulbasaur",
                    "link": null
                  }
                }
              ]
            }
          }
        }
      ],
      "next_cursor": "8ca477c9-afc7-4081-adae-408c0bd0a3f7",
      "type": "page_or_database",
      "page_or_database": {}
    }
    

We can see that under properties, our database has a title property called Name and a select property called Type, and we can see the options we can fill when we add these properties.

Now we can add these properties to our new page. (We can omit any of these properties too, but those property fields would be blank.)

Adding a Page

To add a page, you can use the first “Get contents of https://api.notion.com/v1/pages” block from my shortcut here. First, add your Internal Integration Secret and Database ID again.

If you are not planning to add any properties, you don’t need to edit the text block above “Get contents of https://api.notion.com/v1/pages”, which looks like this:

{
    "parent": {
        "database_id": "database_id"
    },
    "properties": {
        "Name": {
            "title": [{
                "text": {
                    "content": "title"
                }
            }]
        }
    }
}

But if you want to add properties to created pages, you need to edit this text block.

This was the properties section of the JSON we got earlier:

"properties": {
    "Type": {
        "id": "~J%60%3E",
        "type": "select",
        "select": {
        "id": "2ea97cac-28d6-471a-9f80-7727a8d9575e",
        "name": "Grass",
        "color": "green"
        }
    },
    "Name": {
        "id": "title",
        "type": "title",
        "title": [
        {
            "annotations": {
            "code": false,
            "bold": false,
            "underline": false,
            "italic": false,
            "strikethrough": false,
            "color": "default"
            },
            "plain_text": "Bulbasaur",
            "type": "text",
            "href": null,
            "text": {
            "content": "Bulbasaur",
            "link": null
            }
        }
    ]
}
}

So if we want to add the Type property, we can add it to the text block like this:

{
    "parent": {
        "database_id": "database_id"
    },
    "properties": {
        "Name": {
            "title": [
                {
                    "text": {
                        "content": "title"
                    }
                }
            ]
        },
        "Type": {
            "id": "~J%60%3E",
            "type": "select",
            "select": {
                "name": "Electric"
            }
        }
    }
}

But we should check and correct the JSON formatting. To do that, you can use a code editor or use this JSON fixer.

Adding Blocks to the Page

So far, the script allows us to add a page (with its properties) to the database. To add blocks to the page, we need to use another “Get Contents of URL” block, and another text block.

If you just want to share text, this shortcut covers that.

The shortcut I shared lets you to share text from the Share Sheet or clipboard, splits the text into chunks of fewer than 2000 characters each (because the Notion API doesn’t allow text blocks with more than 2000 characters), then sends the text block(s) to the new Notion page.

But if you want to add more blocks of different types, you need to do this:

  1. Duplicate the “Get contents of https://api.notion.com/v1/blocks/page_id/children” block.
  2. Move it below “End Repeat”.
  3. Above it, add a new text block with the JSON needed for your desired Notion block. See this page to learn about each block type and the fields they need.
  4. Open the drop-down menu in the “Get contents of https://api.notion.com/v1/blocks/page_id/children” block and change the variable in “File” to the variable under the new text block.
  5. Add “Ask for Input” blocks or Share Sheet input options to fill up the new blocks.

With a shortcut like the one we have, you can now use iOS Shortcuts to create Notion pages!