> ## Documentation Index
> Fetch the complete documentation index at: https://docs.3i.life/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start

> Start delivering live leads and consultation appointments to 3i CRM in under 5 minutes.

Follow this step-by-step guide to configure your outbound webhook dispatcher, send your first payload, and handle the returned lead ID.

***

## 3-Step Setup Overview

<Steps>
  <Step title="Obtain Your Partner Source Token">
    Your 3i client or account manager provides your dedicated **`x-source-token`** (UUID).

    <Tip>
      **Where Agents Find This in 3i CRM:**\
      The agent opens **Data & Integrations → Lead Sources**, clicks on their vendor source, and copies the token displayed under **Gateway URL (per-vendor token)**.
    </Tip>
  </Step>

  <Step title="Configure Your Webhook Dispatcher">
    Configure your server or webhook engine with the following destination parameters:

    * **Endpoint URL:** `https://api.3i.life/functions/v1/inbound-lead-gateway`
    * **HTTP Method:** `POST`
    * **Headers:**
      * `Content-Type: application/json`
      * `x-source-token: <YOUR_ASSIGNED_TOKEN>`
      * `Idempotency-Key: <UNIQUE_UUID_PER_DELIVERY>`
  </Step>

  <Step title="Dispatch Your Payload & Store lead_id">
    Send your lead data. 3i processes the payload, creates or updates the record, and returns a JSON response containing our internal `lead_id`. Store this ID in your database to correlate future updates.

    <Tip>
      **Already have an existing JSON payload format?** You can send your existing field names without rewriting your dispatcher! 3i's ingestion engine automatically detects aliases (e.g. `cell` → `phone`, `coverage_requested` → `coverage_amount`) and preserves all custom parameters in `custom_fields` with zero data loss.
    </Tip>
  </Step>
</Steps>

<Card title="Using No-Code Tools? (Zapier, Make, n8n, GoHighLevel)" icon="puzzle-piece" href="/no-code-integrations">
  Prefer visual setup over custom code? Follow our step-by-step guides for connecting Webhooks by Zapier, Make.com HTTP modules, n8n, or GoHighLevel workflows.
</Card>

***

## Code Examples

Select your programming language or tool below for a complete, production-ready dispatch script:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.3i.life/functions/v1/inbound-lead-gateway" \
    -H "Content-Type: application/json" \
    -H "x-source-token: YOUR_ASSIGNED_TOKEN" \
    -H "Idempotency-Key: lead_delivery_99201" \
    -d '{
      "first_name": "Marcus",
      "last_name": "Vance",
      "phone": "5125550188",
      "email": "m.vance@example.com",
      "address": "1204 Pecan Grove Rd",
      "city": "Austin",
      "state": "TX",
      "zipcode": "78704",
      "age": 63,
      "date_of_birth": "1963-04-12",
      "gender": "Male",
      "coverage_type": "Final Expense",
      "coverage_amount": "25000",
      "monthly_budget": "$85/mo",
      "smoker": false,
      "health_conditions": "Controlled blood pressure; takes Lisinopril",
      "notes": "Verified Army veteran looking for burial coverage. Prefers morning contact."
    }'
  ```

  ```typescript Node.js (Axios) theme={null}
  import axios, { AxiosError } from 'axios';

  const GATEWAY_URL = 'https://api.3i.life/functions/v1/inbound-lead-gateway';
  const SOURCE_TOKEN = 'YOUR_ASSIGNED_TOKEN';

  interface LeadPayload {
    first_name: string;
    last_name: string;
    phone: string;
    email?: string;
    state?: string;
    coverage_type?: string;
    coverage_amount?: string;
    notes?: string;
    [key: string]: unknown;
  }

  async function deliverLead(lead: LeadPayload, deliveryId: string) {
    try {
      const response = await axios.post(GATEWAY_URL, lead, {
        headers: {
          'Content-Type': 'application/json',
          'x-source-token': SOURCE_TOKEN,
          'Idempotency-Key': deliveryId,
        },
        timeout: 10000,
      });

      // Successfully received by 3i CRM
      const { lead_id, status, message } = response.data;
      console.log(`Lead accepted [${status}]: 3i Lead ID = ${lead_id}`);

      // Store response.data.lead_id in your database
      return response.data;
    } catch (err) {
      const error = err as AxiosError<{ error?: string; error_code?: string }>;
      console.error('Delivery failed:', error.response?.data || error.message);
      throw error;
    }
  }
  ```

  ```python Python (Requests) theme={null}
  import requests
  import uuid

  GATEWAY_URL = "https://api.3i.life/functions/v1/inbound-lead-gateway"
  SOURCE_TOKEN = "YOUR_ASSIGNED_TOKEN"

  payload = {
      "first_name": "Marcus",
      "last_name": "Vance",
      "phone": "5125550188",
      "email": "m.vance@example.com",
      "state": "TX",
      "coverage_type": "Final Expense",
      "coverage_amount": "25000",
      "monthly_budget": "$85/mo",
      "smoker": False,
      "notes": "Verified Army veteran looking for burial coverage."
  }

  headers = {
      "Content-Type": "application/json",
      "x-source-token": SOURCE_TOKEN,
      "Idempotency-Key": f"delivery_{uuid.uuid4()}"
  }

  try:
      response = requests.post(GATEWAY_URL, json=payload, headers=headers, timeout=10)
      response.raise_for_status()
      data = response.json()
      print(f"Lead accepted! 3i Lead ID: {data.get('lead_id')}")
  except requests.exceptions.RequestException as e:
      print(f"Delivery failed: {e}")
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"net/http"
  	"time"
  )

  const gatewayURL = "https://api.3i.life/functions/v1/inbound-lead-gateway"
  const sourceToken = "YOUR_ASSIGNED_TOKEN"

  func main() {
  	payload := map[string]interface{}{
  		"first_name":      "Marcus",
  		"last_name":       "Vance",
  		"phone":           "5125550188",
  		"email":           "m.vance@example.com",
  		"state":           "TX",
  		"coverage_type":   "Final Expense",
  		"coverage_amount": "25000",
  	}

  	body, _ := json.Marshal(payload)
  	req, _ := http.NewRequest("POST", gatewayURL, bytes.NewBuffer(body))
  	req.Header.Set("Content-Type", "application/json")
  	req.Header.Set("x-source-token", sourceToken)
  	req.Header.Set("Idempotency-Key", fmt.Sprintf("lead_%d", time.Now().Unix()))

  	client := &http.Client{Timeout: 10 * time.Second}
  	resp, err := client.Do(req)
  	if err != nil {
  		panic(err)
  	}
  	defer resp.Body.Close()

  	fmt.Printf("HTTP Status: %s\n", resp.Status)
  }
  ```

  ```php PHP (cURL) theme={null}
  <?php

  $gatewayUrl = 'https://api.3i.life/functions/v1/inbound-lead-gateway';
  $sourceToken = 'YOUR_ASSIGNED_TOKEN';

  $payload = [
      'first_name' => 'Marcus',
      'last_name' => 'Vance',
      'phone' => '5125550188',
      'email' => 'm.vance@example.com',
      'state' => 'TX',
      'coverage_type' => 'Final Expense',
      'coverage_amount' => '25000',
      'notes' => 'Looking for burial coverage.'
  ];

  $ch = curl_init($gatewayUrl);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Content-Type: application/json',
      'x-source-token: ' . $sourceToken,
      'Idempotency-Key: lead_' . uniqid()
  ]);

  $response = curl_exec($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  echo "Response ({$httpCode}): {$response}\n";
  ?>
  ```
</CodeGroup>

***

## Response Verification

Every successful request returns HTTP 200 with the assigned `lead_id`:

```json theme={null}
{
  "success": true,
  "message": "Lead created successfully",
  "lead_id": "b3040da5-9bd1-4a4b-8fd3-40e94bb5083f",
  "agent_id": "5170d1fa-fa77-4c7b-b5d1-93c6838a6a12",
  "status": "New",
  "auto_sync_enabled": false
}
```

<Tip>
  **Best Practice:** Save `response.data.lead_id` in your local database or CRM tracking table. When reviewing conversions, checking delivery receipts, or querying status, this UUID links the record directly across both platforms.
</Tip>
