> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.houseofapps.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.houseofapps.ai/_mcp/server.

# Update a lead

PATCH https://api-dev.houseofapps.ai/v1/integrations/leads/{lead_id}
Content-Type: application/json

Updates only the fields you send.

- **Notes:** sending `notes` replaces the whole list. To add one note, read the lead, append to `notes`, and send the full list (only `title` and `content` per item).
- **Clearing:** send `marketing_attribution: null` to remove attribution.
- **Contacts and companies:** use `contacts_update` / `companies_update` to add or remove links without resending the rest.

Reference: https://docs.houseofapps.ai/api-reference/overview/crm/leads/external-update-lead-v-1-integrations-leads-lead-id-patch

## Request

### Path parameters

- `lead_id` (string, required) — Lead ID

### Headers

- `licenseKey` (string, required)
- `appSecret` (string, required)

### Body (application/json)

This endpoint expects an ExternalUpdateLeadRequest.

- `name` (string, optional, nullable) — Lead title; null clears
- `email` (string, optional, nullable) — Lead email; omitted leaves unchanged (null does not clear)
- `phones` (PhonesUpdate, optional, nullable) — Delta phone updates (add/update/remove), same as contacts. Omit or null leaves phones unchanged.
- `pipeline_id` (string, optional) — Move the lead to this pipeline. Without stage_id the lead moves to the pipeline's first stage. Omitted keeps the current pipeline.
- `stage_id` (string, optional, nullable) — Stage UUID within the lead's (or the given) pipeline; null clears
- `lead_source` (string, optional, nullable) — Origin channel; null clears
- `referral_source` (string, optional, nullable) — Referrer; null clears
- `referral_id` (string, optional, nullable) — Referral identifier; null clears
- `lead_score` (string, optional, nullable) — Score label; null clears
- `close_date` (date, optional, nullable) — Expected close date; null clears
- `amount` (ExternalUpdateLeadRequestAmount, optional, nullable) — Deal value; null clears
- `currency` (enum, optional, nullable) — ISO 4217 alpha-3 currency code for amount; null clears
  - Allowed values: `AED`, `AFN`, `ALL`, `AMD`, `ANG`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BGN`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHF`, `CLP`, `CNY`, `COP`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `UYU`, `UZS`, `VES`, `VND`, `VUV`, `WST`, `XAF`, `XCD`, `XOF`, `XPF`, `YER`, `ZAR`, `ZMW`, `ZWL`
- `description` (string, optional, nullable) — Description; null clears
- `owner_id` (string, optional, nullable) — Owner user UUID; null unassigns
- `deal_type` (enum, optional, nullable) — Deal type; null clears
  - Allowed values: `New Business`, `Existing Business`
- `priority` (enum, optional, nullable) — Priority; null clears
  - Allowed values: `low`, `medium`, `high`
- `tags` (list of string, optional) — Replace lead tags when set (empty list clears).
- `notes` (list of LeadNoteItemInput, optional, nullable) — Replace entire notes array when set
- `contacts_update` (LeadContactsUpdate, optional, nullable) — Delta operations for lead_contacts (add/remove/update labels). Omit to leave contacts unchanged. Companies linked to newly added contacts are associated automatically; unlinking contacts does not remove lead companies.
- `companies_update` (LeadCompaniesUpdate, optional, nullable) — Delta operations for lead_companies (add/remove/update labels). Omit to leave companies unchanged.
- `addresses` (AddressesUpdate, optional, nullable) — Batch address operations: add, update, and/or remove.
- `custom_fields` (list of map from string to any, optional) — FieldCell PATCH: root entries use field_id plus value | sub_fields | items (instance_id required for existing roots; list ``items`` is authoritative). Nested cells may use instance_id only (optional field_id must match). Do not send type.
- `marketing_attribution` (MarketingAttribution, optional, nullable) — Marketing / ad attribution; omit to leave unchanged, null to clear.

## Response

### 200

OK

- `status` (string, required) — Response status
- `message` (string, required) — Human-readable success message
- `statusCode` (integer, required) — HTTP status code
- `code` (string, required) — Custom application status code
- `data` (SuccessResponseData, optional, nullable) — Payload for this endpoint

## Errors

### 422 Unprocessable Entity Error

Unprocessable Entity

- `status` (string, required) — Response status
- `message` (string, required) — Human-readable error message
- `statusCode` (integer, required) — HTTP status code
- `code` (string, required) — Custom application status code
- `messageKey` (string, optional) — i18n key for the message
- `errors` (list of map from string to any, optional) — Optional field-level validation errors

## Types

### PhonesUpdate

Batch phone operations: add, update, and/or remove (primary contact).

- `add` (list of PhoneInput, optional, nullable)
- `update` (list of PhoneUpdateItem, optional, nullable)
- `remove` (list of string, optional, nullable)

### ExternalUpdateLeadRequestAmount

Deal value; null clears

- double
- string

### LeadNoteItemInput

Client input for one structured note in ``leads.notes`` (JSONB array).

- `title` (string, required)
- `content` (string, required)

### LeadContactsUpdate

Batch contact association changes for a lead (delta updates). Supports in one request: - remove association with N contacts - add association with N existing contacts (optionally setting label per contact) - update label for N existing contact relationships without unlinking

- `remove_associations` (list of string, optional) — Contact ids to unlink from the lead
- `add_associations` (list of LeadContactCreate, optional) — Associate the lead with existing contacts (by id)
- `update_associations` (list of LeadContactAssociationUpdate, optional) — Update label per contact without unlinking

### LeadCompaniesUpdate

Batch company association changes for a lead (delta updates). Supports in one request: - remove association with N companies - add association with N existing companies (optionally setting label per company) - update label for N existing company relationships without unlinking

- `remove_associations` (list of string, optional) — Company ids to unlink from the lead
- `add_associations` (list of LeadCompanyCreate, optional) — Associate the lead with existing companies (by id)
- `update_associations` (list of LeadCompanyAssociationUpdate, optional) — Update label per company without unlinking

### AddressesUpdate

Batch address operations: add, update, and/or remove.

- `add` (list of AddressInput, optional, nullable) — New addresses to add
- `update` (list of AddressUpdateItem, optional, nullable) — Existing addresses to update (must include id)
- `remove` (list of string, optional, nullable) — Address record IDs to remove

### MarketingAttribution

Optional marketing / ad attribution payload (UTM + campaign / ad metadata). Writable via external integrations create/update; returned on lead GET for all APIs.

- `utm_source` (string, optional, nullable) — UTM source
- `utm_medium` (string, optional, nullable) — UTM medium
- `utm_campaign` (string, optional, nullable) — UTM campaign
- `utm_content` (string, optional, nullable) — UTM content
- `utm_term` (string, optional, nullable) — UTM term
- `campaign_id` (string, optional, nullable) — Ad campaign id
- `campaign_name` (string, optional, nullable) — Ad campaign name
- `ad_group_id` (string, optional, nullable) — Ad group id
- `ad_group_name` (string, optional, nullable) — Ad group name
- `ad_id` (string, optional, nullable) — Ad id
- `ad_name` (string, optional, nullable) — Ad name
- `landing_page_url` (string, optional, nullable) — Landing page URL that captured the lead

### SuccessResponseData

Payload for this endpoint

- map from string to any
- list of any
- string
- double
- boolean

### PhoneInput

Phone input for add operation (no id).

- `phone_number` (string, required) — Phone number
- `phone_isd_code` (string, required) — Phone ISD code
- `label` (string, optional, nullable) — Label (e.g. mobile, work)
- `is_primary` (boolean, optional, default: false) — Primary phone flag

### PhoneUpdateItem

Phone update item; only provided fields are updated.

- `id` (string, required) — Phone item ID to update
- `phone_number` (string, optional, nullable)
- `phone_isd_code` (string, optional, nullable)
- `label` (string, optional, nullable)
- `is_primary` (boolean, optional, nullable)

### LeadContactCreate

Contact linked to a lead (``lead_contacts``).

- `contact_id` (string, required) — Contact UUID
- `label` (string, optional, nullable) — Optional role or tag (e.g. decision_maker)

### LeadContactAssociationUpdate

Update per-contact attributes for a lead relationship (currently label only).

- `contact_id` (string, required) — Existing contact id to update relationship for
- `label` (string, optional, nullable) — Optional role or tag for this association (null clears label)

### LeadCompanyCreate

Company linked to a lead (``lead_companies``).

- `company_id` (string, required) — Company UUID
- `label` (string, optional, nullable) — Optional role or tag for this association

### LeadCompanyAssociationUpdate

Update per-company attributes for a lead relationship (currently label only).

- `company_id` (string, required) — Existing company id to update relationship for
- `label` (string, optional, nullable) — Optional role or tag for this association (null clears label)

### AddressInput

Address input for add operation.

- `place_id` (string, optional, nullable)
- `address_line1` (string, optional, nullable) — Primary address line
- `address_line2` (string, optional, nullable)
- `city` (string, optional, nullable)
- `state` (string, optional, nullable)
- `postal_code` (string, optional, nullable)
- `country` (string, optional, nullable)
- `latitude` (double, optional, nullable)
- `longitude` (double, optional, nullable)
- `address_type` (enum, optional, nullable) — Address type enumeration.
  - Allowed values: `work`, `home`, `billing`, `shipping`, `other`
- `address_data` (map from string to any, optional) — Extra address metadata (e.g. formatted line). Defaults to when omitted.
- `is_primary` (boolean, optional, default: false) — Primary address flag

### AddressUpdateItem

Address update item; only provided fields are updated.

- `id` (string, required) — Address record ID to update
- `place_id` (string, optional, nullable)
- `address_line1` (string, optional, nullable)
- `address_line2` (string, optional, nullable)
- `city` (string, optional, nullable)
- `state` (string, optional, nullable)
- `postal_code` (string, optional, nullable)
- `country` (string, optional, nullable)
- `latitude` (double, optional, nullable)
- `longitude` (double, optional, nullable)
- `address_type` (enum, optional, nullable) — Address type enumeration.
  - Allowed values: `work`, `home`, `billing`, `shipping`, `other`
- `address_data` (map from string to any, optional, nullable)
- `is_primary` (boolean, optional, nullable)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "status": "success",
  "message": "Lead updated successfully",
  "statusCode": 200,
  "code": "2000",
  "data": {
    "lead_id": "8f3c2a10-4b6e-4d11-9c2a-1e5b7a9d0c44",
    "name": "Acme renewal — Q1"
  }
}
```

**SDK Code**

```python OK
import requests

url = "https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id"

payload = {}
headers = {
    "appSecret": "appSecret",
    "licenseKey": "licenseKey",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript OK
const url = 'https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id';
const options = {
  method: 'PATCH',
  headers: {
    appSecret: 'appSecret',
    licenseKey: 'licenseKey',
    'Content-Type': 'application/json'
  },
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go OK
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("appSecret", "appSecret")
	req.Header.Add("licenseKey", "licenseKey")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby OK
require 'uri'
require 'net/http'

url = URI("https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["appSecret"] = 'appSecret'
request["licenseKey"] = 'licenseKey'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java OK
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id")
  .header("appSecret", "appSecret")
  .header("licenseKey", "licenseKey")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php OK
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'appSecret' => 'appSecret',
    'licenseKey' => 'licenseKey',
  ],
]);

echo $response->getBody();
```

```csharp OK
using RestSharp;

var client = new RestClient("https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("appSecret", "appSecret");
request.AddHeader("licenseKey", "licenseKey");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift OK
import Foundation

let headers = [
  "appSecret": "appSecret",
  "licenseKey": "licenseKey",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-dev.houseofapps.ai/v1/integrations/leads/lead_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```