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

# Preview CSV import

> Parse a CSV file and return column headers with a preview of the first 5 rows



## OpenAPI

````yaml /openapi.json post /v1/contacts/import/preview
openapi: 3.0.3
info:
  title: Emailr API
  version: 1.0.0
servers:
  - url: https://api.emailr.dev
    description: Production
security: []
tags:
  - name: emails
    description: Email sending and management
  - name: contacts
    description: Contact management
  - name: templates
    description: Email template management
  - name: domains
    description: Domain verification and management
  - name: webhooks
    description: Webhook configuration
  - name: broadcasts
    description: Broadcast campaign management
  - name: segments
    description: Contact segmentation
paths:
  /v1/contacts/import/preview:
    post:
      tags:
        - import
      summary: Preview CSV import
      description: >-
        Parse a CSV file and return column headers with a preview of the first 5
        rows
      operationId: csvImportPreview
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CSVImportPreviewRequest'
      responses:
        '200':
          description: CSV preview with headers and sample rows
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CSVImportPreviewResponse'
        '400':
          description: CSV parsing error or validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    CSVImportPreviewRequest:
      type: object
      properties:
        file_content:
          type: string
          description: CSV content, either base64 encoded or raw text
          example: >-
            ZW1haWwsZmlyc3RfbmFtZSxsYXN0X25hbWUKam9obkBleGFtcGxlLmNvbSxKb2huLERvZQ==
        is_base64:
          type: boolean
          default: true
          description: 'Whether the file_content is base64 encoded (default: true)'
          example: true
      required:
        - file_content
    CSVImportPreviewResponse:
      type: object
      properties:
        headers:
          type: array
          items:
            type: string
          description: Column headers extracted from the CSV file
          example:
            - email
            - first_name
            - last_name
            - company
        preview_rows:
          type: array
          items:
            $ref: '#/components/schemas/CSVPreviewRow'
          description: First 5 rows of data as objects with header keys
          example:
            - email: john@example.com
              first_name: John
              last_name: Doe
              company: Acme
            - email: jane@example.com
              first_name: Jane
              last_name: Smith
              company: Corp
        total_rows:
          type: integer
          description: Total number of data rows in the CSV (excluding header)
          example: 150
        suggested_mappings:
          type: object
          additionalProperties:
            type: string
            nullable: true
          description: >-
            Auto-suggested mappings for column headers to contact properties.
            Value is null if no suggestion.
          example:
            email: email
            first_name: first_name
            last_name: last_name
            company: null
      required:
        - headers
        - preview_rows
        - total_rows
        - suggested_mappings
    Error:
      type: object
      properties:
        error:
          type: string
          example: An error occurred
        code:
          type: string
          example: VALIDATION_ERROR
        details: {}
      required:
        - error
    CSVPreviewRow:
      type: object
      additionalProperties:
        type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API key authentication. Use your API key as the bearer token.

````