I need some guidance/code snippet in developing a webhooks in Salesforce to receive alerts from third party server.


In our case, Insideview will send alerts to Salesforce whenever they update company or person information in their database.

In Salesforce, we need to read alerts and make necessary changes in our objects(accounts and object).

If you need more information, please let me know. I am just looking for high-level technical information on how to implement with some example.

  • 1
    Read up on RestResource
    – Eric
    Jan 16, 2017 at 16:01
  • 1
    I don't think this question necessarily needs to be closed...OP is not asking us for a complete integration developed for them, simply a high level overview.
    – Adrian Larson
    Jan 16, 2017 at 16:09
  • I agree with @AdrianLarson. The answers below are fine for a question like this?
    – Dan Jones
    Jan 16, 2017 at 17:48

2 Answers 2


Salesforce support the way to get the request and provide the response from third party sites. It is RestResource.


  1. Authentication with Salesforce.OR You can setup force.con site and expose that class so, you can invoke it without authentication.
  2. RestResource annotated class.

Go through below link to setup rest resource:-

Add a Class as a REST Resource

A sample class look like this:-

global with sharing class MerchandiseManager {

    global static Merchandise__c getMerchandiseById() {
        RestRequest req = RestContext.request;        
        String merchId = req.requestURI.substring(
        Merchandise__c result = 
                       [SELECT Name,Description__c,Price__c,Total_Inventory__c
                        FROM Merchandise__c 
                        WHERE Id = :merchId];
        return result;

    global static String createMerchandise(String name,
        String description, Decimal price, Double inventory) {
        Merchandise__c m = new Merchandise__c(
        insert m;
        return m.Id;

You can also generate wsdl from above and consume it on third party site.

Other thing:- If you are looking for standard operations in Salesforce ex: create/update a record, delete record etc. This available natively. Below are some sample code:-

There is a wsdl generated from Salesforce which is consumed in above examples.

  • 1
    I think rolling your own should not be the first choice in most cases?
    – Adrian Larson
    Jan 16, 2017 at 16:12
  • Yes, rolling your own code is not good if there are out of box feature matching with requirement, both options are given. @AdrianLarson
    – Ashwani
    Jan 16, 2017 at 17:16
  • @Ashwin, i was thinking about the same solution (rest resource), but was not sure by the technical word webhook.. Thanks for confirming it. Why my vendor keep calling it as webhook ?
    – Razu
    Jan 16, 2017 at 21:20
  • Webhooks are generally open or authenticated URL, or you can say listeners at the end which accept the request from third party server. It has nothing different than a rest resource.
    – Ashwani
    Jan 16, 2017 at 21:28

There are out of the box APIs that allow external services to update records and don't require you to write a single line of Apex code:

You can also roll your own using:

You should also read Chapter 5 (Remote Call-In Pattern) of Integration Patterns and Practices, which has much more detail than I can quote here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.