Capture Opportunities (Async)

Captures leads and opportunities in your LeadSquared account.

Functionality is the same as the synchronous Capture Opportunities API, with the following differences –

  • API host is different, see Async API.
  • An additional x-api-key must be passed in the header, see Async APIContent-Type is application-json.
  • Returns a RequestId parameter. This must be passed in the Status API to get the status of the request.

Note: The request body is identical to the synchronous Capture Opportunities API.

 

API URL

POST
https://{async-host}/opportunity/capture?accessKey=AccessKey&secretKey=SecretKey
Copy URL

Request

JSON Body/Payload

Content-Type: application/json

{
   "LeadDetails":[
      {
         "Attribute":"EmailAddress",
         "Value":"johndoe@example.com"
      },
      {
         "Attribute":"mx_City",
         "Value":"Bangalore"
      },
      {
         "Attribute":"SearchBy",
         "Value":"EmailAddress"
      }
   ],
   "Opportunity":{
      "OpportunityEventCode":12231,
      "OpportunityNote":"Opportunity capture api",
      "OpportunityDateTime":"2020-12-05 12:13:44",
      "Fields":[
         {
            "SchemaName":"mx_Custom_1",
            "Value":"1"
         },
         {
            "SchemaName":"mx_Custom_2",
            "Value":"1"
         }
      ]
   }
}

JSON Properties

Parameter Description
LeadDetails

Array containing lead fields. These should be passed as attribute-value pairs.

  • You must pass at least 1 unique field
  • It is mandatory to specify theSearchBy attribute in the JSON body.
  • You must specify only unique fields here.

The opportunity event code. This is a mandatory field.

To find the event code, navigate to My Profile>Settings>Opportunities>Opportunity Types, and under the Code column, copy the event code for the relevant opportunity type.

Opportunity Capture API

OpportunityNote

Notes (text) associated with the opportunity.

OpportunityDateTime

Opportunity date and time is in the yyyy-mm-dd hh:mm:ss format.

Fields

Attribute-value pairs for the opportunity fields you want to capture. You must pass the schema names of the opportunity fields.

Response

200 OK

Content-Type: application/json

{
   "Status":"Request accepted. Please use below request id to check the status",
   "RequestID":"8eca6fa6-262c-43eb-8cfe-6e3325e2dc73"
}

HTTP Response Code

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.