Use x-callback-url with Shortcuts on iPhone or iPad
Shortcuts supports x-callback-url, allowing the calling app to receive a response (a callback) when a particular interaction has completed. You can run shortcuts from an x-callback-url using the same parameters as discussed in Run a shortcut using a URL scheme on iPhone or iPad. For example:
shortcuts://x-callback-url/run-shortcut?name=Calculate%20Tip&input=text&text=24.99&x-success=...&x-cancel=...
Per the x-callback-url standard, the following additional parameters can be provided:
x-success (optional): A URL that opens when the interaction is successful—for example, after a shortcut is imported or finished running. If a shortcut is run, a parameter named
result
is appended to the URL and contains the textual output of the shortcut.x-cancel (optional): A URL that opens when the interaction is canceled by the user.
x-error (optional): A URL that opens when the interaction fails because an error occurred. A parameter named
errorMessage
is appended to the URL and contains a description of the error.
With x-success
, you can provide a URL that opens after the shortcut successfully finishes running. This could be used in conjunction with a multistep checklist of tasks, wherein you open the x-callback-url to run a shortcut, return to the list, and move on to the next task via URL.
With x-cancel
, you can provide a contingency URL to launch if the shortcut stops before it finishes running. Because the shortcut did not complete, no output from the shortcut is provided.
With x-error
, you can provide a contingency URL to launch if the shortcut encounters an error while running and fails to finish. In this case, you can kick off a different URL to handle the issue.