βœ•

Automation with Notion CMS

Published on December 23, 2025

Within 36 hours of getting my blog up and running after the Winter Solstice, I began to explore automation with Github Actions and the Notion API to fetch the content from Notion and display the text in the browser.

Because it took me so long to figure out how to fetch the data due to deprecated documentation as well as the latest versions of AI coding agents not having sufficient training with the new documentation, it took me awhile to figure out the correct url to make a successful request.

After all the time spent on getting one site to ensure the functionality was seamless, I chose to work on another project as well that would utilize the Notion API. I thought that it would be a quick copy and paste project. However, because that project needed to read and write to Notion, I again spent a lot of time to figure out the correct structure of the API call.

Then I needed to figure out how I could set up automation to make these API calls to talk to Notion on a set basis that did not necessitate me to ever touch the code base again β€” unless I wanted to build a new feature. So then I found myself working with Github Actions to set up cron events in the workflow.

Now, for one database, I only need to draft the content in Notion and when ready set a publishing date and permit for publishing for public viewing. For another database, I was able to migrate past JSON files to populate the database. Moreover, I was able to set up read and write privileges to this database so updates were possible without having to go into Notion itself. By the time evening arrived, I found myself wondering what other projects I could add the Notion API to…. That shall be a question for another day.

In summary, here is what I learned:

  1. In Notion, go to /profile/integrations to create an integration to get the API key that allows access to make API calls.
  2. Then you would need to assign access to the desired Notion database, which must be in a Notion page.
  3. To get the correct database ID, you must view your Notion database as a Notion page. Then you will see your database ID in the url after the hyphenated name of your page in the url.
  4. To get the data source ID, find the settings button in your database header. Find and click the β€œManage data sources” item to copy the data source ID.
  5. On your Notions integrations dashboard, you can create more than one integration. That way, the API key for a particular database and data source could be read only, write only, OR read and write. In other words, even if it’s the same database, if you want to separate permissions, then you’ll end up with more than one API key for the same database and data source. Be sure to save and copy the API key(s).
  6. Once you have set up the integration and you have added the minimum three secrets (API key, database ID, and data source ID) for a database to your development environment, you can go about creating Notion clients and functions in your code base to handle the logic you’d like the Notion API to implement.
  7. This point may seem redundant: If your site has more than one Notion database, be aware that each Notion database has its own database ID and data source ID. If for one database you only have read access while for another database you have read and write access, then you would have two separate API keys β€” one for read access only while the other is for read and write access.
  8. Once you have set up the secrets and built out the logic, then you want to test locally in your development environment to see if you got the response you intended from the Notion API call request you sent.
  9. Once you have confirmed the expected functionality locally, then you can then build out your YAML file to set up the cron event and the steps you would like your Github Actions workflow to execute on specific intervals. For example, if I blog weekly, then I would want to set up this schedule in the YAML file.
  10. After building out the YAML file, you can deploy your code and link it to a web hosting provider. You’re set!