> ## 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 Provider Contact Import

> Import contacts from one or more sources on a connected Klaviyo, Mailchimp, or HubSpot account. Processing runs in the background; poll `GET /v1/contacts/imports/{id}` for status and counts. Each import creates a tag and a saved segment named after the source(s). Unsubscribed contacts stay unsubscribed. Requires API key with audience:write.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/contacts/imports/provider
openapi: 3.1.0
info:
  title: Migma.ai API (v1)
  description: >-
    API for managing brands, contacts, email generation, sending, and
    integrations. API request budgets are plan-based and shared across an
    account's API keys per route group. Sending request allowances support the
    account's recipients/second rate; recipient throughput and daily/monthly
    email quotas remain separate. See
    https://docs.migma.ai/api-reference/introduction#rate-limiting for limits,
    response headers, and retry behavior.
  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: Events
    description: Record customer events and conversions
  - name: Integrations
    description: Third-party platform integrations
  - name: Campaigns
    description: Create, schedule, send, and manage email campaigns
  - name: Billing
    description: View your plan and credits and create billing links
  - name: Project Editing
    description: Edit project assets, logos, images, and knowledge base entries
paths:
  /v1/contacts/imports/provider:
    post:
      tags:
        - Contacts
      summary: Create Provider Contact Import
      description: >-
        Import contacts from one or more sources on a connected Klaviyo,
        Mailchimp, or HubSpot account. Processing runs in the background; poll
        `GET /v1/contacts/imports/{id}` for status and counts. Each import
        creates a tag and a saved segment named after the source(s).
        Unsubscribed contacts stay unsubscribed. Requires API key with
        audience:write.
      operationId: CreateProviderContactImport
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateProviderContactImportRequest'
            example:
              projectId: aaaaaaaaaaaaaaaaaaaaaaaa
              provider: klaviyo
              sources:
                - id: segment:XyZ
                  type: segment
                  name: VIP Customers
              consentMode: subscribed-only
      responses:
        '201':
          description: Import accepted for background processing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponseProviderContactImport'
        '400':
          description: >-
            Bad request (code: INTEGRATION_ACCOUNT_REQUIRED when multiple
            accounts are connected and connectionId is omitted)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          description: >-
            Provider not connected or reconnect required (codes:
            PROVIDER_NOT_CONNECTED, PROVIDER_RECONNECT_REQUIRED). The error
            message includes a connect link; `data.connectUrl` has the same URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST https://api.migma.ai/v1/contacts/imports/provider \
              -H "Authorization: Bearer $MIGMA_API_KEY" \
              -H "Content-Type: application/json" \
              -H "Idempotency-Key: klaviyo-vip-import-1" \
              -d '{
                "projectId": "PROJECT_ID",
                "provider": "klaviyo",
                "sources": [{"id": "segment:XyZ", "type": "segment", "name": "VIP Customers"}],
                "consentMode": "subscribed-only"
              }'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        Optional key (max 100 chars) for safe retries. Same key + same body
        within 24h replays the original response (same status and body); same
        key + a different body returns 409 IDEMPOTENCY_CONFLICT. Scoped per API
        key.
      schema:
        type: string
        maxLength: 100
  schemas:
    CreateProviderContactImportRequest:
      type: object
      required:
        - projectId
        - provider
        - sources
      properties:
        projectId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: Brand (project) ID
        provider:
          type: string
          enum:
            - klaviyo
            - mailchimp
            - hubspot
        sources:
          type: array
          minItems: 1
          maxItems: 25
          items:
            $ref: '#/components/schemas/ProviderImportSource'
        consentMode:
          type: string
          enum:
            - subscribed-only
            - include-all
          default: subscribed-only
          description: Whether to import only contacts with clear marketing consent
        connectionId:
          type: string
          description: Connected integration account ID when multiple accounts are linked
    ApiResponseProviderContactImport:
      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: pending
                tag:
                  type: object
                  properties:
                    id:
                      type: string
                    name:
                      type: string
                segment:
                  type: object
                  properties:
                    id:
                      type: string
                    name:
                      type: string
    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
    ProviderImportSource:
      type: object
      required:
        - id
        - type
        - name
      properties:
        id:
          type: string
          description: Provider-specific source identifier
        type:
          type: string
          enum:
            - audience
            - segment
            - tag
            - list
        name:
          type: string
    ApiResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          nullable: true
        error:
          type: string
          nullable: true
      required:
        - success
  responses:
    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.

````

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