# Create Lead

> Create a new lead in your workspace

## Request Body

<ParamField body="visitor_id" type="string">
  Associated visitor ID (UUID)
</ParamField>

<ParamField body="code" type="string">
  Lead code or identifier
</ParamField>

<ParamField body="source" type="string">
  Source of the lead (e.g., "website", "referral", "campaign")
</ParamField>

<ParamField body="properties" type="object">
  Custom properties as key-value pairs
</ParamField>

<ParamField body="location" type="object">
  Location data (city, country, etc.)
</ParamField>

<ParamField body="identity_id" type="string">
  Associated identity ID (UUID)
</ParamField>

<ParamField body="session_id" type="string">
  Associated session ID (UUID)
</ParamField>

<ParamField body="company_id" type="string">
  Associated company ID (UUID)
</ParamField>

<RequestExample>

```bash cURL
curl -X POST "https://api.orwel.io/api/v1/leads" \
  -H "Authorization: Bearer orwel_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "visitor_id": "660e8400-e29b-41d4-a716-446655440001",
    "code": "lead_002",
    "source": "website",
    "properties": {
      "industry": "fintech",
      "company_size": "100-500"
    },
    "location": {
      "city": "New York",
      "country": "USA"
    }
  }'
```

```javascript JavaScript
const response = await fetch('https://api.orwel.io/api/v1/leads', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer orwel_sk_YOUR_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    visitor_id: '660e8400-e29b-41d4-a716-446655440001',
    code: 'lead_002',
    source: 'website',
    properties: {
      industry: 'fintech',
      company_size: '100-500'
    },
    location: {
      city: 'New York',
      country: 'USA'
    }
  })
});

const data = await response.json();
```

```python Python
import requests
import json

headers = {
    'Authorization': 'Bearer orwel_sk_YOUR_KEY',
    'Content-Type': 'application/json'
}

payload = {
    'visitor_id': '660e8400-e29b-41d4-a716-446655440001',
    'code': 'lead_002',
    'source': 'website',
    'properties': {
        'industry': 'fintech',
        'company_size': '100-500'
    },
    'location': {
        'city': 'New York',
        'country': 'USA'
    }
}

response = requests.post(
    'https://api.orwel.io/api/v1/leads',
    headers=headers,
    data=json.dumps(payload)
)

data = response.json()
```

</RequestExample>

<ResponseExample>

```json 201 Created
{
  "data": {
    "id": "bb0e8400-e29b-41d4-a716-446655440006",
    "visitor_id": "660e8400-e29b-41d4-a716-446655440001",
    "workspace_id": "770e8400-e29b-41d4-a716-446655440002",
    "code": "lead_002",
    "source": "website",
    "created_at": "2025-01-15T14:30:00Z",
    "updated_at": "2025-01-15T14:30:00Z",
    "properties": {
      "industry": "fintech",
      "company_size": "100-500"
    },
    "location": {
      "city": "New York",
      "country": "USA"
    },
    "identity_id": null,
    "session_id": null,
    "summary": null,
    "company_id": null
  }
}
```

</ResponseExample>
