SwiftCRM

Examples

What you'll achieve: Copy-paste examples that work. Replace YOUR_PROJECT_API_KEY and the base URL with your app URL.

curl

curl -X POST "https://www.swiftcrm.in/api/public/lead" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: YOUR_PROJECT_API_KEY" \
  -d '{"name":"Jane","email":"[email protected]"}'

JavaScript (fetch)

fetch("https://www.swiftcrm.in/api/public/lead", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": "YOUR_PROJECT_API_KEY"
  },
  body: JSON.stringify({
    name: "Jane",
    email: "[email protected]",
    source_url: window.location.href
  })
})
  .then(r => r.json())
  .then(data => console.log(data));

PHP

$ch = curl_init("https://www.swiftcrm.in/api/public/lead");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode([
    'name' => 'Jane',
    'email' => '[email protected]'
  ]),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json',
    'X-Api-Key: YOUR_PROJECT_API_KEY'
  ],
  CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// $code 201 = success; decode $response for lead_id

Expected success response

{
  "code": "LEAD_CREATED",
  "message": "Lead captured.",
  "request_id": "req_...",
  "lead_id": 123
}

Ensure your domain is in the project's Allowed domains. Otherwise you'll get DOMAIN_NOT_ALLOWED. Troubleshooting