LeadSquared Developer Centre

ON THIS PAGE

Add Opportunities in Bulk


Adds multiple opportunities to a lead. The lead is searched for based on any unique field in your account. You can add up to 25 opportunities in a single request.

  • Specify the lead you want to add the opportunity to by passing any unique lead field.*
    • Pass the field schema name in the SearchBy parameter in the API URL.
    • Pass the field value in the SearchByValue attribute in the JSON body.
  • The OpportunityNote and OpportunityOwnerEmail parameters are optional.
  • Specify the opportunity type you want to add to a lead by passing the OpportunityEventCode. To obtain 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 Bulk_1

*Default unique lead fields include EmailAddress, Phone and Mobile. However, you can set your own unique lead fields according to your business requirements.

Note: The opportunity will get created only if all mandatory fields are passed.

 

API URL

URL
Icon
POST https://{host}/v2/OpportunityManagement.svc/Bulk/Add/ByLeadField?accessKey=AccessKey&secretKey=SecretKey&SearchBy=searchBy

URL Parameters

Parameter Description
searchBy The schema name of the unique lead field. E.g., EmailAddress, Phone, etc.

Request

Content-Type: application/json
JSON Body/Payload Icon
[
   {
      "SearchByValue":"+91-2543456794",
      "OpportunityEventCode":12114,
      "OpportunityNote":"Add/ByEmailAddress",
      "UpdateEmptyFields":true,
      "DoNotChangeOwner":true,
      "Fields":[
         {
            "SchemaName":"mx_Custom_1",
            "Value":"XYZ"
         },
         {
            "SchemaName":"mx_Custom_2",
            "Value":"ABC"
         },
         {
            "SchemaName":"mx_Custom_19",
            "Value":"One"
         },
         {
            "SchemaName":"Status",
            "Value":"Open"
         }
      ]
   },
   {
      "SearchByValue":"+91-2543456791",
      "OpportunityEventCode":12114,
      "OpportunityNote":"Add/ByEmailAddress",
      "UpdateEmptyFields":true,
      "DoNotChangeOwner":true,
      "Fields":[
         {
            "SchemaName":"mx_Custom_1",
            "Value":"ABC"
         },
         {
            "SchemaName":"mx_Custom_2",
            "Value":"XYZ"
         },
         {
            "SchemaName":"mx_Custom_19",
            "Value":"One"
         },
         {
            "SchemaName":"Status",
            "Value":"Open"
         }
      ]
   }
]

Request Parameters

Parameter Description
SearchByValue

Value of the “SearchBy” attribute you passed in the API URL. For example, if you passed “EmailAddress” in the API URL, then pass “john@example.com” here. This is a mandatory field.

OpportunityEventCode

The opportunity event code. This is a mandatory field.

OpportunityNote

The description or notes associated with the opportunity.

OpportunityOwnerEmail

Email Id of the opportunity owner.

Fields

You can optionally pass custom opportunity fields here by specifying their “SchemaNames” and “Values”. E.g. “SchemaName”: “mx_Custom_1”, “Value”: “100”.

OverwriteFields

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

 

UpdateEmptyFields

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

DoNotPostDuplicateActivity

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

doNotChangeOwner

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

Response

200 OK
Content-Type: application/json
{
   "Response":[
      {
         "ProspectOpportunityId":"001ea287-b311-4b05-8d7f-2f398379801f",
         "RowNumber":1,
         "OpportunityCreated":true
      },
      {
         "ProspectOpportunityId":"189eddf1-3bc6-4580-96b8-dc57e49eab12",
         "RowNumber":2,
         "OpportunityCreated":true
      }
   ]
}

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.