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

# Import recipients (CSV/XLSX)

> Bulk-add recipients by uploading a CSV or .xlsx file (`multipart/form-data`, field `file`, max 5 MB). The sheet must have a header row with a phone column named `phone_number`, `phone`, `mobile`, or `number`; every other column becomes a per-recipient variable for prompt placeholders. Unlike `POST /recipients` (strict JSON), the import is lenient — valid rows are added and invalid rows are reported per-row rather than failing the whole file. Recipients are deduplicated per (campaign, phone). Scope `campaigns:write`.



## OpenAPI

````yaml /api-reference/openapi.json post /campaigns/{campaign_id}/recipients/import
openapi: 3.1.0
info:
  title: Lehar API
  version: v0
  description: >-
    Customer-facing REST API for the Lehar voice-AI platform. Platform-admin
    endpoints are intentionally excluded from this reference. Regenerate with
    `npm run sync:openapi`.
servers:
  - url: https://api.lehar.ai/ca/api/v0
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /campaigns/{campaign_id}/recipients/import:
    post:
      tags:
        - Campaigns
      summary: Import recipients (CSV/XLSX)
      description: >-
        Bulk-add recipients by uploading a CSV or .xlsx file
        (`multipart/form-data`, field `file`, max 5 MB). The sheet must have a
        header row with a phone column named `phone_number`, `phone`, `mobile`,
        or `number`; every other column becomes a per-recipient variable for
        prompt placeholders. Unlike `POST /recipients` (strict JSON), the import
        is lenient — valid rows are added and invalid rows are reported per-row
        rather than failing the whole file. Recipients are deduplicated per
        (campaign, phone). Scope `campaigns:write`.
      operationId: >-
        import_campaign_recipients_ca_api_v0_campaigns__campaign_id__recipients_import_post
      parameters:
        - name: campaign_id
          in: path
          required: true
          schema:
            type: string
            title: Campaign Id
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    A UTF-8 CSV or .xlsx spreadsheet. Header row required; a
                    phone column (`phone_number` / `phone` / `mobile` /
                    `number`) is mandatory. Every other column is stored as a
                    recipient `variable`. Max 5 MB.
      responses:
        '201':
          description: >-
            Import summary plus the accepted recipients (numbers masked).
            `import.status` is `completed`, or `completed_with_errors` when some
            rows were rejected; rejected rows are listed in `import.errors` and
            are NOT added.
          content:
            application/json:
              example:
                import:
                  id: cimport_01EXAMPLE
                  campaign_id: campaign_01EXAMPLE
                  filename: contacts.csv
                  source_uri: null
                  status: completed_with_errors
                  total_rows: 3
                  accepted_rows: 2
                  rejected_rows: 1
                  errors:
                    - row: 4
                      error: >-
                        phone_number looks like a spreadsheet auto-converted it
                        to a number (for example 9.19911E+11). Re-enter it as
                        text, keeping the leading + and country code, for
                        example +911234567890.
                      value: '9.19911E+11'
                  metadata:
                    content_type: text/csv
                  created_at: '2026-05-22T10:10:00Z'
                  completed_at: '2026-05-22T10:10:01Z'
                recipients:
                  - id: recipient_01EXAMPLE
                    campaign_id: campaign_01EXAMPLE
                    phone_number_masked: +9***3210
                    status: pending
                    variables:
                      callee_name: Jane
                      company: Acme
                    whatsapp_context: {}
                    outcome: {}
                    answers: {}
                    qualification_status: null
                    sentiment: null
                    next_action_at: null
                    last_customer_message_at: null
                    service_window_expires_at: null
                    created_at: '2026-05-22T10:10:00Z'
                    updated_at: '2026-05-22T10:10:00Z'
        '400':
          description: >-
            The file is empty, larger than 5 MB, not a UTF-8 CSV / .xlsx, or has
            no phone column.
          content:
            application/json:
              example:
                error:
                  code: invalid_request
                  message: The file must be a UTF-8 CSV or an .xlsx spreadsheet
        '404':
          description: Campaign not found
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    BearerAuth:
      type: http
      scheme: bearer

````