Integrating Create Lead API
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.
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
Trigger: An action occurs in your external application (e.g., a form submission).
Request: Your application sends a JSON payload to our API endpoint.
Authentication: The CRM validates your PAT Token .
Action: The lead is created, and a success response is returned with Lead object.
Logging: The lead activity is stored in the CRM dashboard.
To integrate, send a POST request to the following endpoint:
Endpoint: POST https://cs.fabbuilder.com/api/tenant/:tenantId/lead
{
"data": {
"customerId": "string",
"leadNumber": "string",
"status": "string",
"source": "string",
"firstName": "string",
"lastName": "string",
"phone": "string",
"email": "string",
"whatsapp": "string",
"description": "string",
}
}
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
Javascript Python Curl
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"
}
}'