# Create customer lead

POST https://services.leadconnectorhq.com/affiliate-manager/{locationId}/affiliates/{affiliateId}/lead/create

Create or update a lead for an affiliate customer.

## Authentication

Send `Authorization: Bearer <token>` using any one of:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `affiliate-manager.write`
- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `affiliate-manager.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location Id |
| `affiliateId` | string | Yes | Affiliate Id |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-07-28"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/affiliate-manager/{locationId}/affiliates/{affiliateId}/lead/create": {
      "post": {
        "summary": "Create customer lead",
        "operationId": "createCustomerLead",
        "description": "Create or update a lead for an affiliate customer.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-07-28"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location Id",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          },
          {
            "name": "affiliateId",
            "required": true,
            "in": "path",
            "description": "Affiliate Id",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLead"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "affiliate-manager.write"
            ]
          },
          {
            "Location-Access": [
              "affiliate-manager.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "CreateLead": {
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string",
            "description": "First Name",
            "example": "John"
          },
          "lastName": {
            "type": "string",
            "description": "Last Name",
            "example": "Deo"
          },
          "email": {
            "type": "string",
            "description": "email",
            "example": "john@deo.com"
          },
          "phone": {
            "type": "string",
            "description": "phone",
            "example": "+91 88888 88888"
          },
          "campaignId": {
            "type": "string",
            "description": "Campaign Id",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "contactId": {
            "type": "string",
            "description": "CRM contact identifier",
            "example": "ve9EPM428h8vShlRW1KT"
          }
        },
        "required": [
          "email",
          "campaignId"
        ],
        "title": "CreateLead"
      },
      "CustomerResponseDTO": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Customer identifier",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "locationId": {
            "type": "string",
            "description": "Location identifier",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "affiliateId": {
            "type": "string",
            "description": "Affiliate identifier",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "campaignId": {
            "type": "string",
            "description": "Campaign identifier",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "contactId": {
            "type": "string",
            "description": "Contact identifier",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "firstName": {
            "type": "string",
            "description": "Customer first name",
            "example": "John"
          },
          "lastName": {
            "type": "string",
            "description": "Customer last name",
            "example": "Doe"
          },
          "email": {
            "type": "string",
            "description": "Customer email address",
            "example": "john.doe@example.com"
          },
          "phone": {
            "type": "string",
            "description": "Customer phone number",
            "example": "+15551234567"
          },
          "type": {
            "type": "string",
            "description": "Customer type",
            "enum": [
              "lead",
              "customer",
              "dropped"
            ],
            "example": "customer"
          },
          "subscriptionId": {
            "type": "string",
            "description": "Subscription identifier",
            "example": "sub_123"
          },
          "dueAt": {
            "type": "string",
            "description": "Customer due date",
            "example": "2026-01-01T00:00:00.000Z",
            "format": "date-time"
          },
          "deleted": {
            "type": "boolean",
            "description": "Whether the customer is deleted",
            "example": false
          },
          "isDisabled": {
            "type": "boolean",
            "description": "Whether the customer is disabled",
            "example": true
          },
          "createdAt": {
            "type": "string",
            "description": "Customer creation timestamp",
            "example": "2026-01-01T00:00:00.000Z",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Customer update timestamp",
            "example": "2026-01-01T00:00:00.000Z",
            "format": "date-time"
          }
        },
        "required": [
          "_id",
          "locationId",
          "affiliateId",
          "campaignId",
          "contactId",
          "deleted",
          "isDisabled"
        ],
        "title": "CustomerResponseDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>/lead/create' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-07-28' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "firstName": "John",
  "lastName": "Deo",
  "email": "john@deo.com",
  "phone": "+91 88888 88888",
  "campaignId": "ve9EPM428h8vShlRW1KT",
  "contactId": "ve9EPM428h8vShlRW1KT"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-07-28',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "firstName": "John",
      "lastName": "Deo",
      "email": "john@deo.com",
      "phone": "+91 88888 88888",
      "campaignId": "ve9EPM428h8vShlRW1KT",
      "contactId": "ve9EPM428h8vShlRW1KT"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>/lead/create', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/affiliate-manager/{locationId}/affiliates/{affiliateId}/lead/create"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-07-28"
}

payload = {
    "firstName": "John",
    "lastName": "Deo",
    "email": "john@deo.com",
    "phone": "+91 88888 88888",
    "campaignId": "ve9EPM428h8vShlRW1KT",
    "contactId": "ve9EPM428h8vShlRW1KT"
}

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

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>/lead/create',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-07-28',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "firstName": "John",
  "lastName": "Deo",
  "email": "john@deo.com",
  "phone": "+91 88888 88888",
  "campaignId": "ve9EPM428h8vShlRW1KT",
  "contactId": "ve9EPM428h8vShlRW1KT"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>/lead/create")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-07-28")
  .header("Content-Type", "application/json")
  .body("{\"firstName\":\"John\",\"lastName\":\"Deo\",\"email\":\"john@deo.com\",\"phone\":\"+91 88888 88888\",\"campaignId\":\"ve9EPM428h8vShlRW1KT\",\"contactId\":\"ve9EPM428h8vShlRW1KT\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>/lead/create"
  payload := strings.NewReader(`{
  "firstName": "John",
  "lastName": "Deo",
  "email": "john@deo.com",
  "phone": "+91 88888 88888",
  "campaignId": "ve9EPM428h8vShlRW1KT",
  "contactId": "ve9EPM428h8vShlRW1KT"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-07-28")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

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

url = URI("https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>/lead/create")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-07-28"
request["Content-Type"] = "application/json"
request.body = '{
  "firstName": "John",
  "lastName": "Deo",
  "email": "john@deo.com",
  "phone": "+91 88888 88888",
  "campaignId": "ve9EPM428h8vShlRW1KT",
  "contactId": "ve9EPM428h8vShlRW1KT"
}'

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-07-28"
}

$body = '{
  "firstName": "John",
  "lastName": "Deo",
  "email": "john@deo.com",
  "phone": "+91 88888 88888",
  "campaignId": "ve9EPM428h8vShlRW1KT",
  "contactId": "ve9EPM428h8vShlRW1KT"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>/lead/create' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
