LeadSquared Developer Centre


Capture Opportunities

Captures leads and opportunities in your LeadSquared account.


Lead Create/Update

  • You must pass at least 1 unique field (attribute-value pair) in the LeadDetails object. For example,
    • "Attribute":"EmailAddress",
  • If you don’t pass at least 1 unique field, you’ll receive an error.
  • If the unique field(s) you pass are not associated with any lead in the system, a new lead will get created.


Opportunity Create

An opportunity captured activity is always posted on the lead.

Opportunity Bulk_1

  • The OpportunityNote and OpportunityDateTime parameters are optional.
  • You may pass the opportunity fields in the Fields object as attribute-value pairs. For example,
    • "SchemaName":"mx_Custom_1",

Note: You must pass the schema name of the opportunity fields.


Duplicate Detection Rules
If you’ve set up duplicate detection rules in your account –

  • If you pass opportunity fields that are not associated with an existing opportunity, a new opportunity is created and an opportunity captured activity is posted on the lead.
  • If you pass opportunity fields associated with an existing opportunity (as specified in the duplicate detection rules), a new opportunity will not be created. An opportunity captured activity will be posted on the lead and a duplicate detected activity will also be posted on the lead.


Response Parameters


Description Values
AdditionalDetails Top-level array of activity details.
ActivityId Activity Id for the captured opportunity. caf2201a-ead4-4cd7-8a0e-16791c31d905
PostDeDupActionPerformed 1 represents a new opportunity has been created.

3 represents a duplicate detected activity has been posted, and no new opportunity has been created.

ConflictedOpportunityId The Id of the duplicate opportunity that’s been detected. It will return “null” if no duplicate opportunity has been detected. null
CreatedOpportunityId The Id of the new opportunity that’s been created. It will return “null” if a duplicate opportunity has been detected. 24590a6c-9dec-4bfd-94df-b7c7d70e0194
ExceptionMessage The description of the exception. “A Lead with same Email already exists.”
ExceptionType The type of exception. “MXDuplicateEntryException”
IsUnique “true” denotes if an opportunity is unique.

“false” denotes if an opportunity is a duplicate.

PrimaryAction 0 represents No Action

1 represents CreateOpportunity

2 represents CreateOpportunityCapturedActivity

3 represents CreateDuplicateDetectedActivity

RelatedProspectId The lead Id on which the opportunity is posted. 489c644c-931e-4ed0-bf72-926a2945e72f
RequestId The identifier of the API request. This can be used to track the API call. 06b09468-5b83-420a-a466-2ca9253b9364
SecondaryAction 0 represents No Action

1 represents CreateOpportunity

2 represents CreateOpportunityCapturedActivity

3 represents CreateDuplicateDetectedActivity


0 – Success. If the primary action and secondary action are executed successfully.

2 – PartialSuccess. If the primary action is executed but secondary action is a failure.

1 – Failure. If primary action is not executed successfully.




If you want the API to throw the exceptions for the dependant dropdown fields, reach out to your account manager or write to support@leadsquared.com. Once these exceptions are enabled –

  • ​​​​​​​If a Dropdown Child field is passed in the payload, an exception is thrown if the parent field is not passed.
  • If the Dropdown parent and Dropdown Child fields are passed, then an exception is thrown if the combination of the values is incorrect or not according to the options configured.
  • Empty values will be allowed in the Dropdown Child if the field is not mandatory.


POST https://{host}/v2/OpportunityManagement.svc/Capture?accessKey=AccessKey&secretKey=SecretKey


Content-Type: application/json
JSON Body/Payload Icon
      "OpportunityNote": "Opportunity capture api overwrite",

Request Parameters

Parameter Description

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.
    • If you  “ProspectID” as the SearchBy criteria, pass an additional parameter “__UseUserDefinedGuid__” as “true”. This is useful if the GUID is generated from an external system.
  • You must specify only unique fields here.

The opportunity event code. This is a mandatory field.


Notes (text) associated with the opportunity.


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


If you passtrue, the existing values in all the opportunity fields passed in the JSON will be overwritten with the new values for duplicate opportunities.


If you passtrue, empty opportunity fields in all opportunities passed will be updated with the values present in the corresponding JSON fields.


If you passtrue, duplicate activities will not get posted on the opportunity.


If you passtrue, duplicate opportunities that contain a new value in the Owner field are ignored, and the opportunity owner remains the same.


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


200 OK
Content-Type: application/json

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

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