> ## 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.

# Validate lead

> Dry-run POST /leads — campaign profile/template exist? required fields filled? Nothing is created.

Use **Lead setup** first to copy a body, fill it, then Try it here.

* `ok: true` → safe to `POST /api/v1/leads`
* `ok: false` → read `checks` (`severity: error` blocks create)
* Warnings (empty `templateVariables`) still send


## OpenAPI

````yaml /openapi.json post /api/v1/leads/validate
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/validate:
    post:
      tags:
        - Core
      summary: Validate lead (dry run)
      description: >-
        Same body as Create lead — pick the **Call / Email / WhatsApp** tab so
        only that channel’s fields show.


        Checks that this campaign’s profile and template exist and that required
        fields are filled. **Never creates a contact.** `200` = safe to POST
        `/api/v1/leads`. `422` = fix `checks` with `severity: error`.
      operationId: validateLead
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LeadRequest'
      responses:
        '200':
          description: All required checks passed (nothing created)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeadValidate'
              example:
                ok: true
                campaignId: 6a7afae1e1cf2999568febc4
                channels:
                  - email
        '400':
          description: Invalid JSON or campaignId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          description: Required field or profile/template missing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeadValidate'
              example:
                ok: false
                campaignId: 6a7afae1e1cf2999568febc4
                channels:
                  - email
                missing:
                  - email
                issues:
                  - field: email
                    error: Valid email is required for email channel
      security:
        - BearerAuth: []
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'
    LeadValidate:
      type: object
      properties:
        ok:
          type: boolean
        campaignId:
          type: string
        channels:
          type: array
          items:
            type: string
        missing:
          type: array
          items:
            type: string
        warnings:
          type: array
          items:
            type: string
        issues:
          type: array
          items:
            type: object
            additionalProperties: true
    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
    NotFound:
      description: Not found or not owned
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            error: Not found
            reasonCode: not_found
  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.

````