FAB Customer Experience

GuideDocs
k
Integeration
On Website
In Flutter App
In Android App
In React-Native
Lead Form

Build by FAB Builder. The source code is available on GitHub.

ContactSponsor

Translate

Choose language

Select your preferred language for this documentation.

Integrating Create Lead API

Overview

The Create Lead API allows you to programmatically push new lead data into your CRM. This integration ensures that all leads captured from your external sources (websites, mobile apps, or third-party tools) are centralized and tracked.

Prerequisites

Before implementing the API, ensure you have:

  • An active account on cs.fabbuilder.com

  • A workspace with admin access.

  • Your Workspace ID (get if from Settings > Workspace Settings > General > In header Here ->)

  • Your unique PAT Token (generated from Settings > Workspace Settings > Service Accounts > View > Generate PAT Here ->)

  • A base understanding of HTTP POST requests

How It Works (Data Flow)

  1. Trigger: An action occurs in your external application (e.g., a form submission).

  2. Request: Your application sends a JSON payload to our API endpoint.

  3. Authentication: The CRM validates your PAT Token.

  4. Action: The lead is created, and a success response is returned with Lead object.

  5. Logging: The lead activity is stored in the CRM dashboard.

Implementation Guide

To integrate, send a POST request to the following endpoint:

Endpoint: POST https://cs.fabbuilder.com/api/tenant/:tenantId/lead

Headers

  • Authorization: Bearer PAT_TOKEN

  • Content-Type: application/json

Request Payload

{
  "data": {
    "customerId": "string",
    "leadNumber": "string",
    "status": "string",
    "source": "string",
    "firstName": "string",
    "lastName": "string",
    "phone": "string",
    "email": "string",
    "whatsapp": "string",
    "description": "string",
  }
}

Response Status

  • 200 Success: Success! Lead entry created.

  • 401 Unauthorized: Invalid or missing PAT Token.

  • 400 Bad Request: Missing mandatory fields or invalid JSON format.

  • 403 Forbidden: Not enough permission for provided PAT Token

Example Code

const axios = require('axios');

const createLead = async () => {
  try {
    const workspaceId = 'your_workspace_id'; // Replace with your actual workspace ID
    const token = 'your_pat_token'; // Replace with your actual PAT token
    const response = await axios.post(`https://cs.fabbuilder.com/api/tenant/${workspaceId}/lead`, {
      data: {
        firstName: 'John',
        lastName: 'Doe',
        email: 'john@example.com',
        phone: '+919876543210'
      }
    }, {
      headers: { 'Authorization': `Bearer ${token}` }
    });
    console.log('Lead Created:', response.data);
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
  }
};

createLead();
import requests

workspace_id = 'your_workspace_id'
token = 'your_pat_token'
url = f"https://cs.fabbuilder.com/api/tenant/{workspace_id}/lead"

headers = {
    "Authorization": f"Bearer {token}",
    "Content-Type": "application/json"
}

payload = {
    "data": {
        "firstName": "John",
        "lastName": "Doe",
        "email": "john@example.com",
        "phone": "+919876543210"
    }
}

response = requests.post(url, json=payload, headers=headers)

if response.status_code == 201:
    print("Lead Created:", response.json())
else:
    print(f"Error ({response.status_code}): {response.text}")
  
curl -X POST https://cs.fabbuilder.com/api/tenant/your_workspace_id/lead \
  -H "Authorization: Bearer your_pat_token" \
  -H "Content-Type: application/json" \
  -d '{
        "data": {
          "firstName": "John",
          "lastName": "Doe",
          "email": "john@example.com",
          "phone": "+919876543210"
        }
      }'