function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lance Shi 8Lance Shi 8 

Calling a webhook web service in Salesforce

I need to call and create a webhook inside a third party platform. The caller code and the return url of the webhook is inside Salesforce.

In Salesforce I need to implement a webservice for the return url. Basically, I don't think using Oauth2 login here is an option because the webhook return call won't be able to login here.

So probably I should use a site to build a public web service here? I don't see an issue with the security because the webservice will only expose minimum amount of data.

But the issue is we are building it in a managed package. I don't think we can include sites inside a package? Correct me if I am wrong.
Is there any walkaround for this?
NagendraNagendra (Salesforce Developers) 
Hi lance,

Please check with below solution from stack exchange community with the best possible workaround.

We haven't found a way to include a Site in a managed package; the problem may be that the first step in setting up Sites is to choose a domain name that hasn't already been used.

So what we have done is include the @RestResource class in the managed package and then provided configuration instructions on how to setup the Site. Not ideal.

On the question of security, in our case it is a callback to receive SMSs from Twilio and that API includes a security hash of a secret that allows us to verify the sender.

An easy thing to forget when the @RestResource class is included in a managed package is that the URL to access it gets an extra path element of the namespace prefix of the managed package (NShere):
https://DOMAIN-developer-edition.na15.force.com/SITE/services/apexrest/NS/URLMAPPING
Kindly mark this post as solved so that it gets removed from the unanswered queue and will be available as a proper solution for others who are encountering a similar issue.

Regards,
Nagendra.