How to handle errors when searching for a note that doesn't exist with x-callback urls?


I use apple shortcuts to generate a daily note for myself each morning. Each time I run the shortcut, I first check to see if I’ve already created a daily note that day – if so, I load up the day’s note. If not, I create a new one.

However, I’m struggling to figure out the best way to search to see if a note already exists. I would like to simply use an x-callback url query to open the note by title (all my daily notes are titled with the date in a particular format). But if /open-note doesn’t find a matching note, it just errors out and stops the shortcut from processing. I’ve tried using a custom x-error to catch errors, but it still errors out as if I haven’t set x-error. If I try to manually set x-error by selecting “custom callback” in shortcuts and entering the same x-error URL into Error Key, the shortcut hangs until I manually cut out.

Here’s the format I’m using:


All I’ve found that works is searching for my properly formatted title using /search. But that searches the entire body my notes. That’s not just inefficient – if that date happens to be repeated anywhere else, it will mistake that random note for my note. In addition, I’ve found that /search doesn’t limit itself to only the exact string you search for, so if I search for “August 23, 2023” it will match on a note titled “August 22, 2023” because it finds “August” and “23” in the title.

Am I missing something? Has anyone seen a better way to handle looking for a specific note?

Thank you for any help or guidance!


Sounds like you can use Bear’s search action in Shortcuts for this particular purpose instead of using XURLs inside your shortcut.

Clever! It looks like appending @title to the search term doesn’t just limit it in the Search shortcut – it also limits it in x-callback queries as well (helpful since I’m doing some calls in python). Thanks for the flag!