LeadSquared Developer Centre

ON THIS PAGE

Create a Webhook


This API allows you to create a webhook.

Before creating a webhook in LeadSquared there are a few things to be clear about:

  1. What event should trigger the webhook?
  2. Where (which URL) would you like the data to be posted when the event occurs?
  3. What format would you like the data to be posted in (e.g., application/json, text/plain, etc.).

When you’re clear on the points mentioned above, use this API to create a webhook.

 

API URL

URL
Icon
POST https://{host}/v2/Webhook.svc/Create?accessKey=AccessKey&secretKey=SecretKey

Request

Content-Type: application/json
JSON Body/Payload Icon
{
  "Description": "Description of webhook",
  "URL": "https://requestb.in/19n3y3u1",
  "Method": "POST",
  "ContentType": "application/json",
  "WebhookEvent": "1",
  "IsSpecificLandingPage": false,
  "NotifyOnFailure": true,
  "WebhookProperties": null,
  "CustomHeaders": [
    {
      "Key": "x-api-key",
      "Value": "j5FtwJk44e6fJHzbKc3fa82pJQQoBa7MebQHXAP"
    },
    {
      "Key": "x-api-key",
      "Value": "j5FtwJk44e6fJHzbKc3fa82pJQQoBa7MebQHXAP6"
    }
  ]
}

Request Parameters

Parameter Description
Description

You can add any text here to describe the webhook.

URL

Specify the URL you want the data posted to. You may use a HTTP or a HTTPS URL. In most cases HTTP is sufficient, but HTTPS can be useful if your data is sensitive.

Method

The HTTP method, which will always be POST in this case.

ContentType

The format you want the data to be posted in. Supported formats are:

  • application/json
  • application/x-www-form-urlencoded
  • text/plain
WebhookEvent

A number that represents the event on which the webhook will trigger:

1 – Landing page submission

2 – Lead activity create

3 – Lead create

4 – Lead owner change

5 – Lead stage change

6 – Lead update

7 – Task create

8 – Task reminder

9 –  Lead score change

15 – Lead activity update

16 – Tasks complete

17 – Task update

26 – Lead field update

31 – Opportunity Create

32 – Opportunity Update

33 – Opportunity Field Update

34 – Opportunity Stage Update

35 – Opportunity Delete

LandingPageUrls

Specifies the landing page(s) on which the event will occur if the event pertains to landing page submission. This parameter will be mandatory if WebhookEvent is landing_page_submission.

IsSpecificLandingPage

This value should be ‘true’ if the list of landing page URLs is provided. Should be ‘true’ if LandingPageUrls are provided.

NotifyOnFailure

Entering ‘true’ will ensure that you are notified whenever a webhook fails.

WebhookProperties

Based on what the webhook pertains to, pass the activity and opportunity details as shown below:

  • Lead Activity :

{“ActivityEvent”:”247″,

“ActivityData”:”[]”,

“WebPageNames”:”[]”}

 

  • Opportunity Create/Update/Delete : 

{\”OpportunityEvents\”:[\”12002\”],

\”IsAsyncEnable\”:true}

 

  • Opportunity Field Change :

{\”OpportunityEvents\”:[\”12003\”],

\”ChangedOpportunityField\”:\”mx_Custom_10\”,

\”IsAsyncEnable\”:false}

 

  • Opportunity Stage Change :

{\”OpportunityEvents\”:[\”12000\”],

\”StatusFrom\”:\”Lost\”,

\”StatusTo\”:\”Open\”,

\”StageFrom\”:\”Budget constraints\”,

\”StageTo\”:\”Negotiation\”,

\”IsAsyncEnable\”:false}

CustomHeaders

For security purposes, you can add custom headers in the form of key-value pairs and use them for authentication (e.g., reject all webhook calls where this header isn’t present).You can add up to 10 custom headers.

Note: The custom headers are strings in JSON format so be sure to add /” before the key and value parameters.

Response

200 OK
Content-Type: application/json
{
    "Status": "Success",
    "Message": {
        "Id": "b1c420d7-9c3e-11e7-b0ab-02e89b2fb8f4"
    }
}

HTTP Response Codes

Code Description
200 OK

This is the status code for successful API call.

401 Unauthorized

The API call was made with invalid access credentials. Check your AccessKey and SecretKey.

400 Bad Request

The message body on the request is not as per API specification. Make sure that content type is set to “application/json” and the JSON body has correct attribute names and structure.

404 Not Found

The API could not be found. Please check the API signature.

429 Too Many Requests

API calls exceeded the limit of 25 in 5 second(s)

500 Internal Server Error

The API called failed. There could be many reasons for it. Check the exception message to get more details.

On this page

© 2024 by MarketXpander Services Pvt Ltd. All Rights Reserved.