Get Opportunities by Lead Id
Lets you retrieve the list of opportunity fields associated with a lead. You can also get theOpportunityId
from the JSON response.
Notes:
- The
leadId
is mandatory. You can get the Id from any of the Get Lead APIs. - The
opportunityType
is optional. If you do not pass it, then the API will retrieve all the opportunities associated with this particular lead. To obtain the Opportunity Type Code, navigate to My Profile>Settings>Opportunities>Opportunity Types, and against an opportunity type, you’ll find the code. - Passing a JSON body is optional. If you do not pass it, the API will retrieve all the default opportunity fields.
API URL
URL Parameters
Parameter | Description |
---|---|
leadId | The lead Id of the lead. This is mandatory. |
opportunityType | The code of the opportunity type. This is optional. |
Request
Content-Type: application/json{ "Columns":{ "Include_CSV":"mx_Custom_3,Owner,Status,mx_Custom_6,mx_Custom_8" }, "Paging":{ "PageIndex":1, "PageSize":100 }, "Sorting":{ "ColumnName":"Owner", "Direction": "1" } }
Request Parameters
Parameter | Description |
---|---|
Columns | In the Include_CSV, add the lead fields you want to retrieve in the response. This is optional. |
Paging | The results matching your criteria may be large. You can fetch the result in blocks of “PageSize” and make multiple calls to the API with increasing values of “PageIndex”. For example, you can specify “PageIndex”: 1, “PageSize”: 100 for the first call and specify “PageIndex”: 2, “PageSize”: 100 for second call. This is optional. |
Sorting | Pass the ColumnName by which you want to sort the results. For direction, passing ‘1’ will sort the data by the most recent first. Passing ‘0’ will sort the data by the oldest first. This is optional. |
Response
{ "RecordCount":2, "List":[ { "ProspectId":"69e1c27e-dd08-4b53-b509-f353ad1c7f4d", "FirstName":"Manish", "LastName":"Garg", "EmailAddress":"manish@mailinator.com", "Phone":"+91-99999999", "DoNotCall":"0", "DoNotEmail":"0", "LeadName":"Manish Garg", "LeadOwner":"Rohan Sane", "OpportunityEventType":"2", "OpportunityEvent":"12005", "OpportunityNote":"", "Score":"0", "PACreatedOn":"2020-09-16 05:43:00", "PAModifiedOn":"2020-09-16 07:26:09", "IP_Latitude":null, "IP_Longitude":null, "PACreatedByName":"Rajesh Aggarwal", "mx_Custom_1":"Manish Garg - Loan", "Status":"Open", "mx_Custom_2":"Prospecting", "mx_Custom_6":"2500000", "mx_Custom_8":"2020-11-06 05:45:00", "Owner":"a4dfa1c5-c6d2-11ea-92ae-0a6d35d1ff1e", "OwnerName":"Rajesh Aggarwal", "OpportunityId":"4597c076-be5a-4ba2-9b08-ecd21626750f", "Total":"2" }, { "ProspectId":"69e1c27e-dd08-4b53-b509-f353ad1c7f4d", "FirstName":"Manish", "LastName":"Garg", "EmailAddress":"manish@mailinator.com", "Phone":"+91-9999999999", "DoNotCall":"0", "DoNotEmail":"0", "LeadName":"Manish Garg", "LeadOwner":"Rohan Sane", "OpportunityEventType":"2", "OpportunityEvent":"12002", "OpportunityNote":"Update note", "Score":"0", "PACreatedOn":"2020-07-16 17:15:29", "PAModifiedOn":"2020-09-15 11:11:35", "IP_Latitude":null, "IP_Longitude":null, "PACreatedByName":"System", "mx_Custom_1":"Manish Garg - Opportunity", "Status":"Open", "mx_Custom_2":"New", "mx_Custom_6":"200,000", "mx_Custom_8":"2020-09-16 12:13:44", "Owner":"a4dfa1c5-c6d2-11ea-92ae-0a6d35d1ff1e", "OwnerName":"Rajesh Aggarwal", "OpportunityId":"5ca5b042-51ea-4699-b6f0-84c40ab12770", "Total":"2" } ] }
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. |