I've found a way to do this - however it could be a security vulnerability.
The CloudPagesURL() function requires a SubscriberKey value to render; since it's generation a QueryString (qs) value for that specific subscriber.
There is a feature/bug that you can exploit to create your own micro endpoint to render these Subscriber-Specific links.
Below is how to solve your use case:
- Create a JSON "Code Resource" in Cloud Pages
Put the following code in the JSON Cloud Page:
Save & Publish the Cloud Page
- Click on the URL Link provided when you publish the page. Edit the URL and add
?sk=#SubscriberKey# (where "#SubscriberKey#" is the SubscriberKey you are rendering the cloud page for) to the end of the URL. The final URL should look something like this:
The content of the page will be full URL target of your CloudPagesURL() function, including the subscriber-specific "qs" value at the end.
You can convert this into a JSON-compliant response by adding some structure to the response. For example:
With the above structure you can use a HTTPGET request (remember to include gzip headers) to return this JSON payload for your use outside of the platform.
Again, use this at your own risk - it's effectively a back door to impersonate any subscriber's view of a CloudPage "as if they had clicked a link from an email".