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

# Preview a transaction file

> Use this endpoint to preview a transaction file before importing it. Returns sample rows and detected columns to help verify the file structure and field mapping.



## OpenAPI

````yaml /en/openapi/v3-current/matcher.yaml post /v1/imports/contexts/{contextId}/sources/{sourceId}/preview
openapi: 3.1.0
info:
  title: Matcher APIs
  description: >-
    Complete API reference for the Matcher reconciliation engine, providing
    automated transaction matching between Midaz Ledger and external systems.
  version: v2.1.1
  license:
    name: Elastic License 2.0
    url: https://www.elastic.co/licensing/elastic-license
servers:
  - url: https://matcher.sandbox.lerian.net
security: []
paths:
  /v1/imports/contexts/{contextId}/sources/{sourceId}/preview:
    post:
      tags:
        - Ingestion
      summary: Preview a transaction file
      description: >-
        Use this endpoint to preview a transaction file before importing it.
        Returns sample rows and detected columns to help verify the file
        structure and field mapping.
      operationId: previewFile
      parameters:
        - description: A unique identifier for tracing the request across services.
          in: header
          name: X-Request-Id
          schema:
            type: string
        - description: The unique identifier of the reconciliation context.
          in: path
          name: contextId
          required: true
          schema:
            type: string
        - description: The unique identifier of the reconciliation source.
          in: path
          name: sourceId
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/XIdempotencyKey'
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  description: Transaction file to preview (CSV, JSON, or XML)
                  type: string
                  format: binary
                format:
                  description: File format (auto-detected from filename if omitted)
                  type: string
                  enum:
                    - csv
                    - json
                    - xml
                max_rows:
                  description: Maximum number of sample rows to return
                  type: integer
                  minimum: 1
                  maximum: 20
                  default: 5
              required:
                - file
        required: true
      responses:
        '200':
          description: >-
            File preview with detected columns and sample rows.


            The response includes the `X-Idempotency-Replayed` header.


            If the value is false, the request was just processed. If the value
            is true, the response is a replay of a previously processed request.


            See [Retries and idempotency](/en/reference/retries-idempotency) for
            more details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FilePreviewResponse'
          headers:
            X-Idempotency-Replayed:
              $ref: '#/components/headers/XIdempotencyReplayed'
        '400':
          description: The request contains invalid parameters or payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: The request lacks valid authentication credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: You do not have permission to access this resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Context or source not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  parameters:
    XIdempotencyKey:
      name: X-Idempotency-Key
      in: header
      required: false
      description: >-
        Optional idempotency key for safe retries. Also accepts
        `Idempotency-Key` as an alternative header name. If the same key is sent
        again and the original request was already processed, the cached
        response is returned with `X-Idempotency-Replayed: true`.


        See [Retries and idempotency](/en/reference/retries-idempotency) for
        details.
      schema:
        type: string
  schemas:
    FilePreviewResponse:
      description: Preview of a transaction file showing detected columns and sample data
      type: object
      properties:
        columns:
          type: array
          items:
            type: string
          description: Detected column names
          example:
            - date
            - amount
            - reference
            - description
        sampleRows:
          type: array
          items:
            items:
              type: string
            type: array
          description: Sample data rows
        rowCount:
          type: integer
          description: Number of sample rows returned
          example: 5
        format:
          type: string
          description: Detected file format
          example: csv
    ErrorResponse:
      description: Standard error response returned by all API endpoints
      type: object
      required:
        - code
        - title
        - message
      properties:
        code:
          type: string
          description: HTTP status code as a string.
          example: '404'
        title:
          type: string
          description: Error type identifier.
          example: not_found
        message:
          type: string
          description: Human-readable error message with details.
          example: context not found
        error:
          type: string
          description: Deprecated. Error message for backward compatibility.
          deprecated: true
        details:
          description: Additional error context as key-value pairs
          additionalProperties: {}
          type: object
  headers:
    XIdempotencyReplayed:
      description: >-
        Indicates whether this response was served from the idempotency cache.
        When `true`, the response is a replay of the original request with the
        same idempotency key.


        See [Retries and idempotency](/en/reference/retries-idempotency) for
        details.
      schema:
        type: boolean
      example: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Bearer token authentication (format: "Bearer {token}")'

````