niiko/developers

Miira · leads & WhatsApp v1 current

miira.lead_create

Creates a new lead in the workspace CRM from its contact details. If a matching one already exists it is not duplicated: the reply is `ambiguous` with the candidates.

Last updated

POST /api/v1/actions/miira.lead_create
Key scope
miira.lead_create@1
Workspace permission
api.miira.lead_create off by default
Two permissions, not one

Both are needed: a key with that scope, and the workspace owner having switched the permission on. Holding the key is not enough — they are two decisions made by different people.

Request

fieldtyperules
submissionIdstring (uuid)required
source"web_form" | "referral" | "api" | "import" | "event" | "other"required
namestringoptionalmax 256
emailstring (email)optionalmax 320
phonestringoptionalmax 40
fieldsmap<string, unknown>optional
consentobjectoptional

consent

fieldtyperules
emailbooleanoptional
whatsappbooleanoptional
source"api" | "web_form" | "verbal" | "llamada" | "visita" | "imported"required

Response — output when status is done

fieldtyperules
outcome"created" | "existing" | "ambiguous" | "rejected"required
clientIdstring | nullrequired
reason"honeypot" | "invalid_email" | "disposable_email" | "invalid_identity" | nullrequired

Example

# One request, one idempotency key: retrying with the same key never runs twice.
curl -X POST https://niiko.org/api/v1/actions/miira.lead_create \
  -H "Authorization: Bearer nk_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "submissionId": "01890a5d-ac96-774b-bcce-b302099a8057",
    "source": "web_form"
  }'
# 200 → done · 202 → pending_approval (a person signs later) · 4xx → refused, with a named reason

Why it may refuse

Each reason names who can fix it and how. With reason stale, detail.message says what to do.

honeypotinvalid_emaildisposable_emailinvalid_identityleads_exceeded

In the clients

@vorluno/niiko-sdkniiko.createLead()
niiko (Python)niiko.create_lead()
niiko-cliniiko run miira.lead_create
n8n-nodes-niikomiiraLeadCreate
niiko-mcp-servermiira_lead_create

History