> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ondial.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create lead

> Pick a channel tab in Try it — only that channel’s fields appear.

Pick the **Call / Email / WhatsApp** tab in Try it. Extra fields for other channels are hidden.

First: [Lead setup](/api-reference/endpoint/outbound/lead-setup) with your `campaignId`.


## OpenAPI

````yaml /openapi.json post /api/v1/leads
openapi: 3.0.3
info:
  title: Ondial Public API
  version: 1.0.0
  description: >-
    Tenant API-key surface for lead ingest, contacts (including dial
    conversation + analysis), events, inbound agents, company profiles, and
    knowledge-base documents.


    **Campaign definition is UI-only** — create and start an API-ingest campaign
    in the dashboard, then push leads here.


    **Auth:** `Authorization: Bearer ond_live_…` or `ond_test_…` (or
    `X-API-Key`). Keys are requested in **API Access** with a friendly **key
    name**, then approved by Super Admin (not self-serve). Tenants can rename
    keys later without rotating the secret.


    **Scopes:** Company and knowledge-base routes require opt-in scopes
    (`companies:read`, `companies:write`, `knowledge:read`, `knowledge:write`)
    granted at key approval. Missing scope → `403 forbidden`.


    **Sandbox** keys never place PSTN dials or live WhatsApp/email and do not
    burn credits (KB upload skips debit).


    **Security:** Company responses never include SMTP/WhatsApp credentials. KB
    v1 is metadata-only — no file download.


    **Kill switch:** Super Admin can disable all `/api/v1/*` (`503` /
    `api_globally_disabled`) without stopping UI CSV campaigns.


    **Compliance:** Call channel requires `consent.outboundCall: true` and phone
    not on tenant/platform DNC.
servers:
  - url: https://dashboard.ondial.ai
    description: Production
  - url: http://localhost:3001
    description: Local
security:
  - BearerAuth: []
tags:
  - name: Core
    description: Auth check and lead ingest
  - name: Contacts
    description: Status, dials/conversation/analysis, cancel, delete, follow-ups, list
  - name: Events
    description: ERP event bus slice — eventType → campaign
  - name: Outbound
    description: >-
      Read-only campaign lookup for API / Custom CRM. Create and start campaigns
      in the dashboard.
  - name: Inbound agents
    description: Configure inbound agents; list/buy pool numbers; read credits
  - name: Companies
    description: >-
      Company profile CRUD (requires companies:read / companies:write scopes).
      Never returns SMTP or WhatsApp credentials.
  - name: Knowledge bases
    description: >-
      Knowledge document upload/list/delete (requires knowledge:read /
      knowledge:write scopes). Metadata only — no file download via API.
paths:
  /api/v1/leads:
    post:
      tags:
        - Core
      summary: Create lead
      description: >-
        Creates or upserts a contact on an **existing active** API campaign and
        arms **only the channel you pick**.


        In **Try it**, choose a tab (**Call**, **Email**, **WhatsApp**, …). Only
        that tab’s fields are shown.


        - **Call** — `phone` + `consent.outboundCall: true`

        - **Email** — `email` (no consent, not dialed)

        - **WhatsApp** — `phone` (no consent)

        - **WhatsApp + Email** — both, no dial

        - **Register only** — phone or email, no send


        Get ids from Lead setup. Campaign create stays dashboard-only.
      operationId: createLead
      parameters:
        - in: header
          name: Idempotency-Key
          schema:
            type: string
          description: >-
            Optional. Same key + same body returns the same contact; same key +
            different body → 409.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LeadRequest'
      responses:
        '201':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeadResponse'
              example:
                contactId: 6a7acd39a82e957a556ff6b3
                campaignId: 6a7acc769198505873b9c0b0
                channels:
                  - call
                status: sandbox_accepted
                mode: sandbox
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: Idempotency conflict or other conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '422':
          description: Guard failure — see reasonCode
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
              example:
                error: Consent required for outbound call
                reasonCode: consent_missing
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          $ref: '#/components/responses/ApiDisabled'
components:
  schemas:
    LeadRequest:
      oneOf:
        - title: Call
          allOf:
            - $ref: '#/components/schemas/LeadCall'
        - title: Email
          allOf:
            - $ref: '#/components/schemas/LeadEmail'
        - title: WhatsApp
          allOf:
            - $ref: '#/components/schemas/LeadWhatsapp'
        - title: WhatsApp + Email
          allOf:
            - $ref: '#/components/schemas/LeadWhatsappEmail'
        - title: Call + WhatsApp
          allOf:
            - $ref: '#/components/schemas/LeadCallWhatsapp'
        - title: Call + Email
          allOf:
            - $ref: '#/components/schemas/LeadCallEmail'
        - title: Register only
          allOf:
            - $ref: '#/components/schemas/LeadNone'
    LeadResponse:
      type: object
      properties:
        contactId:
          type: string
        campaignId:
          type: string
        channels:
          type: array
          items:
            type: string
        status:
          type: string
        mode:
          type: string
          enum:
            - live
            - sandbox
        reasonCode:
          type: string
        scheduledAt:
          type: string
          format: date-time
          nullable: true
        emailScheduledAt:
          type: string
          format: date-time
          nullable: true
        whatsappScheduledAt:
          type: string
          format: date-time
          nullable: true
        emailTemplateId:
          type: string
          nullable: true
        emailProfileId:
          type: string
          nullable: true
        whatsappTemplateId:
          type: string
          nullable: true
        whatsappProfileId:
          type: string
          nullable: true
        templateVariables:
          type: object
          nullable: true
          additionalProperties: true
        whatsappParams:
          type: array
          nullable: true
          items:
            type: string
    ErrorBody:
      type: object
      properties:
        error:
          type: string
        reasonCode:
          type: string
        missing:
          type: array
          items:
            type: string
    LeadCall:
      title: Call
      type: object
      required:
        - campaignId
        - phone
        - channel
        - consent
      properties:
        campaignId:
          type: string
          example: 6a7afae1e1cf2999568febc4
        channel:
          type: string
          enum:
            - call
          default: call
          description: Dial only. Email and WhatsApp fields are not used.
        phone:
          type: string
          example: '+919876543210'
        name:
          type: string
          example: Asha
        consent:
          $ref: '#/components/schemas/Consent'
        priority:
          type: string
          enum:
            - high
            - normal
          default: normal
        scheduledAt:
          type: string
          format: date-time
          description: When to dial. Defaults to now.
        requeue:
          type: boolean
          description: Re-arm a finished contact.
        metadata:
          type: object
          additionalProperties: true
          example:
            leadId: CRM-99
      example:
        campaignId: 6a7afae1e1cf2999568febc4
        channel: call
        phone: '+919876543210'
        name: Asha
        consent:
          outboundCall: true
          source: crm
        metadata:
          leadId: CRM-99
    LeadEmail:
      title: Email
      type: object
      required:
        - campaignId
        - channel
        - email
      properties:
        campaignId:
          type: string
          example: 6a7afae1e1cf2999568febc4
        channel:
          type: string
          enum:
            - email
          default: email
          description: Email only. No dial. Consent is not required.
        email:
          type: string
          format: email
          example: asha@example.com
        name:
          type: string
          example: Asha
        emailProfileId:
          type: string
          description: From Lead setup. Omit to use campaign / Omni default.
        emailTemplateId:
          type: string
          description: From Lead setup. Omit to use campaign / Omni default.
        templateVariables:
          type: object
          additionalProperties:
            type: string
          description: Named `{{key}}` values from the email template.
          example:
            contact_name: Asha
            company_name: Acme
        emailScheduledAt:
          type: string
          format: date-time
          description: When to send. Defaults to now.
        requeue:
          type: boolean
          description: Re-arm a finished contact.
        metadata:
          type: object
          additionalProperties: true
          example:
            leadId: CRM-99
      example:
        campaignId: 6a7afae1e1cf2999568febc4
        channel: email
        email: asha@example.com
        name: Asha
        emailProfileId: YOUR_EMAIL_PROFILE_ID
        emailTemplateId: YOUR_EMAIL_TEMPLATE_ID
        templateVariables:
          contact_name: Asha
        metadata:
          leadId: CRM-99
    LeadWhatsapp:
      title: WhatsApp
      type: object
      required:
        - campaignId
        - channel
        - phone
      properties:
        campaignId:
          type: string
          example: 6a7afae1e1cf2999568febc4
        channel:
          type: string
          enum:
            - whatsapp
          default: whatsapp
          description: WhatsApp only. No dial. Consent is not required.
        phone:
          type: string
          example: '+919876543210'
        name:
          type: string
          example: Asha
        whatsappProfileId:
          type: string
          description: From Lead setup. Omit to use campaign / Omni default.
        whatsappTemplateId:
          type: string
          description: From Lead setup. Omit to use campaign / Omni default.
        whatsappParams:
          type: array
          items:
            type: string
          description: Positional `{{1}}`, `{{2}}`, … from the WhatsApp template.
          example:
            - Asha
            - CRM-99
        whatsappScheduledAt:
          type: string
          format: date-time
          description: When to send. Defaults to now.
        requeue:
          type: boolean
          description: Re-arm a finished contact.
        metadata:
          type: object
          additionalProperties: true
          example:
            leadId: CRM-99
      example:
        campaignId: 6a7afae1e1cf2999568febc4
        channel: whatsapp
        phone: '+919876543210'
        name: Asha
        whatsappProfileId: YOUR_WHATSAPP_PROFILE_ID
        whatsappTemplateId: YOUR_WHATSAPP_TEMPLATE_ID
        whatsappParams:
          - Asha
          - CRM-99
        metadata:
          leadId: CRM-99
    LeadWhatsappEmail:
      title: WhatsApp + Email
      type: object
      required:
        - campaignId
        - channels
        - phone
        - email
      properties:
        campaignId:
          type: string
          example: 6a7afae1e1cf2999568febc4
        channels:
          type: array
          items:
            type: string
            enum:
              - whatsapp
              - email
          default:
            - whatsapp
            - email
          description: Direct send both. No PSTN dial. Consent is not required.
        phone:
          type: string
          example: '+919876543210'
        email:
          type: string
          format: email
          example: asha@example.com
        name:
          type: string
          example: Asha
        emailProfileId:
          type: string
        emailTemplateId:
          type: string
        templateVariables:
          type: object
          additionalProperties:
            type: string
        emailScheduledAt:
          type: string
          format: date-time
        whatsappProfileId:
          type: string
        whatsappTemplateId:
          type: string
        whatsappParams:
          type: array
          items:
            type: string
        whatsappScheduledAt:
          type: string
          format: date-time
        requeue:
          type: boolean
        metadata:
          type: object
          additionalProperties: true
      example:
        campaignId: 6a7afae1e1cf2999568febc4
        channels:
          - whatsapp
          - email
        phone: '+919876543210'
        email: asha@example.com
        name: Asha
    LeadCallWhatsapp:
      title: Call + WhatsApp
      type: object
      required:
        - campaignId
        - channels
        - phone
        - consent
      properties:
        campaignId:
          type: string
          example: 6a7afae1e1cf2999568febc4
        channels:
          type: array
          items:
            type: string
            enum:
              - call
              - whatsapp
          default:
            - call
            - whatsapp
          description: Dial, then WhatsApp. Consent required because call is included.
        phone:
          type: string
          example: '+919876543210'
        name:
          type: string
          example: Asha
        consent:
          $ref: '#/components/schemas/Consent'
        priority:
          type: string
          enum:
            - high
            - normal
        scheduledAt:
          type: string
          format: date-time
          description: When to dial.
        whatsappProfileId:
          type: string
        whatsappTemplateId:
          type: string
        whatsappParams:
          type: array
          items:
            type: string
        requeue:
          type: boolean
        metadata:
          type: object
          additionalProperties: true
      example:
        campaignId: 6a7afae1e1cf2999568febc4
        channels:
          - call
          - whatsapp
        phone: '+919876543210'
        name: Asha
        consent:
          outboundCall: true
          source: crm
    LeadCallEmail:
      title: Call + Email
      type: object
      required:
        - campaignId
        - channels
        - phone
        - email
        - consent
      properties:
        campaignId:
          type: string
          example: 6a7afae1e1cf2999568febc4
        channels:
          type: array
          items:
            type: string
            enum:
              - call
              - email
          default:
            - call
            - email
          description: Dial + email. Consent required because call is included.
        phone:
          type: string
          example: '+919876543210'
        email:
          type: string
          format: email
          example: asha@example.com
        name:
          type: string
          example: Asha
        consent:
          $ref: '#/components/schemas/Consent'
        priority:
          type: string
          enum:
            - high
            - normal
        scheduledAt:
          type: string
          format: date-time
        emailProfileId:
          type: string
        emailTemplateId:
          type: string
        templateVariables:
          type: object
          additionalProperties:
            type: string
        requeue:
          type: boolean
        metadata:
          type: object
          additionalProperties: true
      example:
        campaignId: 6a7afae1e1cf2999568febc4
        channels:
          - call
          - email
        phone: '+919876543210'
        email: asha@example.com
        name: Asha
        consent:
          outboundCall: true
          source: crm
    LeadNone:
      title: Register only
      type: object
      required:
        - campaignId
        - channel
      properties:
        campaignId:
          type: string
          example: 6a7afae1e1cf2999568febc4
        channel:
          type: string
          enum:
            - none
          default: none
          description: >-
            Store the contact only. Then POST /contacts/{id}/followups. Provide
            phone or email.
        phone:
          type: string
          example: '+919876543210'
        email:
          type: string
          format: email
        name:
          type: string
        metadata:
          type: object
          additionalProperties: true
      example:
        campaignId: 6a7afae1e1cf2999568febc4
        channel: none
        phone: '+919876543210'
        name: Asha
    Consent:
      type: object
      required:
        - outboundCall
      properties:
        outboundCall:
          type: boolean
          default: true
          description: Must be true to place a dial. Not used for email or WhatsApp.
        source:
          type: string
          example: crm
  responses:
    Unauthorized:
      description: Missing, invalid, or inactive API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            error: Invalid or inactive API key
            reasonCode: unauthorized
    RateLimited:
      description: Per-key rate limit
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            error: Rate limit exceeded
            reasonCode: rate_limited
    ApiDisabled:
      description: Global kill switch or insufficient credits
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          examples:
            killSwitch:
              value:
                error: API temporarily disabled
                reasonCode: api_globally_disabled
            credits:
              value:
                error: Insufficient credits
                reasonCode: insufficient_credits
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: ond_live | ond_test
      description: >-
        Paste only your API key (`ond_live_…` or `ond_test_…`). Do not type the
        word Bearer — the playground adds it.

````