Search leads via REST API
This feature allows you to search a campaign for an existing lead based using a phone or email field via our REST API.
To search for a lead via the REST API, first, you'll need to set up your API key. You can learn more about that HERE. Along with this, you will need your campaign ID. Find this by editing your campaign and checking the URL.
Performing the Search
You can search using either the email or phone fields. You will need to update the appropriate “search” field in your request.
To see the Search Lead endpoint, this can be found on the REST API key section of your account, selecting the search lead permission and scrolling down the page until you see the documentation for the search lead REST API call.
Using the following body:
{
"key": "[API KEY GOES HERE]",
"searches": [
{
"campaignId": [CAMPAIGN ID GOES HERE],
"email": "[EMAIL TO SEARCH FOR GOES HERE]"
}
]
}
The call can be done with "email" or "phone"
Response
If the email IS found in the campaign, you'll receive a response similar to that shown below:
{
"status": "Success",
"message": "",
"warnings": [],
"totalMatches": 1,
"searches": [
{
"campaignId": 565,
"email": "example@email.com",
"results": [
{
"c1": "",
"c2": "",
"c3": "",
"sub_supplier_id": "0",
"title": "",
"firstname": "",
"lastname": "",
"email": "example@email.com",
"phone1": "0650111111",
"phone2": "",
"phone3": "",
"queue_ref": null,
"leadId": 499791,
"campaignId": 565,
"received": "2022-03-15T10:30:46Z"
}
],
"matches": 1
}
]
}
If the email is NOT found in the campaign, you'll receive a response similar to that shown below:
{
"status": "Success",
"message": "",
"warnings": [],
"totalMatches": 0,
"searches": [
{
"campaignId": 565,
"email": "example@email.com",
"results": [],
"matches": 0
}
]
}
Adding additional lead info to your search results
When returning search results, we provide you with a few important lead fields.
However, if you require other lead fields to be returned with your results, then you'd need to amend your request accordingly:
{
"key": "[API KEY GOES HERE]",
"searches": [
{
"campaignId": [CAMPAIGN ID GOES HERE],
"email": "[EMAIL TO SEARCH FOR GOES HERE]",
"extrafields": [
"fieldname1",
"fieldname2",
"fieldname3"
]
}
]
}
Which would amend your results like this:
{
"status": "Success",
"message": "",
"warnings": [],
"totalMatches": 1,
"searches": [
{
"campaignId": 565,
"email": "example@email.com",
"extrafields": [
"street1",
"postcode"
],
"results": [
{
"c1": "",
"c2": "",
"c3": "",
"sub_supplier_id": "0",
"title": "",
"firstname": "",
"lastname": "",
"email": "example@email.com",
"phone1": "0650111111",
"phone2": "",
"phone3": "",
"fieldname1": "ABC",
"fieldname2": "",
"fieldname3": "123",
"queue_ref": null,
"leadId": 499792,
"campaignId": 565,
"received": "2022-03-15T10:30:46Z"
}
],
"matches": 1
}
]
}
Comments