Skip to main content
Adding Leads via API

This article covers examples of how to add leads via PHP, cURL

Korey Abbott avatar
Written by Korey Abbott
Updated over a month ago

Please Note: this section is intended with users with a high degree of technical knowledge and experience in back end development.

Get Your Integration Document

Before we begin in you'll need to have an integration document to hand for the campaign you will be working with.

Open the HTTP POST tab, which is the cogs icon.

And you should have something like this.

This document (in addition to this guide) covers everything you need to submit leads into the Databowl instance.

Quick Tips:

The following come up fairly frequently, so please ensure they are observed:

Request Type:

Databowl will only work with HTTP POST.

If you are attempting to use GET and are experiencing issues, please change to a POST request instead.

Server Side:

Databowl will only work server side code, we do not allow front end code to work with the system as it could expose the end points to the general public and risk fraudulent data being submitted to your instance.

Understanding the Data:

Whatever language or system you are using, the following information is always required:

End point/URL

This is listed at the top of the doc. In this instance, it's listed as follows, tho yours will differ: https://xyz.databowl.com/api/v1/lead

Headers

Content-Type

Requires a value of application/x-www-form-urlencoded

Content-Length

This should be a calculation of the payload, if you're unable to do this, please do not include this.

Host

This is the address of your databowl instance. Submitting may work OK without this, but if you require it, then the integration doc will show you something like this:

https://xyz.databowl.com/api/v1/lead

So xyz.databowl.com is the value you'd need

Data

The integration doc covers each field, whether it's required, as well as formats that the data needs to follow. Ensure this is observed to avoid errors.

Add each data you need.

The cid and sid are static values, they will be the same for each campaign and supplier that you are working with. Please enter them in as shown in the doc.

In this example, we're using, the following, but yours will differ

cid: 100 and sid: 200

PHP - cURL - Example

The following example should be updated with your own variables and fields/data being inputted.

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://xyz.databowl.com/api/v1/lead',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'cid=100&sid=200&optin_email=true&optin_phone=true&optin_postal=true&f_1_email=dave%40testerson.com&f_3_firstname=Dave&f_4_lastname=Testerson',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded',
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

cURL - Example

The following example should be updated with your own variables and fields/data being inputted.

curl --location --request POST 'https://xyz.databowl.com/api/v1/lead' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--form 'cid="100"' \
--form 'sid="200"' \
--form 'optin_email="true"' \
--form 'optin_phone="true"' \
--form 'optin_postal="true"' \
--form 'f_1_email="dave@testerson.com"' \
--form 'f_3_firstname="Dave"' \
--form 'f_4_lastname="Testerson"'

Python - Requests - Example

The following example should be updated with your own variables and fields/data being inputted.

import requests

url = "https://eventdemo.databowl.com/api/v1/lead"

payload={'cid': '100',
'sid': '200',
'optin_email': 'true',
'optin_phone': 'true',
'optin_postal': 'true',
'f_1_email': 'dave@testerson.com',
'f_3_firstname': 'Dave',
'f_4_lastname': 'Testerson'}
files=[

]
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

C# - RestSharp - Example

The following example should be updated with your own variables and fields/data being inputted.

var client = new RestClient("https://xyz.databowl.com/api/v1/lead");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AlwaysMultipartFormData = true;
request.AddParameter("cid", "100");
request.AddParameter("sid", "200");
request.AddParameter("optin_email", "true");
request.AddParameter("optin_phone", "true");
request.AddParameter("optin_postal", "true");
request.AddParameter("f_1_email", "dave@testerson.com");
request.AddParameter("f_3_firstname", "Dave");
request.AddParameter("f_4_lastname", "Testerson");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Testing

Once you've run a test, you should receive a JSON object back like this:

{
"result": "created",
"lead_id": "934"
}

result: created

This means the lead is in databowl

lead_id: 930

and this is your lead id, you can now head in to the instance and search 930 to find your lead.

If you've got an Error

If you're not seeing this, adjust your configuration following the integration document closely.

Our integration document explains lots of different error messages, it's just lower on the page and should look like this... so scroll down on there and have a read.


πŸš€ Need More assistance?

If you're stuck or if this isn't something you or your team is comfortable with, then please open a new chat/ticket (chat icon in the bottom right of the screen) or email support@databowl.com.

We're here to assist with any questions you have, and if required we can quote on actioning work like this for as part of our Marketing Services.

Did this answer your question?