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

# Upload leads via CSV

> **Upload leads to a campaign via CSV file**

Upload a CSV file containing lead data. The upload is processed asynchronously
for large files, so check the progress URL for status.

## CSV Requirements

- Must include an email column (required)
- Additional columns: first_name, last_name, company, custom fields
- Maximum file size: 50MB
- Maximum leads per upload: 10,000

## Mapping Format

Provide a JSON mapping from CSV columns to lead fields:

```json
{
    "email": "Email Address",
    "first_name": "First Name",
    "last_name": "Last Name",
    "company": "Company",
    "custom_industry": "Industry"
}
```

## Example Usage

```python
import requests

campaign_id = "550e8400-e29b-41d4-a716-446655440000"

mapping = {
    "email": "Email",
    "first_name": "First Name",
    "last_name": "Last Name",
    "company": "Company"
}

with open("leads.csv", "rb") as f:
    response = requests.post(
        f"https://api.coldsend.io/api/public/v1/campaigns/{campaign_id}/leads",
        headers={"X-API-Key": "your-api-key"},
        files={"file": f},
        data={"mapping": json.dumps(mapping)}
    )

print(response.json())
```



## OpenAPI

````yaml /public_openapi.json post /api/public/v1/campaigns/{campaign_id}/leads
openapi: 3.0.3
info:
  title: ColdSend Public API
  description: >-
    Programmatic access to ColdSend for managing cold email campaigns and sender
    accounts.
  version: 1.0.0
  contact:
    name: ColdSend Support
    email: support@coldsend.pro
    url: https://coldsend.pro
servers:
  - url: https://api.coldsend.pro
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/public/v1/campaigns/{campaign_id}/leads:
    post:
      tags:
        - Leads
      summary: Upload leads via CSV
      description: >-
        **Upload leads to a campaign via CSV file**


        Upload a CSV file containing lead data. The upload is processed
        asynchronously

        for large files, so check the progress URL for status.


        ## CSV Requirements


        - Must include an email column (required)

        - Additional columns: first_name, last_name, company, custom fields

        - Maximum file size: 50MB

        - Maximum leads per upload: 10,000


        ## Mapping Format


        Provide a JSON mapping from CSV columns to lead fields:


        ```json

        {
            "email": "Email Address",
            "first_name": "First Name",
            "last_name": "Last Name",
            "company": "Company",
            "custom_industry": "Industry"
        }

        ```


        ## Example Usage


        ```python

        import requests


        campaign_id = "550e8400-e29b-41d4-a716-446655440000"


        mapping = {
            "email": "Email",
            "first_name": "First Name",
            "last_name": "Last Name",
            "company": "Company"
        }


        with open("leads.csv", "rb") as f:
            response = requests.post(
                f"https://api.coldsend.io/api/public/v1/campaigns/{campaign_id}/leads",
                headers={"X-API-Key": "your-api-key"},
                files={"file": f},
                data={"mapping": json.dumps(mapping)}
            )

        print(response.json())

        ```
      operationId: upload_leads_api_public_v1_campaigns__campaign_id__leads_post
      parameters:
        - name: campaign_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Campaign Id
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_upload_leads_api_public_v1_campaigns__campaign_id__leads_post
      responses:
        '201':
          description: Lead upload initiated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeadUploadResponse'
        '400':
          description: Invalid CSV or mapping
        '401':
          description: Missing or invalid API key
        '403':
          description: Insufficient permissions - requires 'leads:create' scope
        '404':
          description: Campaign not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_upload_leads_api_public_v1_campaigns__campaign_id__leads_post:
      properties:
        file:
          type: string
          format: binary
          title: File
          description: CSV file with leads
        mapping:
          type: string
          title: Mapping
          description: JSON mapping from CSV columns to lead fields
        duplicate_action:
          type: string
          title: Duplicate Action
          description: 'Action for duplicates: ''skip'' or ''update'''
          default: skip
        delete_existing:
          type: boolean
          title: Delete Existing
          description: Delete existing leads before upload
          default: false
      type: object
      required:
        - file
        - mapping
      title: Body_upload_leads_api_public_v1_campaigns__campaign_id__leads_post
    LeadUploadResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        message:
          type: string
          title: Message
          default: Lead upload initiated
        job_id:
          type: string
          format: uuid
          title: Job Id
          description: Job ID for tracking upload progress
        campaign_id:
          type: string
          format: uuid
          title: Campaign Id
          description: Campaign ID
        total_rows:
          type: integer
          title: Total Rows
          description: Total rows in CSV
        estimated_leads:
          type: integer
          title: Estimated Leads
          description: Estimated valid leads
        progress_url:
          type: string
          title: Progress Url
          description: URL to check upload progress
      type: object
      required:
        - job_id
        - campaign_id
        - total_rows
        - estimated_leads
        - progress_url
      title: LeadUploadResponse
      description: Response for lead upload initiation.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key with format cs_live_xxx

````