Skip to content

Leads API

Capture and manage potential customers through your sales pipeline.

The Leads API allows you to create and retrieve lead records from external sources such as web forms, marketing campaigns, and third-party integrations. Leads represent prospective customers that have not yet converted, and can be tracked through your CRM until they are ready to become active customers.

Use Cases

  • Web Forms: Capture leads from your landing pages and contact forms
  • Marketing Campaigns: Import leads from ad platforms and email campaigns
  • Partner Integrations: Receive referrals from external systems
  • Sales Pipeline: Automate lead entry from your sales tools

Endpoints

MethodEndpointDescription
POST/business/lead/createCreate a new lead
GET/business/lead/listList all leads

Create Lead

Create a new lead record in your CRM.

http
POST /business/lead/create

Request Body

FieldTypeRequiredDescription
namestringYesLead's full name
emailstringNoLead's email address
phonestringNoLead's phone number
companystringNoCompany or organization name
jobtitlestringNoLead's job title
industrystringNoIndustry or sector
websitestringNoCompany or personal website
requeststringNoDescription of their request or interest
budgetnumberNoEstimated budget
countrystringNoCountry
statestringNoState or region
addressstringNoStreet address
sourcestringNoLead source (e.g., website, referral, ad)
statusstringNoInitial status (default: new)

Example Request

bash
curl -X POST "https://api.cashfin.africa/business/lead/create" \
  -H "Authorization: cs_your_client_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Smith",
    "email": "[email protected]",
    "phone": "+254722000001",
    "company": "Acme Corp",
    "jobtitle": "CTO",
    "source": "website",
    "request": "Interested in enterprise billing solution",
    "budget": 50000
  }'
javascript
const response = await fetch(
  "https://api.cashfin.africa/business/lead/create",
  {
    method: "POST",
    headers: {
      Authorization: "cs_your_client_secret",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      name: "Jane Smith",
      email: "[email protected]",
      phone: "+254722000001",
      company: "Acme Corp",
      jobtitle: "CTO",
      source: "website",
      request: "Interested in enterprise billing solution",
      budget: 50000,
    }),
  }
);

const data = await response.json();
console.log(data);
php
<?php
$leadData = [
  'name'    => 'Jane Smith',
  'email'   => '[email protected]',
  'phone'   => '+254722000001',
  'company' => 'Acme Corp',
  'jobtitle'=> 'CTO',
  'source'  => 'website',
  'request' => 'Interested in enterprise billing solution',
  'budget'  => 50000,
];

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://api.cashfin.africa/business/lead/create",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST           => true,
  CURLOPT_POSTFIELDS     => json_encode($leadData),
  CURLOPT_HTTPHEADER     => [
    "Authorization: cs_your_client_secret",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$result   = json_decode($response, true);

print_r($result);
python
import requests

lead_data = {
    'name':    'Jane Smith',
    'email':   '[email protected]',
    'phone':   '+254722000001',
    'company': 'Acme Corp',
    'jobtitle': 'CTO',
    'source':  'website',
    'request': 'Interested in enterprise billing solution',
    'budget':  50000,
}

response = requests.post(
    'https://api.cashfin.africa/business/lead/create',
    headers={
        'Authorization': 'cs_your_client_secret',
        'Content-Type': 'application/json'
    },
    json=lead_data
)

result = response.json()
print(result)

Success Response

json
{
  "success": true,
  "message": "Lead created successfully",
  "data": {
    "_id": "507f1f77bcf86cd799439050",
    "name": "Jane Smith",
    "email": "[email protected]",
    "phone": "+254722000001",
    "company": "Acme Corp",
    "status": "new",
    "source": "website",
    "createdat": "2024-01-15T12:00:00.000Z"
  }
}

List Leads

Retrieve a paginated list of leads with optional filters.

http
GET /business/lead/list

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger10Results per page (max: 100)
searchstring-Search by name, email, phone, or company
statusstring-Filter by status (e.g., new, contacted, qualified, converted)
sourcestring-Filter by lead source (e.g., website, referral)

Example Request

bash
curl -X GET "https://api.cashfin.africa/business/lead/list?page=1&limit=10&status=new" \
  -H "Authorization: cs_your_client_secret"
javascript
const params = new URLSearchParams({
  page: 1,
  limit: 10,
  status: "new",
});

const response = await fetch(
  `https://api.cashfin.africa/business/lead/list?${params}`,
  {
    headers: {
      Authorization: "cs_your_client_secret",
    },
  }
);

const data = await response.json();
console.log(data);
php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://api.cashfin.africa/business/lead/list?page=1&limit=10&status=new",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER     => [
    "Authorization: cs_your_client_secret"
  ],
]);

$response = curl_exec($curl);
$result   = json_decode($response, true);

print_r($result);
python
import requests

response = requests.get(
    'https://api.cashfin.africa/business/lead/list',
    headers={'Authorization': 'cs_your_client_secret'},
    params={'page': 1, 'limit': 10, 'status': 'new'}
)

result = response.json()
print(result)

Success Response

json
{
  "success": true,
  "data": [
    {
      "_id": "507f1f77bcf86cd799439050",
      "name": "Jane Smith",
      "email": "[email protected]",
      "phone": "+254722000001",
      "company": "Acme Corp",
      "status": "new",
      "source": "website",
      "country": null,
      "budget": 50000,
      "createdat": "2024-01-15T12:00:00.000Z",
      "updatedat": "2024-01-15T12:00:00.000Z"
    }
  ],
  "pagination": {
    "total": 42,
    "page": 1,
    "limit": 10,
    "pages": 5
  }
}

Lead Statuses

StatusDescription
newNewly created lead, not yet contacted
contactedInitial contact has been made
qualifiedLead has been qualified as a prospect
convertedLead converted to a customer
lostLead did not convert

Lead Object Reference

FieldTypeDescription
_idstringUnique lead identifier (MongoDB ObjectID)
namestringLead's full name
emailstringEmail address
phonestringPhone number
companystringCompany or organization name
jobtitlestringJob title
industrystringIndustry or sector
websitestringWebsite URL
requeststringDescription of the lead's interest or request
budgetnumberEstimated budget
countrystringCountry
statestringState or region
addressstringStreet address
sourcestringOrigin of the lead
statusstringCurrent status in the pipeline
sourceoriginstringCreation channel: api or dashboard
activebooleanWhether the lead is active
createdatstringISO 8601 creation timestamp
updatedatstringISO 8601 last update timestamp

Error Responses

Missing Required Field

json
{
  "success": false,
  "error": "Key: 'ApiLeadRequest.Name' Error:Field validation for 'Name' failed on the 'required' tag"
}

Internal Error

json
{
  "success": false,
  "error": "Error creating lead"
}

Use Cases

Capture Web Form Submissions

javascript
// Triggered when a visitor submits your contact form
async function handleContactForm(formData) {
  const response = await fetch(
    "https://api.cashfin.africa/business/lead/create",
    {
      method: "POST",
      headers: {
        Authorization: API_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        name: formData.fullName,
        email: formData.email,
        phone: formData.phone,
        company: formData.company,
        request: formData.message,
        source: "website",
      }),
    }
  );

  const result = await response.json();
  if (result.success) {
    console.log("Lead captured:", result.data._id);
  }
}

Import Leads in Bulk

javascript
async function importLeads(leads) {
  const results = await Promise.allSettled(
    leads.map((lead) =>
      fetch("https://api.cashfin.africa/business/lead/create", {
        method: "POST",
        headers: {
          Authorization: API_KEY,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(lead),
      }).then((r) => r.json())
    )
  );

  const succeeded = results.filter((r) => r.status === "fulfilled" && r.value.success).length;
  console.log(`Imported ${succeeded} of ${leads.length} leads`);
}

Cashfin Business API Documentation