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

# Import Lien Filings In Bulk

> Submit a CSV of liens to import from the public record (one lien per row). Always processed asynchronously (202 + batch id); poll GET /lien_submissions/import/batches/{batch_id} and download per-row results via /lien_submissions/import/batches/{batch_id}/download. Batches are capped at 40,000 rows. Columns: state, filing_number, filing_name (required: state, filing_number). Only the file as a whole is validated on upload — headers, encoding, size and row count; a row the parser cannot map is reported per-row in the results instead. Rows are identified by their ORIGINAL line number in the uploaded file (the header is line 1, and skipped blank lines still take up their line). One row per line: a quoted field may not contain a line break, and a file with one is rejected naming the line the row starts on.



## OpenAPI

````yaml /api-reference/openapi.json post /lien_submissions/import/batches
openapi: 3.1.0
info:
  title: baselayer-api-service
  version: 0.1.0
servers:
  - url: https://api.baselayer.com/
security: []
paths:
  /lien_submissions/import/batches:
    post:
      tags:
        - Lien Filing
      summary: Import Lien Filings In Bulk
      description: >-
        Submit a CSV of liens to import from the public record (one lien per
        row). Always processed asynchronously (202 + batch id); poll GET
        /lien_submissions/import/batches/{batch_id} and download per-row results
        via /lien_submissions/import/batches/{batch_id}/download. Batches are
        capped at 40,000 rows. Columns: state, filing_number, filing_name
        (required: state, filing_number). Only the file as a whole is validated
        on upload — headers, encoding, size and row count; a row the parser
        cannot map is reported per-row in the results instead. Rows are
        identified by their ORIGINAL line number in the uploaded file (the
        header is line 1, and skipped blank lines still take up their line). One
        row per line: a quoted field may not contain a line break, and a file
        with one is rejected naming the line the row starts on.
      operationId: import_lien_filings_in_bulk_lien_submissions_import_batches_post
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_import_lien_filings_in_bulk_lien_submissions_import_batches_post
      responses:
        '202':
          description: The import batch was accepted and is being processed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1.LienFilingImportBatchResponse'
        '400':
          description: >-
            The upload is not a CSV, is not UTF-8, carries
            unknown/missing/duplicate headers, or has no data rows.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/APIError'
                    title: InvalidFileType
                    description: Invalid file type. Please upload a CSV file.
                    examples:
                      - code: 602
                        message: Invalid file type. Please upload a CSV file.
                        metadata: {}
                  - $ref: '#/components/schemas/APIError'
                    title: InvalidCSVFormat
                    description: >-
                      Invalid CSV format. Please ensure the file is encoded in
                      UTF-8.
                    examples:
                      - code: 604
                        message: >-
                          Invalid CSV format. Please ensure the file is encoded
                          in UTF-8.
                        metadata: {}
                  - $ref: '#/components/schemas/APIError'
                    title: InvalidCSVHeaders
                    description: >-
                      Cannot process CSV file due to missing required headers.
                      Please ensure your CSV includes all required headers.
                    examples:
                      - code: 600
                        message: >-
                          Cannot process CSV file due to missing required
                          headers. Please ensure your CSV includes all required
                          headers.
                        metadata: {}
                  - $ref: '#/components/schemas/APIError'
                    title: LienImportBatchEmpty
                    description: A bulk lien import must contain at least one row.
                    examples:
                      - code: 802
                        message: A bulk lien import must contain at least one row.
                        metadata: {}
                title: >-
                  Response 400 Import Lien Filings In Bulk Lien Submissions
                  Import Batches Post
        '402':
          description: >-
            The calling application is a sandbox application, which cannot
            import filings from the public record, or the organization is
            locked.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/APIError'
                    title: PaymentRequiredSandboxApplication
                    description: >-
                      Payment Required. Sandbox applications do not support this
                      request.
                    examples:
                      - code: 500
                        message: >-
                          Payment Required. Sandbox applications do not support
                          this request.
                        metadata: {}
                  - $ref: '#/components/schemas/APIError'
                    title: OrganizationLocked
                    description: >-
                      The organization is locked due to payment issues. Please
                      update your payment information.
                    examples:
                      - code: 3004
                        message: >-
                          The organization is locked due to payment issues.
                          Please update your payment information.
                        metadata: {}
                title: >-
                  Response 402 Import Lien Filings In Bulk Lien Submissions
                  Import Batches Post
        '413':
          description: The uploaded file exceeds the maximum allowed size.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
                title: FileTooLarge
                description: The file is too large. Please upload a smaller file.
                examples:
                  - code: 900
                    message: The file is too large. Please upload a smaller file.
                    metadata: {}
        '422':
          description: The CSV carries more rows than a single batch may hold.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
                title: LienImportBatchTooLarge
                description: A bulk lien import exceeds the maximum allowed number of rows.
                examples:
                  - code: 801
                    message: >-
                      A bulk lien import exceeds the maximum allowed number of
                      rows.
                    metadata: {}
        '502':
          description: >-
            The upload could not be stored. Nothing was recorded — send the file
            again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
                title: ThirdPartyServiceFailure
                description: >-
                  The request could not be completed due to a failure in an
                  external service.
                examples:
                  - code: 7
                    message: >-
                      The request could not be completed due to a failure in an
                      external service.
                    metadata: {}
      security:
        - APIKeyHeader: []
components:
  schemas:
    Body_import_lien_filings_in_bulk_lien_submissions_import_batches_post:
      properties:
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
      type: object
      required:
        - file
      title: Body_import_lien_filings_in_bulk_lien_submissions_import_batches_post
    v1.LienFilingImportBatchResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Import Batch ID
          description: The batch's id, used to poll status and fetch per-row results.
        name:
          type: string
          title: Name
          description: The name of the batch, taken from the uploaded file.
          examples:
            - q3-portfolio-liens.csv
        state:
          $ref: '#/components/schemas/TaskState'
          title: State
          description: Processing state of the batch.
          examples:
            - PENDING
        total_count:
          type: integer
          title: Total Count
          description: Rows read from the uploaded CSV, excluding blank lines.
          examples:
            - 100
        imported_count:
          type: integer
          title: Imported Count
          description: >-
            Rows that resolved against the public record and produced a newly
            imported filing.
          default: 0
          examples:
            - 80
        already_imported_count:
          type: integer
          title: Already Imported Count
          description: >-
            Rows naming a lien the organization had already imported; the
            existing filing is kept.
          default: 0
          examples:
            - 15
        not_found_count:
          type: integer
          title: Not Found Count
          description: >-
            Rows whose state and filing number matched nothing in the public
            record.
          default: 0
          examples:
            - 4
        invalid_row_count:
          type: integer
          title: Invalid Row Count
          description: >-
            Rows rejected before resolution (unparseable state, blank filing
            number, and the like).
          default: 0
          examples:
            - 1
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: >-
            Why the batch last failed, as a human-readable message. Set when the
            state is FAILED; a batch that failed once and succeeded on a resume
            can still carry the message from that attempt, so read it alongside
            the state rather than as a failure signal on its own.
          examples:
            - The uploaded CSV could not be read from storage.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the batch was accepted.
        completed_count:
          type: integer
          title: Completed Count
          description: >-
            Rows processed so far, whatever their outcome — the sum of the four
            outcome counts.
          readOnly: true
          examples:
            - 0
            - 50
        progress:
          type: number
          title: Progress
          description: Fraction of the uploaded rows processed so far, in [0, 1].
          readOnly: true
          examples:
            - 0
            - 0.5
            - 1
      type: object
      required:
        - id
        - name
        - state
        - total_count
        - created_at
        - completed_count
        - progress
      title: LienFilingImportBatchResponse (v1)
      description: >-
        A bulk lien import (ENG-6884) — returned when one is accepted, by the

        polling endpoint, and as the payload of its completion/failure webhooks.


        The four outcome counts partition the rows processed so far: every
        completed

        row is exactly one of imported / already imported / not found / invalid.
    APIError:
      properties:
        code:
          type: integer
          title: Code
        message:
          type: string
          title: Message
        uri:
          anyOf:
            - type: string
            - type: 'null'
          title: Uri
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
      type: object
      required:
        - code
        - message
      title: APIError
      description: >-
        APIError is a Pydantic model for standardizing error responses from the
        API.


        This class is used internally by APIException for JSON serialization.

        Users should typically work with APIException directly in exception
        catalogs.
    TaskState:
      enum:
        - PENDING
        - EXECUTING
        - COMPLETED
        - FAILED
        - CANCELLED
      title: TaskState
      type: string
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````