SharinPix Webhooks

Enrich image data through Webhooks

What is a Webhook?

A WebHook is a callback request (HTTP POST) made to a specific URL when something happens.

In our case, we have these configurable Webhooks available:

  • New image

  • New publication

  • New provider reply

  • New tag image

  • Delete image

  • Delete tag image

  • Upload done

  • New einstein prediction

These callbacks can be configured on the admin page, in the Webhooks section. You can provide your URL on which you want the WebHook (callback) to occur.

Tip:

To know more on those events and how they are triggered, refer to the following article: Types of SharinPix Events

Note:

In order to use Webhooks, you should ensure that you have granted API access to SharinPix on your organization. To verify this, go to the SharinPix Settings tab and check if the second row, that is, Sharinpix -> Salesforce full API access, is highlighted in green.

In case the row, Sharinpix -> Salesforce full API access is still highlighted in red, simply click on the Grant button to grant API access.

For more detailed information on how to grant API access, please refer the the following article:

Basic Setup - Step 2 - Register your Salesforce organization to SharinPix


Types of webhooks

  1. Call to URL with JSON payload using HTTP POST

  2. Call to a static method in an Apex class

To configure a webhook along with its endpoint url, access the Admin Dashboard and follow the instructions below.

Call to URL with JSON payload using HTTP POST

  • Select the ‘Webhooks’ menu item from the navigation bar.

  • Click on the ‘New Webhook’ button.

  • Enter the relevant details for the Webhook.

Call to a static method in an Apex class

In this case, we will use another type of webhook which will execute a static method on your Salesforce environment. The sample code below illustrates an example method which is called by a webhook.

public class Webhook {
    public static void perform(string payload, string webhookInformation){
        // your business logic here
    }
}
  • payload is the json string containing the relevant actions.
  • webhookInformation contains information about the webhook such as the event type.

Next, go to the SharinPix Administration dashboard, click on the menu Webhooks and New Webhook. Select Action type apex_method and insert your class name and method name and select New einstein prediction as event type.