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

# Upload Workflow Leads

> Upload leads to a workflow.

Changes state - verify before retry
Uploads leads into a workflow from a CSV or Excel file. Each row with a phone number becomes one enrolled lead. Ordinary data columns become dynamic variables available in the agent's prompt at each voice call step.

## Draft workflows are replaced, others are appended

What an upload does to the leads already in the workflow depends on the workflow's status:

| Workflow status | Effect of an upload | When the new leads start |
| - | - | - |
| `draft` | Replaces every lead in the workflow. Earlier lead IDs stop working. | When the workflow is activated. |
| `active` | Adds to the existing leads. | Immediately. |
| `paused` | Adds to the existing leads. | Only after `activate`. `resume` does not start them. |
| `completed` or `cancelled` | Adds to the existing leads. | Never: these workflows cannot be activated again. |

So on a draft workflow, upload the complete lead list in one file. To add more leads later, activate the workflow first.

## When to use this

* **Enrolling a cohort**: add a set of leads to a workflow that is already built.
* **Incremental enrollment**: keep feeding new leads into an active workflow as they arrive, unlike a batch call where the list is fixed at creation.
* **Re-enrollment after correction**: on an active workflow, remove a lead that was uploaded with bad data via [Delete Workflow Lead](https://dialnexa.com/docs/api-reference/v1/workflow-leads/delete.md), then upload the corrected record here. On a draft workflow, upload the corrected complete file instead.

For a one-shot list where every contact just gets a single call, [Create Batch Call](https://dialnexa.com/docs/api-reference/v1/batches/create.md) is the simpler tool.

## File format

Send a CSV, XLSX, or XLS file up to 10 MB in the multipart `file` field; a larger file returns `413`. The file name must end in `.csv`, `.xlsx` or `.xls`, and the part's `Content-Type` must be `text/csv`, `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` or `application/vnd.ms-excel`. A part sent as `application/octet-stream` is rejected with `400`.

```
phone_number,name,city,product
+919876543210,Priya Sharma,Mumbai,home_loan
+919123456789,Rahul Mehra,Delhi,car_loan
```

Write phone numbers in international format with the country code, for example `+919876543210`. A number without a country code is read as if its first digits were one: `9876543210` is read as `+98...` and fails destination validation. Numbers are stored exactly as written in the file.

| Column | Meaning |
| - | - |
| `phone_number` | Required. The header can also be `phone`, `mobile`, `mobile_number`, `cell`, `telephone` or `tel`; case, spaces, hyphens and underscores are ignored. In a CSV, a row with an empty phone number is skipped; in an Excel file it fails the upload. |
| `tags` | Optional, reserved. Row-specific labels, comma- or pipe-separated. Not a prompt variable. |
| `notes` | Optional, reserved. Plain text is stored as `{"text": "..."}`; a JSON object of at most 15 keys is stored as sent. A value that starts with `{` or `[` but is not valid JSON, or a JSON array, returns `400`. Not a prompt variable. |
| `agent_transfer_destinations` | Optional, reserved. Pipe-separated transfer destinations, checked for format: an invalid value fails the upload with `400`. Workflow leads do not store this column; transfers on workflow calls use the destinations configured on the agent. Not a prompt variable. |
| Any other column | A dynamic variable, stored as `{ "key": "<header>", "value": "<cell>" }` in the lead's `dynamic_variables`. A blank cell adds no entry; values are trimmed and inner whitespace is collapsed. |

## Tags

Add an optional multipart `tags` field, such as `priority,september`, to label every lead in the upload. It is combined with each row's own `tags` column. Tags are comma- or pipe-separated, lowercased, whitespace-normalized, and deduplicated, with at most 20 tags per lead and 40 characters per tag. A tag over 40 characters, or more than 20 tags in the `tags` field or in one row's `tags` column, fails the upload with `400` before any lead is created. When the field and a row's column together exceed 20 tags, the upload returns `400` at that row, after the rows before it have been created. Because an upload to a draft workflow replaces its leads, the draft then holds only the rows before that one; upload the corrected complete file.

## Response

A `201` response carries, inside `data`:

* `data`: the created lead IDs (`lead_...`) grouped by phone number, as written in the file.
* `count`: the number of leads created.
* `dnc_skipped_count`: rows left out because their number is on the workspace's DNC list. `0` when none was.
* `tags`: every tag applied in this upload.
* `errors`: present only when some rows failed, one message per row. Rows are numbered from `Row 1` in order of the rows that have a phone number; blank rows and rows without a number are skipped and not counted. The message is then `Leads uploaded with N row(s) failed.` instead of `Leads uploaded successfully`, and the status is still `201`. On an active workflow, a row whose lead was created but could not be started is also listed here; that lead is included in `count` and `data`. Check [List Workflow Leads](https://dialnexa.com/docs/api-reference/v1/workflow-leads/list.md) before uploading such a row again, so the contact is not enrolled twice.
* `unused_columns` and `allowed_columns`: present only when some data columns are not referenced by any node or agent prompt in the workflow. The columns are still stored on the leads. The reserved `notes` and `agent_transfer_destinations` columns can also be listed in `unused_columns`.

Check [List Workflow Leads](https://dialnexa.com/docs/api-reference/v1/workflow-leads/list.md) after upload. If the workflow is active, new leads can immediately advance into calls and incur charges. After an error or timeout, inspect enrolled leads before retrying the file, because some leads may already have been created. On a draft workflow, a retry replaces them.

## Destination validation

If the workflow contains Voice Call nodes, every row is validated before any lead is created. A lead's `phone_number` must be valid and must be allowed by at least one active Voice Call phone number in the workflow.

For non-SIP routes, the destination country and prefix must be enabled in **Workspace Settings > Telephony**. Validation failures return `400 Bad Request` with grouped row-level errors and no lead is created, so you can fix the file and retry. These errors number rows by their line in the file, with the header as row 1, so the first data row is row 2.

## Numbers on the DNC list

Rows whose number is on the workspace's DNC list are skipped: no lead is created and nothing is processed for them, and `dnc_skipped_count` in the response counts them. If every row's number is on the DNC list, the upload returns `400 Bad Request` (`All N numbers in this file are on your workspace's DNC list, so there is nothing to call.`, or `The only number in this file is on your workspace's DNC list, so there is nothing to call.` for a one-number file) and creates nothing; on a draft workflow the existing leads are kept. A lead whose number is added to the DNC list after upload is stopped before its next step of any kind, with the lead status `dnc_blocked`. The DNC list is managed in the dashboard, not through the API.


## OpenAPI

````yaml POST /v1/workflows/{workflowId}/leads
openapi: 3.0.0
info:
  title: DialNexa API
  description: Public `/v1` REST API for the DialNexa voice AI platform.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: Agents
  - name: Batch Calls
  - name: Calls
  - name: Knowledge Base
  - name: Languages
  - name: LLMs
  - name: Phone Numbers
  - name: Organization Folders
  - name: Transcribers
  - name: Webhooks
  - name: Voices
  - name: Workflows
  - name: Workflow Leads
  - name: Authentication
  - name: Agent Builder
  - name: Agent Evaluations
paths:
  /v1/workflows/{workflowId}/leads:
    post:
      tags:
        - Workflow Leads
      summary: Upload Workflow Leads
      description: >-
        Uploads and enrolls leads in one workflow from a CSV or Excel file. On a
        `draft` workflow the upload replaces every existing lead; on an `active`
        or `paused` workflow it adds to them. Leads uploaded to an `active`
        workflow start immediately; leads uploaded to a `paused` workflow start
        only when the workflow is activated again with `activate`. A 201 can be
        a partial success: rows listed in `errors` either could not be saved or,
        on an `active` workflow, were saved but could not start; a saved row is
        still counted in `data` and `count`.
      operationId: uploadWorkflowLeads
      parameters:
        - name: workflowId
          required: true
          in: path
          description: Workflow ID
          schema:
            type: string
            example: workflow_abc123
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    CSV, XLSX, or XLS file, at most 10 MB (10485760 bytes). The
                    part's Content-Type must be text/csv,
                    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
                    or application/vnd.ms-excel, and the file name must end in
                    .csv, .xlsx or .xls.
                tags:
                  type: string
                  description: >-
                    Optional comma- or pipe-separated labels for every lead.
                    Unioned with the reserved tags column, normalized to
                    lowercase, at most 20 tags per lead and 40 characters per
                    tag.
              required:
                - file
            examples:
              request:
                summary: Upload workflow leads file
                value:
                  file: workflow-leads.csv
      responses:
        '201':
          description: File processed successfully.
          content:
            application/json:
              examples:
                success:
                  summary: All rows created
                  value:
                    success: true
                    error: false
                    statusCode: 201
                    message: Success
                    data:
                      statusCode: 201
                      message: Leads uploaded successfully
                      data:
                        '+919876543210':
                          - lead_abc123
                        '+919123456789':
                          - lead_def456
                      count: 2
                      tags:
                        - priority
                      dnc_skipped_count: 0
                    timestamp: '2026-09-07T06:00:00.000Z'
                partial:
                  summary: Some rows failed
                  value:
                    success: true
                    error: false
                    statusCode: 201
                    message: Success
                    data:
                      statusCode: 201
                      message: Leads uploaded with 2 row(s) failed.
                      data:
                        '+919876543210':
                          - lead_abc123
                        '+919123456789':
                          - lead_def456
                      count: 2
                      tags: []
                      errors:
                        - >-
                          Row 1 (phone: +919876543210): Phone number phn_abc123
                          not found or not active for VoiceCall node
                          Rt5vN8kQ2wLz7x
                        - >-
                          Row 2 (phone: +919123456789): Phone number phn_abc123
                          not found or not active for VoiceCall node
                          Rt5vN8kQ2wLz7x
                      unused_columns:
                        - product
                      allowed_columns:
                        - customer_name
                      dnc_skipped_count: 0
                    timestamp: '2026-09-07T06:00:00.000Z'
              schema:
                type: object
                required:
                  - success
                  - error
                  - statusCode
                  - message
                  - data
                  - timestamp
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  error:
                    type: boolean
                    enum:
                      - false
                  statusCode:
                    type: integer
                    example: 201
                  message:
                    type: string
                    example: Success
                  data:
                    type: object
                    properties:
                      statusCode:
                        type: number
                        example: 201
                      message:
                        type: string
                        example: Leads uploaded successfully
                        description: >-
                          `Leads uploaded successfully`, or `Leads uploaded with
                          N row(s) failed.` when `errors` is present.
                      data:
                        type: object
                        description: >-
                          Created lead IDs grouped by the phone number exactly
                          as it appears in the file.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                            example: lead_abc123
                      count:
                        type: number
                        example: 1
                        description: Number of leads created.
                      tags:
                        type: array
                        items:
                          type: string
                        description: Every tag applied in this upload.
                      errors:
                        type: array
                        items:
                          type: string
                        description: >-
                          Present only when some rows failed, one message per
                          row: the lead could not be saved, or, on an active
                          workflow, it was saved (and is in data and count) but
                          its execution could not start.
                      unused_columns:
                        type: array
                        items:
                          type: string
                        description: >-
                          Present only when some data columns are not referenced
                          by any node or agent prompt in the workflow. The
                          reserved notes and agent_transfer_destinations columns
                          can also be listed.
                      allowed_columns:
                        type: array
                        items:
                          type: string
                        description: >-
                          Present with unused_columns: the variable names the
                          workflow does reference.
                      dnc_skipped_count:
                        type: integer
                        example: 0
                        description: >-
                          Rows left out because their number is on the
                          workspace's DNC list. 0 when none was.
                  timestamp:
                    type: string
                    format: date-time
        '400':
          description: >-
            Missing file, wrong extension or MIME type, malformed CSV, no row
            with a phone number, invalid notes, transfer destinations or tags,
            or rows whose phone number fails destination validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 400 Bad Request
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: File must be a CSV or Excel file (.csv, .xlsx, .xls)
                    errors: []
                rowValidation:
                  summary: Rows whose numbers fail validation
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: >-
                      1 phone number failed validation.

                      Phone Number "12345" Could Not Be Parsed. Use
                      International Format Such As +447700900123. (row: 3)
                    errors:
                      - >-
                        Phone Number "12345" Could Not Be Parsed. Use
                        International Format Such As +447700900123. (row: 3)
                    validation_errors:
                      - error: >-
                          Phone Number "12345" Could Not Be Parsed. Use
                          International Format Such As +447700900123.
                        rows:
                          - 3
                        phone_numbers:
                          - '12345'
                    invalid_row_count: 1
                allNumbersOnDnc:
                  summary: Every number is on the DNC list
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: >-
                      All 2 numbers in this file are on your workspace's DNC
                      list, so there is nothing to call.
                    errors:
                      - >-
                        All 2 numbers in this file are on your workspace's DNC
                        list, so there is nothing to call.
        '401':
          description: Unauthorized - missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 401 Unauthorized
                  value:
                    statusCode: 401
                    error: true
                    success: false
                    data: []
                    message: Invalid API key
                    errors: []
        '404':
          description: Workflow not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 404 Not Found
                  value:
                    statusCode: 404
                    error: true
                    success: false
                    data: []
                    message: Workflow with ID Hk3pW9zQe1LmRt not found
                    errors: []
        '413':
          description: The uploaded file is larger than 10 MB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 413 Payload Too Large
                  value:
                    statusCode: 413
                    error: true
                    success: false
                    data: []
                    message: File too large
                    errors: []
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 500 Internal Server Error
                  value:
                    statusCode: 500
                    error: true
                    success: false
                    data: []
                    message: Something went wrong while processing your request.
                    errors: []
      security:
        - bearer: []
components:
  schemas:
    ErrorResponse:
      type: object
      description: Error body on endpoints without response filtering.
      properties:
        statusCode:
          type: integer
          example: 404
        error:
          type: boolean
          enum:
            - true
        success:
          type: boolean
          enum:
            - false
        data:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                  description: Machine-readable refusal code.
            - type: array
              items: {}
          description: >-
            For a coded refusal, an object with code and the details listed for
            that code. Otherwise an empty array.
        message:
          type: string
        errors:
          type: array
          items:
            type: string
          description: Validation messages for a 400. Empty for other errors.
        validation_errors:
          type: array
          description: >-
            Present when uploaded rows fail number validation (batch and
            workflow lead uploads): one group per distinct error.
          items:
            type: object
            properties:
              error:
                type: string
              rows:
                type: array
                items:
                  type: integer
                description: Row numbers with this error.
              phone_numbers:
                type: array
                items:
                  type: string
        invalid_row_count:
          type: integer
          description: 'Present with validation_errors: how many rows failed.'
      required:
        - statusCode
        - error
        - success
        - data
        - message
        - errors
  securitySchemes:
    bearer:
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.