> ## Documentation Index
> Fetch the complete documentation index at: https://api.smartlead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Lead

> Update lead contact information and custom fields. Changes apply globally across all campaigns.

<Warning>
  Updating a lead modifies the lead record globally across all campaigns. The `email` field is required even if not being changed.
</Warning>

## Path Parameters

<ParamField path="campaign_id" type="number" required>
  The campaign ID (used for validation and audit logging)
</ParamField>

<ParamField path="lead_id" type="number" required>
  The lead ID to update
</ParamField>

## Query Parameters

<ParamField query="api_key" type="string" required>
  Your SmartLead API key
</ParamField>

## Request Body

<ParamField body="email" type="string" required>
  Lead's email address (required field, even if not being changed)
</ParamField>

<ParamField body="first_name" type="string">
  Lead's first name
</ParamField>

<ParamField body="last_name" type="string">
  Lead's last name
</ParamField>

<ParamField body="phone_number" type="string">
  Lead's phone number
</ParamField>

<ParamField body="company_name" type="string">
  Company name
</ParamField>

<ParamField body="website" type="string">
  Company website
</ParamField>

<ParamField body="location" type="string">
  Lead's location
</ParamField>

<ParamField body="linkedin_profile" type="string">
  LinkedIn profile URL
</ParamField>

<ParamField body="company_url" type="string">
  Company URL
</ParamField>

<ParamField body="custom_fields" type="object">
  Custom fields object (maximum 200 key-value pairs). Custom fields are merged with existing fields, not replaced.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://server.smartlead.ai/api/v1/campaigns/123/leads/456?api_key=YOUR_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "email": "john@example.com",
      "first_name": "John",
      "last_name": "Doe",
      "company_name": "Acme Corp",
      "custom_fields": {
        "job_title": "CTO",
        "department": "Engineering"
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  API_KEY = "YOUR_API_KEY"
  campaign_id = 123
  lead_id = 456

  payload = {
      "email": "john@example.com",
      "first_name": "John",
      "last_name": "Doe",
      "company_name": "Acme Corp",
      "custom_fields": {
          "job_title": "CTO",
          "department": "Engineering"
      }
  }

  response = requests.post(
      f"https://server.smartlead.ai/api/v1/campaigns/{campaign_id}/leads/{lead_id}",
      params={"api_key": API_KEY},
      json=payload
  )

  result = response.json()
  if result.get('ok'):
      print("Lead updated successfully")
  ```

  ```javascript JavaScript theme={null}
  const API_KEY = 'YOUR_API_KEY';
  const campaignId = 123;
  const leadId = 456;

  const payload = {
    email: 'john@example.com',
    first_name: 'John',
    last_name: 'Doe',
    company_name: 'Acme Corp',
    custom_fields: {
      job_title: 'CTO',
      department: 'Engineering'
    }
  };

  const response = await fetch(
    `https://server.smartlead.ai/api/v1/campaigns/${campaignId}/leads/${leadId}?api_key=${API_KEY}`,
    {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(payload)
    }
  );

  const result = await response.json();
  if (result.ok) {
    console.log('Lead updated successfully');
  }
  ```
</RequestExample>

## Response Codes

<ResponseField name="200" type="Success">
  Lead updated successfully
</ResponseField>

<ResponseField name="401" type="Unauthorized">
  Invalid or missing API key
</ResponseField>

<ResponseField name="404" type="Not Found">
  Campaign or lead not found, or you don't have access
</ResponseField>

<ResponseField name="422" type="Validation Error">
  Missing required email field or invalid custom\_fields object size
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Server error occurred
</ResponseField>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "ok": true
  }
  ```

  ```json 401 - Unauthorized theme={null}
  {
    "message": "Invalid API Key"
  }
  ```

  ```json 404 - Not Found theme={null}
  {
    "ok": false,
    "error": "Invalid request!"
  }
  ```

  ```json 404 - Campaign Not Found theme={null}
  {
    "error": "Campaign not found - Invalid campaign_id."
  }
  ```

  ```json 422 - Validation Error theme={null}
  {
    "error": "email is required"
  }
  ```
</ResponseExample>

## Related Endpoints

* [Get Campaign Leads](/api-reference/leads/get-by-campaign)
* [Add Leads to Campaign](/api-reference/leads/add-to-campaign)
* [Delete Lead](/api-reference/leads/delete)
