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

# Create Contact Import

> Import contacts from an uploaded CSV file. The file is stored and processed in the background; poll `GET /v1/contacts/imports/{id}` for status and counts. Requires API key with audience:write.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/contacts/imports
openapi: 3.1.0
info:
  title: Migma.ai API (v1)
  description: >-
    API for managing brands, contacts, email generation, sending, and
    integrations.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.migma.ai
    description: Production
security:
  - apiKeyAuth: []
tags:
  - name: Projects/Brands
    description: Manage projects (brands) and import from websites
  - name: Contacts
    description: Manage your contacts, segments, tags, and topics
  - name: Segments
    description: Create and manage dynamic contact segments
  - name: Tags
    description: Organize contacts with tags
  - name: Topics
    description: Manage subscription topics and preferences
  - name: Emails
    description: Generate, send, and export emails
  - name: Email Validation
    description: Validate email content for compatibility and deliverability
  - name: Email Previews
    description: Preview emails across devices and email clients
  - name: Domains
    description: Manage sending domains and verification
  - name: Webhooks
    description: Manage webhook endpoints for real-time event notifications
  - name: Integrations
    description: Third-party platform integrations
  - name: Campaigns
    description: Create, schedule, send, and manage email campaigns
  - name: Project Editing
    description: Edit project assets, logos, images, and knowledge base entries
paths:
  /v1/contacts/imports:
    post:
      tags:
        - Contacts
      summary: Create Contact Import
      description: >-
        Import contacts from an uploaded CSV file. The file is stored and
        processed in the background; poll `GET /v1/contacts/imports/{id}` for
        status and counts. Requires API key with audience:write.
      operationId: CreateContactImport
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateContactImportRequest'
      responses:
        '200':
          description: Import accepted for background processing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponseContactImport'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST https://api.migma.ai/v1/contacts/imports \
              -H "Authorization: Bearer $MIGMA_API_KEY" \
              -F "file=@contacts.csv" \
              -F "projectId=PROJECT_ID" \
              -F 'columnMap={"email":"Email","firstName":"First Name"}' \
              -F "onConflict=upsert" \
              -F "tags=newsletter,launch"
components:
  schemas:
    CreateContactImportRequest:
      type: object
      properties:
        file:
          type: string
          format: binary
          description: CSV file to import
        projectId:
          type: string
          description: Project ID
        columnMap:
          type: string
          description: >-
            JSON string mapping subscriber fields to CSV header names. Only
            `email` is required. Supported keys: `email`, `firstName`,
            `lastName`, `name`, `phone`, `country`, `language`, and
            `customFields` (an object mapping each custom field key to its CSV
            header). Example: `{"email":"Email","firstName":"First
            Name","customFields":{"plan":"Plan"}}`.
        onConflict:
          type: string
          enum:
            - skip
            - upsert
          default: upsert
          description: How to handle rows whose email already exists.
        delimiter:
          type: string
          default: ','
          description: CSV field delimiter.
        tags:
          type: string
          description: >-
            Tag names to apply to every imported contact, as a JSON array (e.g.
            `["newsletter"]`) or a comma-separated string. Tags are created if
            they do not exist.
      required:
        - file
        - projectId
        - columnMap
    ApiResponseContactImport:
      allOf:
        - $ref: '#/components/schemas/ApiResponse'
        - type: object
          properties:
            data:
              type: object
              properties:
                object:
                  type: string
                  example: contact_import
                id:
                  type: string
                  description: >-
                    Import job ID. Poll GET /v1/contacts/imports/{id} for
                    status.
                status:
                  type: string
                  example: processing
    ApiResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          nullable: true
        error:
          type: string
          nullable: true
      required:
        - success
    ApiError:
      type: object
      properties:
        success:
          type: boolean
          default: false
        error:
          type: string
        code:
          type: string
          description: >-
            Machine-readable error code (e.g., IDEMPOTENCY_CONFLICT,
            DOMAIN_CLAIMABLE).
        data:
          type: object
          description: >-
            Additional structured context for the error, such as the affected
            domain.
          additionalProperties: true
      required:
        - success
        - error
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Forbidden:
      description: Forbidden - Missing required permissions or access denied
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Use 'Authorization: Bearer YOUR_API_KEY' where
        YOUR_API_KEY is obtained from the Migma dashboard under Settings →
        Developers → API Keys.

````