How to add URLs to a Notion database using the API and Apple Shortcuts?

I’m working on a project to save URLs from my iPhone’s share sheet to a Notion database. I’m using Apple Shortcuts and the Notion API, but I’m having trouble with the POST request. Here’s what I’ve tried:

{
  "parent": {
    "type": "database_id",
    "database_id": "MY_DATABASE_ID"
  },
  "properties": {
    "WebLink": {
      "type": "url",
      "content": "SHARED_URL_GOES_HERE"
    }
  }
}

I’m not sure if this JSON structure is correct. Can someone help me figure out how to properly format the request to add a URL to my Notion database? I’m new to working with APIs, so any tips or explanations would be really helpful. Thanks!

hey dancingfox, looks like ur on the right track! the json structure seems ok, but u might wanna double-check the “content” field under “WebLink”. i think it should be “url” instead. try changing it to:

"WebLink": {
  "type": "url",
  "url": "SHARED_URL_GOES_HERE"
}

hope that helps! lmk if u need anything else

I’ve encountered similar issues when working with the Notion API. Your JSON structure is close, but there’s a small adjustment needed. The ‘WebLink’ property should use ‘url’ instead of ‘content’. Here’s the corrected version:

{
  "parent": {
    "type": "database_id",
    "database_id": "MY_DATABASE_ID"
  },
  "properties": {
    "WebLink": {
      "type": "url",
      "url": "SHARED_URL_GOES_HERE"
    }
  }
}

Make sure you’re using the correct endpoint for creating pages in Notion (usually ‘/v1/pages’). Also, don’t forget to include the necessary headers in your request, such as ‘Authorization’ with your Notion API key and ‘Content-Type: application/json’. If you’re still having trouble, double-check your database structure to ensure the property names match exactly.

I’ve been using the Notion API with Shortcuts for a while now, and I can confirm that the previous answers are correct about the JSON structure. One thing I’d like to add is that you might want to consider adding more properties to your page creation request. For example, you could include a ‘Name’ or ‘Title’ property to make your entries more organized. Here’s an example:

{
  "parent": { "database_id": "YOUR_DATABASE_ID" },
  "properties": {
    "Name": { "title": [{ "text": { "content": "Page Title" } }] },
    "WebLink": { "url": "YOUR_URL_HERE" },
    "Date Added": { "date": { "start": "2023-04-20" } }
  }
}

This way, you’ll have a title for each entry and a timestamp. Just make sure these properties exist in your Notion database. Also, don’t forget to URL-encode your shared link before inserting it into the JSON. Good luck with your project!