Dashboard

Get Lead

Retrieve a specific lead by ID

GET
3 min read

Endpoint Details

Retrieve complete information for a specific lead

HTTP Method & URL

GET ${baseUrl}/api/v1/leads/{leadId}

Path Parameters

leadId

The unique identifier of the lead (required)

string

Response

Returns the complete lead object with all metadata

Success Response (200 OK)

{
  "success": true,
  "data": {
    "id": "lead_1234567890abcdef",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "phone": "+1-555-123-4567",
    "source": "website",
    "status": "contacted",
    "metadata": {
      "utm_source": "google",
      "utm_campaign": "spring_2024",
      "interests": ["product_a", "product_b"],
      "company": "Tech Corp",
      "job_title": "Marketing Manager",
      "last_interaction": "2024-01-16T14:30:00.000Z",
      "notes": "Interested in premium package",
      "follow_up_date": "2024-01-20"
    },
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-16T14:30:00.000Z",
    "workspaceId": "ws_your_workspace_id"
  }
}

💡 Complete Data

The GET endpoint returns the complete lead object including all metadata fields, unlike the list endpoint which may only return essential fields for performance.

Code Examples

Simple implementations for retrieving a specific lead

cURL

curl -X GET "https://your-domain.com/api/v1/leads/lead_1234567890abcdef" \
  -H "Authorization: Bearer sk-workspace_your_api_key"

JavaScript (fetch)

const getLead = async (leadId) => {
  try {
    const response = await fetch(`https://your-domain.com/api/v1/leads/${leadId}`, {
      method: 'GET',
      headers: {
        'Authorization': 'Bearer sk-workspace_your_api_key',
        'Content-Type': 'application/json'
      }
    });

    if (!response.ok) {
      if (response.status === 404) {
        throw new Error('Lead not found');
      }
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    const result = await response.json();
    return result.data;
  } catch (error) {
    console.error('Error getting lead:', error);
    throw error;
  }
};

// Usage
const leadId = "lead_1234567890abcdef";
getLead(leadId);

Python (requests)

import requests

def get_lead(api_key: str, lead_id: str) -> dict:
    """
    Retrieve a specific lead by ID.
    
    Args:
        api_key: Your API key
        lead_id: The lead's unique identifier
        
    Returns:
        dict: The lead data
        
    Raises:
        requests.exceptions.HTTPError: If lead not found or other HTTP error
    """
    url = f"https://your-domain.com/api/v1/leads/{lead_id}"
    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }
    
    try:
        response = requests.get(url, headers=headers)
        
        if response.status_code == 404:
            raise ValueError(f"Lead with ID '{lead_id}' not found")
            
        response.raise_for_status()
        
        result = response.json()
        print(f"Retrieved lead: {result['data']['name']} ({result['data']['email']})")
        
        return result['data']
    except requests.exceptions.RequestException as e:
        print(f"Error getting lead: {e}")
        raise

# Usage
api_key = "sk-workspace_your_api_key"
lead_id = "lead_1234567890abcdef"

try:
    lead = get_lead(api_key, lead_id)
    print(f"Lead status: {lead['status']}")
    print(f"Company: {lead['metadata'].get('company', 'N/A')}")
except ValueError as e:
    print(f"Lead not found: {e}")
except Exception as e:
    print(f"Error: {e}")

Error Scenarios

Handle these common error cases

404 Not Found

{
  "success": false,
  "error": "Lead not found",
  "code": "LEAD_NOT_FOUND",
  "details": {
    "leadId": "lead_nonexistent123",
    "message": "No lead found with this ID in your workspace"
  }
}
Common causes: Lead ID doesn't exist, lead was deleted, lead belongs to different workspace, or typo in the lead ID.

400 Bad Request - Invalid ID Format

{
  "success": false,
  "error": "Invalid lead ID format",
  "code": "INVALID_ID_FORMAT",
  "details": {
    "leadId": "invalid-id",
    "expected": "lead_[alphanumeric string]",
    "message": "Lead IDs must start with 'lead_' followed by alphanumeric characters"
  }
}

✓ Best Practices

Validate lead ID format before API call
Handle 404 errors gracefully
Cache lead data when possible

💡 Usage Tips

Use after list operations to get full details
Perfect for lead detail pages
Contains complete metadata object
    PollyBot.ai - Smart Conversations, Seamless Automation