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

# Bulk Import Contacts

> Bulk import contacts. Requires API key with audience:write.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/contacts/bulk
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/bulk:
    post:
      tags:
        - Contacts
      summary: Bulk Import Contacts
      description: Bulk import contacts. Requires API key with audience:write.
      operationId: BulkImportContacts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkImportSubscribersRequest'
      responses:
        '200':
          description: Bulk import result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponseBulkImportResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Unauthorized'
      x-codeSamples:
        - lang: javascript
          label: Node.js SDK
          source: |-
            import Migma from 'migma';

            const migma = new Migma('YOUR_API_KEY');

            const { data, error } = await migma.contacts.bulkImport({
              subscribers: [
                { email: 'john@example.com', firstName: 'John' },
                { email: 'jane@example.com', firstName: 'Jane' }
              ],
              projectId: 'PROJECT_ID'
            });
components:
  schemas:
    BulkImportSubscribersRequest:
      type: object
      properties:
        subscribers:
          type: array
          items:
            $ref: '#/components/schemas/AddSubscriberRequest'
          minItems: 1
        projectId:
          type: string
      required:
        - subscribers
        - projectId
    ApiResponseBulkImportResult:
      allOf:
        - $ref: '#/components/schemas/ApiResponse'
        - type: object
          properties:
            data:
              type: object
              properties:
                success:
                  type: integer
                failed:
                  type: integer
                updated:
                  type: integer
                errors:
                  type: array
                  items:
                    type: string
    AddSubscriberRequest:
      type: object
      properties:
        email:
          type: string
          format: email
        firstName:
          type: string
        lastName:
          type: string
        phone:
          type: string
          maxLength: 30
          description: Phone number (free-form, max 30 chars)
        country:
          type: string
        language:
          type: string
        tags:
          type: array
          items:
            type: string
        customFields:
          type: object
          additionalProperties: true
        status:
          type: string
          description: Contact subscription status. Defaults to subscribed.
          enum:
            - subscribed
            - unsubscribed
            - bounced
            - non-subscribed
        projectId:
          type: string
      required:
        - email
        - projectId
    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
      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'
  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 → API
        Integration.

````