Getting Started

The below documentation illustrates how to submit leads into the LeadExec platform. For more information, please refer to the post documentation provided to you.

Note: The information provided is general and is supplied to explain how to interact with our API, field information as well as any requirements are not outlined and are included in the posting documents provided to you.

Authentication

To authenticate with the lead receiver API, please refer to the post documentation you received. This documentation should contain the api-key value required to interact with this API.

POST

Create Lead

Creates a new lead in the system. Fields are dynamic and you should refer to your supplied documentation for more information.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
source.vid number body required Source identifier
source.lid number body required Lead type identifier
source.aid number body optional Campaign identifier
source.sendDelay number body required Amount (in hours) to delay sending the lead
source.returnURL string body optional For async processing, this url will be called when processing is completed with the response details.
lead.properties.orderId string body optional Inbound PING order ID received (if needed)
lead.properties.offerIds array body optional Offer ids selected by consumer if presented.
lead.properties.reference string body optional Reference value to store on the record for reporting purposes
lead.properties.noSell bool body optional Prevent the lead from being delivered automatically
lead.fields lead_fields body required Field information being passed about the incomming lead.
POST /v2/insert/general HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

{
    "source": {
        "vid": 0,
        "aid": 0,
        "lid": 0,
        "sendDelay": 0.0,
        "returnURL": ""
    },
    "leads": [
        {
            "properties": {
                "reference": "",
                "noSell": false,
                "orderId": "",
                "offerIds": [
                    "",
                    ""
                ]
            },
            "fields": {
                "FirstName": "",
                "LastName": "",
                ...
            }
        }
    ]
}
POST /v2/insert/general HTTP/1.1
host: leads.leadexec.net
content-type: application/xml
accept: application/xml
authorization: Bearer [acces_token]

<Leads vid="" lid="" aid="" offerids="">
<Lead reference="">
...
</Lead>
</Leads>

Response


Property Type Description Example
requestId string Log identifier for the request guid
results array Array of result objects
results.isValid bool Result of the transaction true
false
results.responseType response_type Type of response No_Error
System_ID_Missing
LeadType_ID_Missing
Vendor_ID_Missing
No_Account_Found
Outside_Criteria
Duplicate_Lead
Account_Disabled
Post_Over_Max
Data_Errors
results.responseMessage string Details about the transaction and why it may have failed Lead was accepted
results.leadId number ID of the lead record received 123456789
results.campaignId number ID of the campaign being assigned 1234
results.isPendingReview bool Is record under quality review true
false
results.price number The price being paid for the record 0.00
results.offers Array<Offer> Offers to be displayed to end consumer for 1 to 1 consent
results.offers.offerId string Identifier of the offer
results.offers.companyName string Name of the contacting company
results.offers.companyPhoneNumber string Phone number of the contacting company
results.offers.name string Name of the offer being presented 30 day introductory offer
results.offers.description string Description of the offer being presented
results.offers.type string Duration of the amount being offered (Monthly or Yearly)
results.offers.price number The price of the offer being presented
results.offers.url string The URL to direct the consumer to for more information or if selected
results.offers.tcpaInformation TCPA Details Information about TCPA language to present for this offer
results.offers.tcpaInformation.customTCPATextRequired bool Is custom TCPA text required to be presented to consumer
results.offers.tcpaInformation.tcpaText string Custom TCPA language to display
results.offers.tcpaInformation.privacyURL string Location of company privacy policy
results.offers.tcpaInformation.privacyURL string Location of company terms policy
{
    "requestId": "",
    "results": [
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0,
            "offers": [
                {
                    "offerId": "",
                    "companyName": "",
                    "companyPhoneNumber": "",
                    "name": "",
                    "description": "",
                    "type": "Monthly",
                    "price": 0.0,
                    "url": "",
                    "tcpaInformation": {
                        "customTCPATextRequired": true,
                        "tcpaText": "",
                        "privacyURL": "",
                        "termsURL": ""
                    }
                }
            ]
        },
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0,
            "offers": [
                {
                    "offerId": "",
                    "companyName": "",
                    "companyPhoneNumber": "",
                    "name": "",
                    "description": "",
                    "type": "Monthly",
                    "price": 0.0,
                    "url": "",
                    "tcpaInformation": {
                        "customTCPATextRequired": true,
                        "tcpaText": "",
                        "privacyURL": "",
                        "termsURL": ""
                    }
                }
            ]
        }
    ]
}
<LeadReceiverResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LeadExec.LeadReceiver.API.Models">
    <RequestId>929f4d31-5576-49b5-ae9b-606d94a475e2</RequestId>
    <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/LeadImportService.Core.Classes">
        <d2p1:PostResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
            <Offers>
                <Offer>
                    <Id></Id>
                    <CompanyName></CompanyName>
                    <CompanyPhoneNumber></CompanyPhoneNumber>
                    <Name></Name>
                    <Description></Description>
                    <Type>Monthly</Type>
                    <Price>0.0</Price>
                    <Url></Url>
                    <TCPAInformation>
                        <CustomTCPATextRequired>True</CustomTCPATextRequired>
                        <TCPAText></TCPAText>
                        <PrivacyUrl></PrivacyUrl>
                        <TermsUrl></TermsUrl>
                    </TCPAInformation>
                </Offer>
            </Offers>
        </d2p1:PostResponse>
        <d2p1:PostResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
            <Offers>
                <Offer>
                    <Id></Id>
                    <CompanyName></CompanyName>
                    <CompanyPhoneNumber></CompanyPhoneNumber>
                    <Name></Name>
                    <Description></Description>
                    <Type>Monthly</Type>
                    <Price>0.0</Price>
                    <Url></Url>
                    <TCPAInformation>
                        <CustomTCPATextRequired>True</CustomTCPATextRequired>
                        <TCPAText></TCPAText>
                        <PrivacyUrl></PrivacyUrl>
                        <TermsUrl></TermsUrl>
                    </TCPAInformation>
                </Offer>
            </Offers>
        </d2p1:PostResponse>
    </Results>
</LeadReceiverResult>

POST

Create Lead and Return Send Information

Creates a new lead in the system. Once the insert is complete and the lead accepted, LeadExec will attempt to deliver that lead and will return the results of the delivery process. Fields are dynamic and you should refer to your supplied documentation for more information.

Note: This feature requires approval and will not function unless permission is granted.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
source.vid number body required Source identifier
source.lid number body required Lead type identifier
source.aid number body optional Campaign identifier
source.sendDelay number body required Amount (in hours) to delay sending the lead
source.returnURL string body optional For async processing, this url will be called when processing is completed with the response details.
lead.properties.orderId string body optional Inbound PING order ID received (if needed)
lead.properties.reference string body optional Reference value to store on the record for reporting purposes
lead.properties.noSell bool body optional Prevent the lead from being delivered automatically
lead.fields lead_fields body required Field information being passed about the incomming lead.
POST /v2/insert/general HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

{
    "source": {
        "vid": 0,
        "aid": 0,
        "lid": 0,
        "sendDelay": 0.0,
        "returnURL": ""
    },
    "leads": [
        {
            "properties": {
                "reference": "",
                "noSell": false,
                "orderId": ""
            },
            "fields": {
                "FirstName": "",
                "LastName": "",
                ...
            }
        }
    ]
}
POST /v2/insert/general HTTP/1.1
host: leads.leadexec.net
content-type: application/xml
accept: application/xml
authorization: Bearer [acces_token]

<Leads vid="" lid="" aid="">
<Lead reference="">
...
</Lead>
</Leads>

Response


Property Type Description Example
requestId string Log identifier for the request guid
results array Array of result objects
results.isValid bool Result of the transaction true
false
results.responseType response_type Type of response No_Error
System_ID_Missing
LeadType_ID_Missing
Vendor_ID_Missing
No_Account_Found
Outside_Criteria
Duplicate_Lead
Account_Disabled
Post_Over_Max
Data_Errors
results.responseMessage string Details about the transaction and why it may have failed Lead was accepted
results.leadId number ID of the lead record received 123456789
results.campaignId number ID of the campaign being assigned 1234
results.isPendingReview bool Is record under quality review true
false
results.price number The price being paid for the record 0.00
results.sends array of sends The results of the delivery process
results.sends.clientId number Identifier of the target client
results.sends.clientName string Name of the target client
results.sends.redirectURL string URL the consumer should be directed to. (if any)
results.sends.valid bool Result of the delivery to the target client
results.sends.price number Delivery price of the target client
{
    "requestId": "",
    "results": [
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0,
            "sends": [
                {
                    "clientId": 0,
                    "clientName": "",
                    "redirectURL": "",
                    "valid": true,
                    "price": 0.0
                },
                {
                    "clientId": 0,
                    "clientName": "",
                    "redirectURL": "",
                    "valid": true,
                    "price": 0.0
                }
            ]
        },
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0,
            "sends": [
                {
                    "clientId": 0,
                    "clientName": "",
                    "redirectURL": "",
                    "valid": true,
                    "price": 0.0
                },
                {
                    "clientId": 0,
                    "clientName": "",
                    "redirectURL": "",
                    "valid": true,
                    "price": 0.0
                }
            ]
        }
    ]
}
<SendsReceiverResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LeadExec.LeadReceiver.API.Models">
    <RequestId>929f4d31-5576-49b5-ae9b-606d94a475e2</RequestId>
    <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/LeadImportService.Core.Classes">
        <d2p1:SendResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
            <Sends>
                <Send>
                    <ClientUID>0</ClientUID>
                    <ClientName></ClientName>
                    <RedirectURL />
                    <Valid>true</Valid>
                    <Price>0.0</Price>
                </Send>
            </Sends>
        </d2p1:SendResponse>
        <d2p1:SendResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
            <Sends>
                <Send>
                    <ClientUID>0</ClientUID>
                    <ClientName></ClientName>
                    <RedirectURL />
                    <Valid>true</Valid>
                    <Price>0.0</Price>
                </Send>
            </Sends>
        </d2p1:SendResponse>
    </Results>
</SendsReceiverResult>

POST

Create Call Transfer Lead

Creates a new lead in the system, this endpoint will return the agent name and phone number the call should be transferred to. Fields are dynamic and you should refer to your supplied documentation for more information.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
source.vid number body required Source identifier
source.lid number body required Lead type identifier
source.aid number body optional Campaign identifier
source.sendDelay number body required Amount (in hours) to delay sending the lead
source.returnURL string body optional For async processing, this url will be called when processing is completed with the response details.
lead.properties.orderId string body optional Inbound PING order ID received (if needed)
lead.properties.reference string body optional Reference value to store on the record for reporting purposes
lead.properties.noSell bool body optional Prevent the lead from being delivered automatically
lead.fields lead_fields body required Field information being passed about the incomming lead.
POST /v2/insert/transfer HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

{
    "source": {
        "vid": 0,
        "aid": 0,
        "lid": 0,
        "sendDelay": 0.0,
        "returnURL": ""
    },
    "leads": [
        {
            "properties": {
                "reference": "",
                "noSell": false,
                "orderId": ""
            },
            "fields": {
                "FirstName": "",
                "LastName": "",
                ...
            }
        }
    ]
}
POST /v2/insert/general HTTP/1.1
host: leads.leadexec.net
content-type: application/xml
accept: application/xml
authorization: Bearer [acces_token]

<Leads vid="" lid="" aid="">
<Lead reference="">
...
</Lead>
</Leads>

Response


Property Type Description Example
requestId string Log identifier for the request guid
results array Array of result objects
results.isValid bool Result of the transaction true
false
results.responseType response_type Type of response No_Error
System_ID_Missing
LeadType_ID_Missing
Vendor_ID_Missing
No_Account_Found
Outside_Criteria
Duplicate_Lead
Account_Disabled
Post_Over_Max
Data_Errors
results.responseMessage string Details about the transaction and why it may have failed Lead was accepted
results.leadId number ID of the lead record received 123456789
results.campaignId number ID of the campaign being assigned 1234
results.isPendingReview bool Is record under quality review true
false
results.price number The price being paid for the record 0.00
results.client transfer result The results of the transfer scan
results.client.clientId number Identifier of the target client
results.client.clientName string Name of the target client
results.client.agentName string Name of the agent
results.client.agentPhone string Phone number of the agent
{
    "requestId": "",
    "results": [
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0,
            "client": [
                {
                    "clientId": 0,
                    "clientName": "",
                    "agentName": "",
                    "agentPhone": ""
                },
                {
                    "clientId": 0,
                    "clientName": "",
                    "agentName": "",
                    "agentPhone": ""
                }
            ]
        },
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0,
            "client": [
                {
                    "clientId": 0,
                    "clientName": "",
                    "agentName": "",
                    "agentPhone": ""
                },
                {
                    "clientId": 0,
                    "clientName": "",
                    "agentName": "",
                    "agentPhone": ""
                }
            ]
        }
    ]
}
<TransferReceiverResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LeadExec.LeadReceiver.API.Models">
    <RequestId>929f4d31-5576-49b5-ae9b-606d94a475e2</RequestId>
    <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/LeadImportService.Core.Classes">
        <d2p1:PostTransferResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
            <Sends>
                <Send>
                    <ClientUID>0</ClientUID>
                    <ClientName></ClientName>
                    <RedirectURL />
                    <Valid>true</Valid>
                    <Price>0.0</Price>
                </Send>
            </Sends>
        </d2p1:PostTransferResponse>
        <d2p1:PostTransferResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
            <Sends>
                <Send>
                    <ClientUID>0</ClientUID>
                    <ClientName></ClientName>
                    <RedirectURL />
                    <Valid>true</Valid>
                    <Price>0.0</Price>
                </Send>
            </Sends>
        </d2p1:PostTransferResponse>
    </Results>
</TransferReceiverResult>

POST

Create Call Lead

Creates a new call lead in the system. Fields are dynamic and you should refer to your supplied documentation for more information.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
source.vid number body required Source identifier
source.lid number body required Lead type identifier
source.aid number body optional Campaign identifier
source.sendDelay number body required Amount (in hours) to delay sending the lead
source.returnURL string body optional For async processing, this url will be called when processing is completed with the response details.
lead.properties.orderId string body optional Inbound PING order ID received (if needed)
lead.properties.reference string body optional Reference value to store on the record for reporting purposes
lead.properties.noSell bool body optional Prevent the lead from being delivered automatically
lead.properties.ivrNumber number body required Inbound phone number being called
lead.properties.callDuration number body required The duration of the call in seconds
lead.properties.callResult string body required Description of the result of the call
lead.properties.callDate date body optional Date the call was received
lead.properties.recordingUrl string body optional The URL that contains the audio file for the call recording.
lead.fields lead_fields body required Field information being passed about the incomming lead.
POST /v2/insert/calldata HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

{
    "source": {
        "vid": 0,
        "aid": 0,
        "lid": 0,
        "sendDelay": 0.0,
        "returnURL": ""
    },
    "leads": [
        {
            "properties": {
                "reference": "",
                "noSell": false,
                "ivrNumber": 0,
                "callDuration": 0,
                "callResult": "",
                "callDate": "",
                "recordingUrl": ""
            },
            "fields": {
                "FirstName": "",
                "LastName": "",
                ...
            }
        }
    ]
}
POST /v2/insert/general HTTP/1.1
host: leads.leadexec.net
content-type: application/xml
accept: application/xml
authorization: Bearer [acces_token]

<Leads vid="" lid="" aid="">
<Lead reference="">
    <IVRNumber></IVRNumber>
    <CallDuration></CallDuration>
    <CallResult></CallResult>
    <CallDate></CallDate>
...
</Lead>
</Leads>

Response


Property Type Description Example
requestId string Log identifier for the request guid
results array Array of result objects
results.isValid bool Result of the transaction true
false
results.responseType response_type Type of response No_Error
System_ID_Missing
LeadType_ID_Missing
Vendor_ID_Missing
No_Account_Found
Outside_Criteria
Duplicate_Lead
Account_Disabled
Post_Over_Max
Data_Errors
results.responseMessage string Details about the transaction and why it may have failed Lead was accepted
results.leadId number ID of the lead record received 123456789
results.campaignId number ID of the campaign being assigned 1234
results.isPendingReview bool Is record under quality review true
false
results.price number The price being paid for the record 0.00
{
    "requestId": "",
    "results": [
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0
        },
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0
        }
    ]
}
<LeadReceiverResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LeadExec.LeadReceiver.API.Models">
    <RequestId>929f4d31-5576-49b5-ae9b-606d94a475e2</RequestId>
    <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/LeadImportService.Core.Classes">
        <d2p1:PostResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
        </d2p1:PostResponse>
        <d2p1:PostResponse>
            <IsValid>true</IsValid>
            <ResponseType></ResponseType>
            <ResponseMessage></ResponseMessage>
            <LeadIdentifier>0</LeadIdentifier>
            <CampaignIdentifier>0</CampaignIdentifier>
            <IsPendingReview>false</IsPendingReview>
            <Price>0</Price>
        </d2p1:PostResponse>
    </Results>
</LeadReceiverResult>

PUT

Update Lead

Updates the field properties of existing leads. Fields are dynamic and you should refer to your supplied documentation for more information.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
source.vid number body required Source identifier
source.lid number body required Lead type identifier
lead.properties.leadUID number body required Identifier of the lead being updated
lead.properties.processDelivery bool body optional When true LeadExec will attempt to deliver the lead.
lead.fields lead_fields body required Field information being passed about the updated lead.
PUT /v2/update HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

{
    "source": {
        "vid": 0,
        "lid": 0
    },
    "leads": [
        {
            "properties": {
                "leadUID": 0,
                "processDelivery": false
            },
            "fields": {
                "FirstName": "",
                "LastName": "",
                ...
            }
        }
    ]
}

Response


Property Type Description Example
requestId string Log identifier for the request guid
results array Array of result objects
results.isValid bool Result of the transaction true
false
results.responseType response_type Type of response No_Error
System_ID_Missing
LeadType_ID_Missing
Vendor_ID_Missing
No_Account_Found
Outside_Criteria
Duplicate_Lead
Account_Disabled
Post_Over_Max
Data_Errors
results.responseMessage string Details about the transaction and why it may have failed Lead information updated
results.leadId number ID of the lead record received 123456789
results.campaignId number ID of the campaign being assigned 1234
results.isPendingReview bool Is record under quality review true
false
results.price number The price being paid for the record 0.00
{
    "requestId": "",
    "results": [
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0
        },
        {
            "isValid": true,
            "responseType": "",
            "responseMessage": "",
            "leadId": 0,
            "campaignId": 0,
            "isPendingReview": false,
            "price": 0.0
        }
    ]
}

POST

Create Inbound PING

Creates an inbound PING and returns an order ID if accepted.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
source.vid number body required Source identifier
source.lid number body required Lead type identifier
source.aid number body optional Campaign identifier
lead.fields lead_fields body required Basic field information being passed about the potential lead.
POST /v2/insert/ping HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

{
    "source": {
        "vid": 0,
        "aid": 0,
        "lid": 0
    },
    "leads": [
        {
            "properties": {
            },
            "fields": {
                "State": "",
                "Zip": "",
                ...
            }
        }
    ]
}
POST /v2/insert/general HTTP/1.1
host: leads.leadexec.net
content-type: application/xml
accept: application/xml
authorization: Bearer [acces_token]

<Leads vid="" lid="" aid="">
<Lead reference="">
    <State></State>
    <Zip></Zip>
...
</Lead>
</Leads>

Response


Property Type Description Example
requestId string Log identifier for the request guid
results array Array of result objects
results.willAccept bool Result of the transaction true
false
results.orderId string ID of the order being created
results.orderExpiresOn date Date and time (in UTC) the order expires.
results.estimatedPayout number The estimated payout based on the order scan.
Note: This is not a guaranteed price as the final lead may produce different results based on the information supplied, please be sure to read the final price when submitted.
0.0
results.campaignId number The identifier of the campaign the order is assigned to.
results.response string Information about the result of the request Coverage found, please supplied Order ID in POST
results.offers Array<Offer> Offers to be displayed to end consumer for 1 to 1 consent
results.offers.offerId string Identifier of the offer
results.offers.companyName string Name of the contacting company
results.offers.companyPhoneNumber string Phone number of the contacting company
results.offers.name string Name of the offer being presented 30 day introductory offer
results.offers.description string Description of the offer being presented
results.offers.type string Duration of the amount being offered (Monthly or Yearly)
results.offers.price number The price of the offer being presented
results.offers.url string The URL to direct the consumer to for more information or if selected
results.offers.tcpaInformation TCPA Details Information about TCPA language to present for this offer
results.offers.tcpaInformation.customTCPATextRequired bool Is custom TCPA text required to be presented to consumer
results.offers.tcpaInformation.tcpaText string Custom TCPA language to display
results.offers.tcpaInformation.privacyURL string Location of company privacy policy
results.offers.tcpaInformation.privacyURL string Location of company terms policy
{
    "requestId": "",
    "results": [
        {
            "willAccept": true,
            "orderId": "",
            "orderExpiresOn": "2024-08-29T16:25:12Z",
            "estimatedPayout": 0.0,
            "campaignId": 0,
            "response": "",
            "offers": [
                {
                    "offerId": "",
                    "companyName": "",
                    "companyPhoneNumber": "",
                    "name": "",
                    "description": "",
                    "type": "Monthly",
                    "price": 0.0,
                    "url": "",
                    "tcpaInformation": {
                        "customTCPATextRequired": true,
                        "tcpaText": "",
                        "privacyURL": "",
                        "termsURL": ""
                    }
                }
            ]
        },
        {
            "willAccept": true,
            "orderId": "",
            "orderExpiresOn": "2024-08-29T16:25:12Z",
            "estimatedPayout": 0.0,
            "campaignId": 0,
            "response": "",
            "offers": [
                {
                    "offerId": "",
                    "companyName": "",
                    "companyPhoneNumber": "",
                    "name": "",
                    "description": "",
                    "type": "Monthly",
                    "price": 0.0,
                    "url": "",
                    "tcpaInformation": {
                        "customTCPATextRequired": true,
                        "tcpaText": "",
                        "privacyURL": "",
                        "termsURL": ""
                    }
                }
            ]
        }
    ]
}
<PingReceiverResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LeadExec.LeadReceiver.API.Models">
    <RequestId>929f4d31-5576-49b5-ae9b-606d94a475e2</RequestId>
    <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/LeadImportService.Core.Classes">
        <d2p1:PingResponse>
            <WillAccept>true</WillAccept>
            <OrderID></OrderID>
            <OrderExpiresOn>0</OrderExpiresOn>
            <CampaignID>0</CampaignID>
            <EstimatedPayout></EstimatedPayout>
            <Response>0</Response>
            <Offers>
                <Offer>
                    <Id></Id>
                    <CompanyName></CompanyName>
                    <CompanyPhoneNumber></CompanyPhoneNumber>
                    <Name></Name>
                    <Description></Description>
                    <Type>Monthly</Type>
                    <Price>0.0</Price>
                    <Url></Url>
                    <TCPAInformation>
                        <CustomTCPATextRequired>True</CustomTCPATextRequired>
                        <TCPAText></TCPAText>
                        <PrivacyUrl></PrivacyUrl>
                        <TermsUrl></TermsUrl>
                    </TCPAInformation>
                </Offer>
            </Offers>
        </d2p1:PingResponse>
        <d2p1:PingResponse>
            <WillAccept>true</WillAccept>
            <OrderID></OrderID>
            <OrderExpiresOn>0</OrderExpiresOn>
            <CampaignID>0</CampaignID>
            <EstimatedPayout></EstimatedPayout>
            <Response>0</Response>
            <Offers>
                <Offer>
                    <Id></Id>
                    <CompanyName></CompanyName>
                    <CompanyPhoneNumber></CompanyPhoneNumber>
                    <Name></Name>
                    <Description></Description>
                    <Type>Monthly</Type>
                    <Price>0.0</Price>
                    <Url></Url>
                    <TCPAInformation>
                        <CustomTCPATextRequired>True</CustomTCPATextRequired>
                        <TCPAText></TCPAText>
                        <PrivacyUrl></PrivacyUrl>
                        <TermsUrl></TermsUrl>
                    </TCPAInformation>
                </Offer>
            </Offers>
        </d2p1:PingResponse>
    </Results>
</PingReceiverResult>

POST

Duplicate Check

Query the system for the existance of a lead with similar properties.

Note: This endpoint requires additional permissions, please contact your account manager for more information.

Request


Parameter Type Position Required Description
access_token string header required Authentication Key
source.vid number body required Source identifier
source.lid number body required Lead type identifier
source.aid number body required Campaign identifier
lead.fields lead_fields body required Field information being passed about the potential lead.
POST /v2/duplicate/check HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

{
    "source": {
        "vid": 0,
        "aid": 0,
        "lid": 0
    },
    "leads": [
        {
            "properties": {
            },
            "fields": {
                "Email": ""
                ...
            }
        }
    ]
}
POST /v2/duplicate/check HTTP/1.1
host: leads.leadexec.net
content-type: application/xml
accept: application/xml
authorization: Bearer [acces_token]

<Leads vid="" lid="" aid="">
<Lead reference="">
    <Email></Email>
...
</Lead>
</Leads>

Response


Property Type Description Example
success bool Result of the duplicate scan. true
false
isDuplicate bool Result of the duplicate scan to determine if a simlar lead exists. true
false
DuplidateLeadId number Identifier of original lead
results.receivedOn date Date original lead was received
results.response string Information on the result of the query
{
    "requestId": "",
    "results": [
        {
            "success": true,
            "isDuplicate": true,
            "duplicateLeadId": 0,
            "receivedOn": "2024-08-29T16:25:12Z",
            "response": ""
        },
        {
            "success": true,
            "isDuplicate": true,
            "duplicateLeadId": 0,
            "receivedOn": "2024-08-29T16:25:12Z",
            "response": ""
        }
    ]
}
<DuplicateCheckResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LeadExec.LeadReceiver.API.Models">
    <RequestId>929f4d31-5576-49b5-ae9b-606d94a475e2</RequestId>
    <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/LeadImportService.Core.Classes">
        <d2p1:DupResponse>
            <Success>true</Success>
            <IsDuplicate></IsDuplicate>
            <DuplicateLeadId>0</DuplicateLeadId>
            <ReceivedOn>0</ReceivedOn>
            <Response></Response>
        </d2p1:DupResponse>
        <d2p1:DupResponse>
            <Success>true</Success>
            <IsDuplicate></IsDuplicate>
            <DuplicateLeadId>0</DuplicateLeadId>
            <ReceivedOn>0</ReceivedOn>
            <Response></Response>
        </d2p1:DupResponse>
    </Results>
</DuplicateCheckResult>

GET

Lead Request Status

Returns the latest status of a lead request, this includes if the lead has been processed, rejected, or returned.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
id string query required Request identifier received from the create lead response.
GET /v2/status/{id} HTTP/1.1
host: leads.leadexec.net
accept: application/json
api-key: [api-key]

Response


Property Type Description Example
requestId string ID of the request being checked
results array of result Results of the status check
results.leadId number Identifier of lead received
results.isValid bool Was the lead accepted by the system
results.rejectionReason string If isValid=false this will contain the reason for the failure.
results.campaignId number Campaign identifier assigned
results.dateReceived date Date and time the request was received in UTC.
results.qualityControlDetails Quality Control Info The current state of the quality control review
results.qualityControlDetails.isPendingReview bool Is the lead awaiting review by quality control team.
results.qualityControlDetails.dateOfReview date Date lead was reviewed by quality control.
results.qualityControlDetails.isQualityControlRejected bool Was the lead rejected during the review process.
results.qualityControlDetails.rejectionReason string If isQualityControlRejected=true this will contain the rason for the rejection.
results.returnDetails Return Info The current return state of the lead
results.returnDetails.isReturned bool Has the lead been marked as returned
results.returnDetails.dateOfReturn date Date the lead was marked as a return
results.returnDetails.returnReason string If isReturn=true this will contain the reason for the return
{
    "requestId": "",
    "results": [
        {
            "leadId": 0,
            "isValid": false,
            "rejectionReason": "",
            "campaignId": 0,
            "dateReceived": "2024-08-28T21:20:38.573Z",
            "qualityControlDetails": {
                "isPendingReview": false,
                "dateOfReview": "2024-08-28T21:20:41.117Z",
                "isQualityControlRejected": true,
                "rejectionReason": ""
            },
            "returnDetails": {
                "isReturned": false,
                "dateOfReturn": null,
                "returnReason": ""
            }
        },
        {
            "leadId": 0,
            "isValid": false,
            "rejectionReason": "",
            "campaignId": 0,
            "dateReceived": "2024-08-28T21:20:42.410Z",
            "qualityControlDetails": {
                "isPendingReview": false,
                "dateOfReview": "2024-08-28T21:20:45.287Z",
                "isQualityControlRejected": true,
                "rejectionReason": ""
            },
            "returnDetails": {
                "isReturned": false,
                "dateOfReturn": null,
                "returnReason": ""
            }
        }
    ]
}

PUT

Mark Offer as Accepted

Mark an offer presented to an end consumer as accepted.

Request


Parameter Type Position Required Description
api-key string header required Authentication Key
leadUID number body required Identifier of the lead record
offerId string body required Identifier of the offer being accepted
PUT /v2/leads/[leadUID]/offers/[offerId]/accept HTTP/1.1
host: leads.leadexec.net
content-type: application/json
accept: application/json
api-key: [api-key]

Response


Property Type Description Example
success bool Result of the request. true
false
Message string Information about the result.
{
    "success": true,
    "message": "Offer accepted"
}

Code Examples

The following are examples of how to interact with this API using different code languages.

Note: This information is subject to change, and may not reflect the latest technologies.


.NET Framework (C#)

  1. Setup: Ensure that your project references System.Net.Http. You can add this by right-clicking on your project in Visual Studio, selecting "Manage NuGet Packages", and searching for System.Net.Http if it's not already included.
  2. Create a Class for the Request Payload: Define classes that mirror the structure of the expected JSON payload.
    public class Source
    {
        public int vid { get; set; }
        public int aid { get; set; }
        public int lid { get; set; }
        public double sendDelay { get; set; }
        public string returnURL { get; set; }
    }
    
    public class Properties
    {
        public string reference { get; set; }
        public bool noSell { get; set; }
        public string orderId { get; set; }
    }
    
    public class Fields
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        // Add other fields as needed
    }
    
    public class Lead
    {
        public Properties properties { get; set; }
        public Fields fields { get; set; }
    }
    
    public class InsertRequest
    {
        public Source source { get; set; }
        public List<Lead> leads { get; set; }
    }
    
  3. Send the POST Request: Use HttpClient to send the request to the API endpoint.
    using System;
    using System.Collections.Generic;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Text;
    using System.Threading.Tasks;
    using Newtonsoft.Json; // Install Newtonsoft.Json via NuGet
    
    class Program
    {
        static async Task Main(string[] args)
        {
            var client = new HttpClient();
            client.BaseAddress = new Uri("https://leads.leadexec.net");
    
            // Set up request headers
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("api-key", "[api-key]");
    
            // Create request payload
            var request = new InsertRequest
            {
                source = new Source
                {
                    vid = 0,
                    aid = 0,
                    lid = 0,
                    sendDelay = 0.0,
                    returnURL = ""
                },
                leads = new List<Lead>
                {
                    new Lead
                    {
                        properties = new Properties
                        {
                            reference = "",
                            noSell = false,
                            orderId = ""
                        },
                        fields = new Fields
                        {
                            FirstName = "",
                            LastName = "",
                            // Populate other fields as needed
                        }
                    }
                }
            };
    
            // Convert request payload to JSON
            var json = JsonConvert.SerializeObject(request);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
    
            try
            {
                // Send POST request
                HttpResponseMessage response = await client.PostAsync("/v2/insert/general", content);
    
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Request succeeded!");
                    string responseContent = await response.Content.ReadAsStringAsync();
                    Console.WriteLine("Response: " + responseContent);
                }
                else
                {
                    Console.WriteLine("Request failed. Status Code: " + response.StatusCode);
                    string errorContent = await response.Content.ReadAsStringAsync();
                    Console.WriteLine("Error: " + errorContent);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred: " + ex.Message);
            }
        }
    }
    

Explanation

  • HttpClient: This class is used to send HTTP requests and receive HTTP responses from resource identified by the URI.
  • Request Headers: We set the Accept head to application/json to indicate that we expect a JSON response. The Authorization header is set with the Bearer token to authenticate the request.
  • Serialization: We use Newtonsoft.Json (also known as Json.NET) to serialize the C# object into a JSON string.
  • Error Handling: The code includes basic error handling to catch and display any exceptions that occur during the HTTP request.

Note

  • Replace [access_token] with the actual token you are using for authentication.
  • Ensure that all necessary fields are filled in according to your API documentation.
  • For production use, consider handling exceptions more gracefully and implementing retry logic if needed.

Classic ASP

  1. Setup: Ensure that your server supports classic ASP and has the necessary permissions to make HTTP requests.
  2. Create an ASP Page to Make the HTTP POST Request: Here's a sample ASP code to make a POST request to the endpoint:
    <%
    Dim xmlhttp, url, authToken, postData
    
    ' Initialize the XMLHTTP object
    Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    ' Set the request URL
    url = "https://leads.leadexec.net/v2/insert/general"
    
    ' Set the Bearer token for authorization
    api-key = "[api-key]" ' Replace [api-key] with your actual token
    
    ' Create the JSON payload
    postData = "{" & _
        """source"": {" & _
            """vid"": 0," & _
            """aid"": 0," & _
            """lid"": 0," & _
            """sendDelay"": 0.0," & _
            """returnURL"": """"}," & _
        """leads"": [{" & _
            """properties"": {" & _
                """reference"": """"," & _
                """noSell"": false," & _
                """orderId"": """"}," & _
            """fields"": {" & _
                """FirstName"": """"," & _
                """LastName"": """"," & _
                """Email"": """"," & _
                """Phone"": """" " & _
            "}" & _
        "}]" & _
    "}"
    
    ' Open a connection to the server
    xmlhttp.Open "POST", url, False
    
    ' Set request headers
    xmlhttp.setRequestHeader "Content-Type", "application/json"
    xmlhttp.setRequestHeader "Accept", "application/json"
    xmlhttp.setRequestHeader "Authorization", authToken
    
    ' Send the request with the JSON payload
    xmlhttp.Send postData
    
    ' Get the response
    If xmlhttp.Status = 200 Then
        Response.Write "Request succeeded!<br>"
        Response.Write "Response: " & xmlhttp.responseText
    Else
        Response.Write "Request failed. Status Code: " & xmlhttp.Status & "<br>"
        Response.Write "Error: " & xmlhttp.responseText
    End If
    
    ' Clean up
    Set xmlhttp = Nothing
    %>
    

Explanation

  • ServerXMLHTTP: The ServerXMLHTTP object allows you to send HTTP requests and handle server responses. It is more suitable for server-side operations in ASP compared to the XMLHTTP object.
  • Request Headers: The headers Content-Type, Accept, and Authorization are set to ensure the server correctly processes the request and authenticates it.
  • JSON Payload: The postData variable contains the JSON payload formatted as a string. Ensure the JSON structure matches what the API expects.
  • Response Handling: The code checks the Status property of the xmlhttp object to determine if the request was successful (HTTP 200 OK). It outputs the server's response or an error message accordingly.

Note

  • Replace [access_token] with the actual token you are using for authentication.
  • Security Considerations: Classic ASP is an older technology; ensure that your server is secure and up-to-date. Avoid exposing sensitive data unnecessarily.

PHP

  1. Ensure cURL is Enabled: Most PHP installations have cURL enabled by default. If it's not enabled, you need to install it or enable it in your php.ini file.
  2. Create a PHP Script to Make the HTTP POST Request: Here's a sample PHP code to make a POST request to your endpoint:
    <?php
    
    // The URL of the API endpoint
    $url = "https://leads.leadexec.net/v2/insert/general";
    
    // The Bearer token for authorization
    $apiKey = "[api-key]"; // Replace [api-key] with your actual token
    
    // Create the JSON payload
    $data = array(
        "source" => array(
            "vid" => 0,
            "aid" => 0,
            "lid" => 0,
            "sendDelay" => 0.0,
            "returnURL" => ""
        ),
        "leads" => array(
            array(
                "properties" => array(
                    "reference" => "",
                    "noSell" => false,
                    "orderId" => ""
                ),
                "fields" => array(
                    "FirstName" => "",
                    "LastName" => "",
                    "Email" => "",
                    "Phone" => ""
                    // Add other fields as needed
                )
            )
        )
    );
    
    // Encode the array into a JSON string
    $jsonData = json_encode($data);
    
    // Initialize cURL session
    $ch = curl_init($url);
    
    // Set cURL options
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Accept: application/json',
        'api-key: $apiKey
    ));
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
    
    // Execute the POST request
    $response = curl_exec($ch);
    
    // Check for cURL errors
    if ($response === false) {
        echo 'Curl error: ' . curl_error($ch);
    } else {
        // Check HTTP response status code
        $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($httpStatus == 200) {
            echo "Request succeeded!<br>";
            echo "Response: " . $response;
        } else {
            echo "Request failed. Status Code: " . $httpStatus . "<br>";
            echo "Error: " . $response;
        }
    }
    
    // Close cURL session
    curl_close($ch);
    
    ?>
    

Explanation

  • cURL Initialization: curl_init() initializes a new cURL session
  • Setting cURL Options:
    • CURLOPT_RETURNTRANSFER ensures the response is returned as a string instead of outputting it directly.
    • CURLOPT_HTTPHEADER sets the necessary headers for the request, including Content-Type, Accept, and Authorization headers.
    • CURLOPT_POST indicates that this is a POST request.
    • CURLOPT_POSTFIELDS sets the JSON-encoded data as the POST body.
  • Error Handling: The script checks if the cURL execution was successful. If not, it prints the cURL error. If successful, it checks the HTTP response status code to determine whether the request was successful.

Note

  • Replace [access_token] with the actual token you are using for authentication.
  • JSON Encoding: Ensure that the data structure matches the API's expected format. Use json_encode() to convert PHP arrays to JSON strings.
  • Security Considerations: Make sure to handle sensitive data securely and follow best practices for error handling and logging.
  • PHP Version: This script is compatible with most PHP versions that support cURL, typically PHP 5.1.3 and later.

Python

  1. Setup: Ensure you have Python installed on your system. Install the requests library if it is not already installed:
    pip install requests
  2. Create a Python Script to Make the HTTP POST Request:

    Here's a sample Python code to make a POST request to your endpoint:

    import requests
    import json
    
    # The URL of the API endpoint
    url = "https://leads.leadexec.net/v2/insert/general"
    
    # The Bearer token for authorization
    apiKey = "[api-key]"  # Replace [api-key] with your actual token
    
    # Create the JSON payload
    data = {
        "source": {
            "vid": 0,
            "aid": 0,
            "lid": 0,
            "sendDelay": 0.0,
            "returnURL": ""
        },
        "leads": [
            {
                "properties": {
                    "reference": "",
                    "noSell": False,
                    "orderId": ""
                },
                "fields": {
                    "FirstName": "",
                    "LastName": "",
                    "Email": "",
                    "Phone": ""
                    # Add other fields as needed
                }
            }
        ]
    }
    
    # Convert the data to a JSON string
    json_data = json.dumps(data)
    
    # Set the headers for the request
    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "api-key": apiKey
    }
    
    # Send the POST request
    response = requests.post(url, headers=headers, data=json_data)
    
    # Check the response
    if response.status_code == 200:
        print("Request succeeded!")
        print("Response:", response.json())
    else:
        print(f"Request failed. Status Code: {response.status_code}")
        print("Error:", response.text)
    

Explanation

  • Requests Library: The requests library simplifies making HTTP requests in Python. It provides methods like requests.post() for POST requests.
  • JSON Payload: The data dictionary represents the JSON payload to be sent in the request. It is converted to a JSON string using json.dumps().
  • Headers: The headers dictionary specifies the Content-Type, Accept, and Authorization headers to be included in the request.
  • Sending the Request: The requests.post() method sends the POST request to the specified URL with the given headers and JSON payload.
  • Response Handling: The script checks the status_code of the response to determine if the request was successful (HTTP 200 OK). It prints the response content or error message accordingly.

Note

  • Replace [access_token] with the actual token you are using for authentication.
  • Error Handling: The script checks for HTTP status codes to handle errors. You can further improve error handling by catching exceptions (e.g., network errors) using a try-except block.
  • Python Version: This script is compatible with Python 3.x. Ensure you're using an up-to-date version of Python.

Perl

  1. Setup: Ensure that Perl is install on the system and the LWP::UserAgent module is available.

    You can install it using CPAN if needed:

    cpan install LWP::UserAgent
  2. Create a Perl Script to Make the HTTP POST Request:

    Here's a sample Perl code to make a POST request to your endpoint:

    use strict;
    use warnings;
    use LWP::UserAgent;
    use HTTP::Request;
    use JSON;
    
    # Initialize the user agent
    my $ua = LWP::UserAgent->new;
    
    # The URL of the API endpoint
    my $url = 'https://leads.leadexec.net/v2/insert/general';
    
    # The Bearer token for authorization
    my $api_key = '[api-key]'; # Replace [api-key] with your actual token
    
    # Create the JSON payload
    my $data = {
        source => {
            vid       => 0,
            aid       => 0,
            lid       => 0,
            sendDelay => 0.0,
            returnURL => ''
        },
        leads => [
            {
                properties => {
                    reference => '',
                    noSell    => \0,  # Use a reference to scalar to represent a JSON boolean
                    orderId   => ''
                },
                fields => {
                    FirstName => '',
                    LastName  => '',
                    Email     => '',
                    Phone     => ''
                    # Add other fields as needed
                }
            }
        ]
    };
    
    # Convert the Perl data structure to a JSON string
    my $json_data = encode_json($data);
    
    # Create the HTTP request object
    my $req = HTTP::Request->new(POST => $url);
    $req->header('Content-Type'  => 'application/json');
    $req->header('Accept'        => 'application/json');
    $req->header('api-key' => "$api_key");
    $req->content($json_data);
    
    # Send the request
    my $response = $ua->request($req);
    
    # Check the response
    if ($response->is_success) {
        print "Request succeeded!\n";
        print "Response: " . $response->decoded_content . "\n";
    } else {
        print "Request failed. Status Code: " . $response->code . "\n";
        print "Error: " . $response->message . "\n";
    }
    

Explanation

  • LWP::UserAgent: This module provides a user agent object that can be used to make HTTP requests. It's part of the LWP (Library for WWW in Perl) suite.
  • HTTP::Reques: This module represents an HTTP request. It is used to build the request with the appropriate HTTP method (POST) and headers.
  • JSON: This module is used to encode the Perl data structure into a JSON string. It provides functions for converting between JSON strings and Perl data structures.
  • Request Headers: The headers Content-Type, Accept, and Authorization are set to ensure the server correctly processes the request and authenticates it.
  • Error Handling: The code checks if the request was successful using $response->is_success. If not, it prints the HTTP status code and error message.

Note

  • Replace [access_token] with the actual token you are using for authentication.
  • JSON Boolean Representation: In Perl, JSON booleans can be represented using references to scalar values (\1 for true, \0 for false).
  • Security Considerations: Ensure to handle sensitive data securely and follow best practices for error handling and logging.
  • Perl Version: This script is compatible with most versions of Perl that support LWP::UserAgent and JSON.

Java

Using HttpURLConnection (Java 8 and earlier)

  1. Setup: Ensure you have Java Development Kit (JDK) installed.
  2. Create a Java Class to Make the HTTP POST Request: Here's a sample Java code using HttpURLConnection:
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.nio.charset.StandardCharsets;
    
    public class ApiPostRequest {
        public static void main(String[] args) {
            try {
                // The URL of the API endpoint
                URL url = new URL("https://leads.leadexec.net/v2/insert/general");
    
                // Open a connection to the URL
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    
                // Set the request method to POST
                conn.setRequestMethod("POST");
    
                // Set request headers
                conn.setRequestProperty("Content-Type", "application/json");
                conn.setRequestProperty("Accept", "application/json");
                conn.setRequestProperty("api-key", "[api-key]"); // Replace [api-key] with your actual token
    
                // Enable input and output streams
                conn.setDoOutput(true);
    
                // Create the JSON payload
                String jsonInputString = "{"
                        + "\"source\": {"
                        + "\"vid\": 0,"
                        + "\"aid\": 0,"
                        + "\"lid\": 0,"
                        + "\"sendDelay\": 0.0,"
                        + "\"returnURL\": \"\""
                        + "},"
                        + "\"leads\": ["
                        + "{"
                        + "\"properties\": {"
                        + "\"reference\": \"\","
                        + "\"noSell\": false,"
                        + "\"orderId\": \"\""
                        + "},"
                        + "\"fields\": {"
                        + "\"FirstName\": \"\","
                        + "\"LastName\": \"\","
                        + "\"Email\": \"\","
                        + "\"Phone\": \"\""
                        + "}"
                        + "}"
                        + "]"
                        + "}";
    
                // Write JSON data to the output stream
                try (OutputStream os = conn.getOutputStream()) {
                    byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                    os.write(input, 0, input.length);
                }
    
                // Get the response code
                int responseCode = conn.getResponseCode();
                System.out.println("Response Code: " + responseCode);
    
                // Read the response
                if (responseCode == HttpURLConnection.HTTP_OK) { // success
                    try (var reader = new java.io.BufferedReader(
                            new java.io.InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
                        StringBuilder response = new StringBuilder();
                        String responseLine;
                        while ((responseLine = reader.readLine()) != null) {
                            response.append(responseLine.trim());
                        }
                        System.out.println("Response: " + response.toString());
                    }
                } else {
                    System.out.println("Request failed. Response Code: " + responseCode);
                }
    
                // Close the connection
                conn.disconnect();
    
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

Explanation

  • HttpURLConnection: This class allows you to send HTTP requests and receive responses from a URL.
  • Setting Request Headers: The setRequestProperty method sets the request headers for Content-Type, Accept, and Authorization.
  • Sending Data: The setDoOutput(true) method enables the output stream, and OutputStream is used to write the JSON payload to the server.
  • Reading Reaponse: The input stream reads the server's response, which is handled using a BufferedReader.
  • Error Handling: The script checks the response code to determine whether the request was successful (HTTP 200 OK).

Using HttpClient (Java 11 and later)

  1. Setup: Ensure you are using JDK 11 or later.
  2. Create a Java Class to Make the HTTP POST Request: Here's a sample Java code using HttpClient:
    import java.net.URI;
    import java.net.http.HttpClient;
    import java.net.http.HttpRequest;
    import java.net.http.HttpResponse;
    import java.net.http.HttpRequest.BodyPublishers;
    import java.net.http.HttpResponse.BodyHandlers;
    
    public class ApiPostRequest {
        public static void main(String[] args) {
            try {
                // The URL of the API endpoint
                URI uri = new URI("https://leads.leadexec.net/v2/insert/general");
    
                // Create the JSON payload
                String jsonInputString = "{"
                        + "\"source\": {"
                        + "\"vid\": 0,"
                        + "\"aid\": 0,"
                        + "\"lid\": 0,"
                        + "\"sendDelay\": 0.0,"
                        + "\"returnURL\": \"\""
                        + "},"
                        + "\"leads\": ["
                        + "{"
                        + "\"properties\": {"
                        + "\"reference\": \"\","
                        + "\"noSell\": false,"
                        + "\"orderId\": \"\""
                        + "},"
                        + "\"fields\": {"
                        + "\"FirstName\": \"\","
                        + "\"LastName\": \"\","
                        + "\"Email\": \"\","
                        + "\"Phone\": \"\""
                        + "}"
                        + "}"
                        + "]"
                        + "}";
    
                // Create the HttpClient
                HttpClient client = HttpClient.newHttpClient();
    
                // Create the HttpRequest
                HttpRequest request = HttpRequest.newBuilder()
                        .uri(uri)
                        .header("Content-Type", "application/json")
                        .header("Accept", "application/json")
                        .header("Authorization", "Bearer [access_token]") // Replace [access_token] with your actual token
                        .POST(BodyPublishers.ofString(jsonInputString))
                        .build();
    
                // Send the request and get the response
                HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
    
                // Print the response
                if (response.statusCode() == 200) {
                    System.out.println("Request succeeded!");
                    System.out.println("Response: " + response.body());
                } else {
                    System.out.println("Request failed. Status Code: " + response.statusCode());
                    System.out.println("Error: " + response.body());
                }
    
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

Explanation

  • HttpClient: The HttpClient class provides a more modern and easier-to-use API for making HTTP requests.
  • HttpRequest: The HttpRequest class is used to build the request, set the headers, and specify the HTTP method and payload.
  • HttpResponse: The HttpResponse class is used to handle the response from the server.
  • Error Handling: The code checks the status code of the response to determine success or failure.

Notes

  • Replace [access_token] with your actual Bearer token for authentication.
  • JSON Payload: Ensure the JSON structure matches the API requirements.
  • Java Version: Use HttpURLConnection for Java 8 and earlier and HttpClient for Java 11 and later for a more modern approach.