v1.0 • Lead Management
Modify an existing lead's information
Update specific fields of an existing lead
PUT ${baseUrl}/api/v1/leads/{leadId}leadIdThe unique identifier of the lead to update (required)
Only include fields you want to change
You only need to include the fields you want to update. Existing fields will remain unchanged.
{
"status": "contacted",
"phone": "+1-555-123-9999"
}{
"metadata": {
"last_interaction": "2024-01-16T14:30:00.000Z",
"notes": "Interested in premium package",
"follow_up_date": "2024-01-20",
"lead_score": 85
}
}{
"name": "John Smith",
"phone": "+1-555-456-7890",
"status": "qualified",
"source": "webinar",
"metadata": {
"company": "New Tech Corp",
"job_title": "Senior Manager",
"budget": "$50k-100k",
"timeline": "Q2 2024",
"interests": ["enterprise_solution", "support_package"]
}
}Returns the updated lead with new timestamps
{
"success": true,
"data": {
"id": "lead_1234567890abcdef",
"name": "John Smith",
"email": "john.doe@example.com",
"phone": "+1-555-456-7890",
"source": "webinar",
"status": "qualified",
"metadata": {
"utm_source": "google",
"utm_campaign": "spring_2024",
"company": "New Tech Corp",
"job_title": "Senior Manager",
"budget": "$50k-100k",
"timeline": "Q2 2024",
"interests": ["enterprise_solution", "support_package"]
},
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-16T14:30:00.000Z",
"workspaceId": "ws_your_workspace_id"
}
}updatedAtTimestamp reflects the update time
metadataMerged with existing data
idAlways remains the same
createdAtNever changes after creation
workspaceIdCannot be modified
Implementation examples for updating leads
curl -X PUT "https://your-domain.com/api/v1/leads/lead_1234567890abcdef" \
-H "Authorization: Bearer sk-workspace_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"status": "contacted",
"metadata": {
"notes": "Follow up scheduled for next week",
"last_interaction": "2024-01-16T14:30:00.000Z"
}
}'const updateLead = async (leadId, updates) => {
try {
const response = await fetch(`https://your-domain.com/api/v1/leads/${leadId}`, {
method: 'PUT',
headers: {
'Authorization': 'Bearer sk-workspace_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify(updates)
});
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 updating lead:', error);
throw error;
}
};
// Usage examples
const leadId = "lead_1234567890abcdef";
// Simple status update
updateLead(leadId, {
status: "contacted"
});
// Add notes and metadata
updateLead(leadId, {
metadata: {
notes: "Very interested in our services",
lead_score: 90,
follow_up_date: "2024-01-25"
}
});
// Multiple field update
updateLead(leadId, {
phone: "+1-555-999-8888",
status: "qualified",
source: "referral",
metadata: {
referrer: "Jane Smith",
budget_range: "$10k-25k"
}
});import requests
from typing import Dict, Any
def update_lead(api_key: str, lead_id: str, updates: Dict[str, Any]) -> Dict[str, Any]:
"""
Update a lead with partial data.
Args:
api_key: Your API key
lead_id: The lead's unique identifier
updates: Dictionary of fields to update
Returns:
dict: The updated lead data
"""
url = f"https://your-domain.com/api/v1/leads/{lead_id}"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
try:
response = requests.put(url, headers=headers, json=updates)
if response.status_code == 404:
raise ValueError(f"Lead with ID '{lead_id}' not found")
response.raise_for_status()
result = response.json()
print(f"Updated lead: {result['data']['name']} - Status: {result['data']['status']}")
return result['data']
except requests.exceptions.RequestException as e:
print(f"Error updating lead: {e}")
raise
# Usage examples
api_key = "sk-workspace_your_api_key"
lead_id = "lead_1234567890abcdef"
# Simple status update
try:
updated_lead = update_lead(api_key, lead_id, {
"status": "contacted"
})
print(f"Status updated to: {updated_lead['status']}")
except Exception as e:
print(f"Update failed: {e}")
# Add metadata
update_lead(api_key, lead_id, {
"metadata": {
"notes": "Interested in enterprise solution",
"follow_up_date": "2024-01-25",
"priority": "high"
}
})
# Helper function for common updates
def update_lead_status(api_key: str, lead_id: str, status: str, notes: str = None):
"""Update lead status with optional notes."""
updates = {"status": status}
if notes:
updates["metadata"] = {"notes": notes}
return update_lead(api_key, lead_id, updates)
# Usage
update_lead_status(api_key, lead_id, "qualified", "Ready for sales team")Handle validation and update errors
{
"success": false,
"error": "Validation failed",
"code": "VALIDATION_ERROR",
"details": {
"field": "status",
"value": "invalid_status",
"message": "Status must be one of: new, contacted, qualified, converted, lost, follow_up"
}
}{
"success": false,
"error": "Email already exists",
"code": "DUPLICATE_EMAIL",
"details": {
"email": "existing@example.com",
"existingLeadId": "lead_another123",
"message": "A different lead with this email already exists in your workspace"
}
}