> 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.

# Create a lead

POST https://api-dev.houseofapps.ai/v1/integrations/leads
Content-Type: application/json

`lead.name` is required. Without `pipeline_id` / `stage_id`, the lead goes to your default pipeline and its first stage.

* **New person in the same call:** send a top-level `contact` (with `email`). It is created and linked to the lead.
* **Where the lead came from:** send `lead.marketing_attribution` with UTM and ad fields (`utm_source`, `utm_campaign`, `landing_page_url`, …).
* **Notes:** `lead.notes` is a list of `{ "title", "content" }` items (title up to 500 characters, content up to 50,000).
* **Custom fields:** `lead.custom_fields` items are `{ "field_id", "value" }`. Get IDs from **Custom Fields**.

Returns `lead_id`, plus `contact_id` / `company_id` when those were created. The new lead runs your organization's automations like one created in the app.

Reference: https://docs.houseofapps.ai/api-reference/overview/crm/leads/external-create-lead-v-1-integrations-leads-post

## Request

### Headers

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

### Body (application/json)

This endpoint expects an ExternalCreateLeadRequest.

- `lead` (ExternalCreateLeadData, required) — Lead create payload (same as internal, plus optional marketing_attribution). Use `lead.contacts` to associate existing contacts by id. Use top-level `contact` to create a new contact (auto-linked).
- `contact` (CreateContactRequestStandalone, optional, nullable) — Optional contact create payload.
- `lead_contact_label` (string, optional, nullable) — Optional label for the created contact on the lead (lead_contacts.label).

## Response

### 201

Created

- `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

### ExternalCreateLeadData

Lead create payload for external auth; adds optional marketing attribution.

- `name` (string, required) — Lead display title
- `email` (string, optional, nullable)
- `phones` (list of Phone, optional)
- `pipeline_id` (string, optional, nullable) — Pipeline UUID. When omitted, the organization's default pipeline is used.
- `stage_id` (string, optional, nullable) — Stage UUID; must belong to the resolved pipeline. When omitted, the pipeline's first stage (lowest sort_order) is used.
- `lead_source` (string, optional, nullable) — Origin channel
- `referral_source` (string, optional, nullable) — Referrer name or id
- `referral_id` (string, optional, nullable) — Referral identifier (free text)
- `lead_score` (string, optional, nullable) — Score label or tier
- `close_date` (date, optional, nullable) — Expected close date (YYYY-MM-DD)
- `amount` (ExternalCreateLeadDataAmount, optional, nullable) — Estimated deal value
- `currency` (enum, optional, nullable) — ISO 4217 alpha-3 currency code for `amount`
  - 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) — Longer opportunity description
- `owner_id` (string, optional, nullable) — Owning user; defaults to creator when omitted (service layer)
- `company` (CreateLeadCompany, optional, nullable) — Optional company on create (``lead_companies``). All companies linked to each contact via ``contact_companies`` are associated as well.
- `contacts` (list of LeadContactCreate, optional, nullable) — Contacts on the lead; optional labels per association. Each contact's company memberships are linked to the lead automatically.
- `deal_type` (enum, optional, nullable) — New vs existing business; omit or null when unknown
  - Allowed values: `New Business`, `Existing Business`
- `priority` (enum, optional, nullable) — Priority tier
  - Allowed values: `low`, `medium`, `high`
- `tags` (list of string, optional) — Free-form tags for segmentation and KPI analytics.
- `notes` (list of LeadNoteItemInput, optional) — Structured notes
- `custom_fields` (list of map from string to any, optional) — Root FieldCell create: field_id plus exactly one of value | sub_fields | items. Do not send instance_id or type.
- `contact` (CreateContactRequestStandalone, optional, nullable) — Create a contact without allowing nested lead creation. This is used by endpoints that already own lead creation (e.g. external lead create), and want to optionally create a contact but forbid sending a `lead` block inside the contact payload.
- `lead_contact_label` (string, optional, nullable)
- `create_company` (CreateCompanyRequestStandalone, optional, nullable) — Optional inline company create linked on the lead only (``lead_companies``). Does not create a ``contact_companies`` row.
- `lead_company_label` (string, optional, nullable) — Optional label for the inline-created company on the lead (lead_companies.label).
- `addresses` (list of AddressInput, optional)
- `marketing_attribution` (MarketingAttribution, optional, nullable) — Optional marketing / ad attribution (UTM + campaign metadata).

### CreateContactRequestStandalone

Create a contact without allowing nested lead creation. This is used by endpoints that already own lead creation (e.g. external lead create), and want to optionally create a contact but forbid sending a `lead` block inside the contact payload.

- `email` (string, required) — Contact email address (required).
- `owner_id` (string, optional, nullable) — Owning user; defaults to the caller on internal create when omitted.
- `portal_access` (boolean, optional, default: false) — If true, provisions a portal user for this contact and sends an invite email.
- `prefix` (string, optional, nullable)
- `first_name` (string, optional, nullable)
- `middle_name` (string, optional, nullable)
- `last_name` (string, optional, nullable)
- `title` (string, optional, nullable)
- `date_of_birth` (date, optional, nullable)
- `profile_photo_url` (string, optional, nullable)
- `external_contact_id` (string, optional, nullable) — Optional identifier from an external system (immutable after create).
- `phones` (list of PhoneInput, optional)
- `tags` (list of string, optional)
- `social_pages` (list of SocialPage, optional)
- `websites` (list of Website, optional) — Websites for the contact (stored in additional_data.websites).
- `custom_fields` (list of map from string to any, optional) — Custom fields root cells payload (validated and stored as JSONB).
- `additional_data` (map from string to any, optional) — Free-form JSONB payload stored on the contact.
- `notes` (list of NoteItemInput, optional) — Structured notes
- `company_association` (ContactCompaniesCreate, optional, nullable) — Company association payload used during contact create. Mirrors the update naming, but allows only a single operation: - add an existing company membership (optional primary) - OR create exactly one new company and associate it (optional primary)
- `addresses` (list of AddressInput, optional)

### SuccessResponseData

Payload for this endpoint

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

### Phone

Phone number item: id, phone_number, phone_isd_code, label, is_primary.

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

### ExternalCreateLeadDataAmount

Estimated deal value

- double
- string

### CreateLeadCompany

Optional explicit company on ``POST /leads``.

- `company_id` (string, optional, nullable) — Company UUID
- `label` (string, optional, nullable) — Optional label for the company association on create

### 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)

### LeadNoteItemInput

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

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

### CreateCompanyRequestStandalone

Create a company without nested lead or contact association blocks. Used when another endpoint owns lead creation (e.g. lead create with inline company) and the company should be linked on the lead only (``lead_companies``), not via ``contact_companies``.

- `name` (string, required)
- `industry` (string, optional, nullable)
- `profile_photo_url` (string, optional, nullable)
- `portal_access` (boolean, optional, default: false)
- `email` (string, optional, nullable)
- `phones` (list of Phone, optional)
- `tags` (list of string, optional)
- `websites` (list of Website, optional)
- `billing_preferences` (BillingPreferences, optional, nullable) — Billing preferences (defaults to empty preferences).
- `social_pages` (list of SocialPage, optional)
- `target_market_segments` (list of string, optional)
- `current_tech_stack` (list of string, optional)
- `preferred_communication_channels` (list of string, optional)
- `industry_specific_terminologies` (list of string, optional)
- `description` (string, optional, nullable)
- `custom_fields` (list of map from string to any, optional)
- `additional_data` (map from string to any, optional)
- `notes` (list of NoteItemInput, optional) — Structured notes
- `addresses` (list of AddressInput, optional)

### 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

### 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

### 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

### SocialPage

Social media page schema: platform (e.g. linkedin, instagram, twitter) and URL.

- `platform` (string, required) — Platform name
- `url` (string, required) — Profile/page URL
- `id` (string, optional, nullable) — Social page ID

### Website

Website schema.

- `url` (string, required) — Website URL
- `type` (string, required) — Website type
- `id` (string, optional, nullable) — Website ID
- `is_primary` (boolean, optional, default: false) — Primary website flag

### NoteItemInput

Client input for a structured note (title and content only).

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

### ContactCompaniesCreate

Company association payload used during contact create. Mirrors the update naming, but allows only a single operation: - add an existing company membership (optional primary) - OR create exactly one new company and associate it (optional primary)

- `add_association` (ContactCompanyAssociationAdd, optional, nullable) — Associate the contact with an existing company (single).
- `create_and_associate` (ContactCompanyAssociationCreateInline, optional, nullable) — Create exactly one new company and associate it to the contact (single).

### BillingPreferences

Billing preferences schema.

- `method` (string, optional, nullable) — Billing method
- `terms` (string, optional, nullable) — Payment terms

### ContactCompanyAssociationAdd

Add an existing company membership for a contact.

- `company_id` (string, required) — Existing company id to link
- `is_primary` (boolean, optional, default: false) — If true, set this contact as the company's primary contact.

### ContactCompanyAssociationCreateInline

Create a new company inline and link it during contact create.

- `company` (CreateCompanyRequest, required) — New company payload (same shape as POST /companies).
- `is_primary` (boolean, optional, default: false) — If true, set this contact as the company's primary contact.

### CreateCompanyRequest

Create a company. Supports ADR operations: - company only - company + link existing contact (primary/non-primary) - company + create new contact + link (primary/non-primary)

- `name` (string, required)
- `owner_id` (string, optional, nullable) — Owning user; defaults to the caller on internal create when omitted.
- `industry` (string, optional, nullable)
- `profile_photo_url` (string, optional, nullable)
- `portal_access` (boolean, optional, default: false)
- `email` (string, optional, nullable)
- `phones` (list of Phone, optional)
- `tags` (list of string, optional)
- `websites` (list of Website, optional)
- `billing_preferences` (BillingPreferences, optional, nullable) — Billing preferences (defaults to empty preferences).
- `social_pages` (list of SocialPage, optional)
- `target_market_segments` (list of string, optional)
- `current_tech_stack` (list of string, optional)
- `preferred_communication_channels` (list of string, optional)
- `industry_specific_terminologies` (list of string, optional)
- `description` (string, optional, nullable)
- `custom_fields` (list of map from string to any, optional)
- `additional_data` (map from string to any, optional)
- `notes` (list of NoteItemInput, optional) — Structured notes
- `lead` (CompanyLeadAssociation, optional, nullable) — Optional lead creation. When provided, creates a lead and associates it with this company (and the linked contact if provided).
- `contact_association` (CompanyContactsCreate, optional, nullable) — Optional contact association (add existing OR create+associate).
- `addresses` (list of AddressInput, optional)

### CompanyLeadAssociation

Optional lead creation/linking on company create. Creates a new lead (v2 `public.leads`) and associates it with the created company, and also with the linked/created contact when present on the same request.

- `stage_id` (string, required) — Lead pipeline stage id (UUID).
- `intake_stage` (string, optional, nullable) — Optional intake stage label.
- `lead_score` (string, optional, nullable) — Optional lead score label/tier.

### CompanyContactsCreate

Contact association payload used during company create. Mirrors the update naming, but allows only a single operation: - add an existing contact membership (optional primary) - OR create exactly one new contact and associate it (optional primary)

- `add_association` (CompanyContactAssociationAdd, optional, nullable) — Associate an existing contact to this company (single).
- `create_and_associate` (CompanyContactAssociationCreate, optional, nullable) — Create exactly one new contact and associate it to the company (single).

### CompanyContactAssociationAdd

Add an existing contact membership for a company.

- `contact_id` (string, required) — Existing contact id to link
- `is_primary` (boolean, optional, default: false) — If true, set this contact as the company's primary contact.

### CompanyContactAssociationCreate

Create exactly one new contact and link it to the company.

- `contact` (CreateContactRequest, required) — New contact payload (same shape as POST /contacts).
- `is_primary` (boolean, optional, default: false) — If true, set the new contact as the company's primary contact.

### CreateContactRequest

Create a contact. Supports the operations from ADR: - contact only - contact + link to existing company (optionally primary) - contact + create new company + link (optionally primary)

- `email` (string, required) — Contact email address (required).
- `owner_id` (string, optional, nullable) — Owning user; defaults to the caller on internal create when omitted.
- `portal_access` (boolean, optional, default: false) — If true, provisions a portal user for this contact and sends an invite email.
- `prefix` (string, optional, nullable)
- `first_name` (string, optional, nullable)
- `middle_name` (string, optional, nullable)
- `last_name` (string, optional, nullable)
- `title` (string, optional, nullable)
- `date_of_birth` (date, optional, nullable)
- `profile_photo_url` (string, optional, nullable)
- `external_contact_id` (string, optional, nullable) — Optional identifier from an external system (immutable after create).
- `phones` (list of PhoneInput, optional)
- `tags` (list of string, optional)
- `social_pages` (list of SocialPage, optional)
- `websites` (list of Website, optional) — Websites for the contact (stored in additional_data.websites).
- `custom_fields` (list of map from string to any, optional) — Custom fields root cells payload (validated and stored as JSONB).
- `additional_data` (map from string to any, optional) — Free-form JSONB payload stored on the contact.
- `notes` (list of NoteItemInput, optional) — Structured notes
- `lead` (ContactLeadAssociation, optional, nullable) — Optional lead creation. When provided, creates a lead and associates it with this contact (and the linked company if provided).
- `company_association` (ContactCompaniesCreate, optional, nullable) — Optional company association (add existing OR create+associate).
- `addresses` (list of AddressInput, optional)

### ContactLeadAssociation

Optional lead creation/linking on contact create. This creates a new lead (v2 `public.leads`) and associates it with the created contact, and also with the linked/created company when present on the same request.

- `stage_id` (string, required) — Lead pipeline stage id (UUID).
- `name` (string, optional, nullable) — Optional lead display title. When omitted or blank, the lead name is derived from the contact first/last name (or email).
- `intake_stage` (string, optional, nullable) — Optional intake stage label.
- `lead_score` (string, optional, nullable) — Optional lead score label/tier.

## Examples

**Request**

```json
{
  "lead": {
    "name": "string"
  }
}
```

**Response**

```json
{
  "status": "success",
  "message": "Lead created successfully",
  "statusCode": 201,
  "code": "2001",
  "data": {
    "contact_id": "c1a2b3c4-1111-2222-3333-444455556666",
    "lead_id": "8f3c2a10-4b6e-4d11-9c2a-1e5b7a9d0c44"
  }
}
```

**SDK Code**

```python Created
import requests

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

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

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

print(response.json())
```

```javascript Created
const url = 'https://api-dev.houseofapps.ai/v1/integrations/leads';
const options = {
  method: 'POST',
  headers: {
    appSecret: 'appSecret',
    licenseKey: 'licenseKey',
    'Content-Type': 'application/json'
  },
  body: '{"lead":{"name":"string"}}'
};

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

```go Created
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"lead\": {\n    \"name\": \"string\"\n  }\n}")

	req, _ := http.NewRequest("POST", 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 Created
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["appSecret"] = 'appSecret'
request["licenseKey"] = 'licenseKey'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"lead\": {\n    \"name\": \"string\"\n  }\n}"

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

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

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Created
using RestSharp;

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

```swift Created
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-dev.houseofapps.ai/v1/integrations/leads")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```