---
title: "Create or update a lead by external channel identity"
method: POST
path: "/api/leads"
tags: ["Leads"]
---

# Create or update a lead by external channel identity

`POST /api/leads`

## Request

- Base URL: `https://api.setluca.com`
- URL: `https://api.setluca.com/api/leads`
- Auth: one of:
  - API key in cookie `luca.session_token`
  - API key in header `x-api-key`
  - HTTP bearer

Upserts on `channel` plus `externalUserId`. Send the same identity twice and you update that lead instead of creating a second one. Emits `lead.created`, and `lead.stage_changed` too if the request moves the lead's stage.

**API key scopes:** `leads:write`. You also need an `Idempotency-Key` header.

## Headers

- `Luca-API-Version` '1'

## Request body

- LeadCreate
  - `channel` 'telegram' | 'instagram' | 'messenger' | 'whatsapp', required
  - `externalUserId` string, required
  - `displayName` string
  - `stage` string
  - `customFields` object
  - `tags` string[]

## Response `200`

ok

- LeadUpdateResponse
  - `id` string, uuid, required
  - `lead` object, required
    - `id` string, uuid, required
    - `coachId` string, uuid, required
    - `channel` 'telegram' | 'instagram' | 'messenger' | 'whatsapp', required
    - `externalUserId` string, required
    - `displayName` string, nullable, required
    - `profilePhotoUrl` string, uri, nullable
    - `customFields` unknown, required
    - `tags` string[], required
    - `score` integer, required
    - `createdAt` string, required
    - `lastSeenAt` string, required

## Other responses

- `400`: bad request
- `401`: unauthorized
- `429`: rate limited
- `500`: internal error
- `503`: service unavailable

---

[API](https://skmtc.dev/setluca/apis/luca-api.md) · [All operations](https://skmtc.dev/setluca/apis/luca-api/llms.txt) · [OpenAPI document](https://skmtc.dev/setluca/apis/luca-api/revisions/90a200e4100b?raw)
