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

# Bulk import hosts

> Body is a CSV file (text/csv) or a JSON envelope. Returns 200 with a per-row verdict even when every row failed.



## OpenAPI

````yaml /openapi.json post /api/v1/hosts/batch
openapi: 3.0.3
info:
  title: 2501 Public API
  version: v1
  description: >-
    The stable, versioned HTTP API for driving 2501 as code. See the API
    Overview for authentication, the org_id rule, cursor pagination, and the
    error envelope.
servers:
  - url: https://{command_center_host}
    variables:
      command_center_host:
        default: your-command-center-host
        description: Your Command Center host
security:
  - bearerAuth: []
paths:
  /api/v1/hosts/batch:
    post:
      tags:
        - Hosts
      summary: Bulk import hosts
      description: >-
        Body is a CSV file (text/csv) or a JSON envelope. Returns 200 with a
        per-row verdict even when every row failed.
      parameters:
        - schema:
            type: string
          required: false
          name: org_id
          in: query
        - schema:
            type: string
            enum:
              - stop
              - continue
            default: continue
          required: false
          name: on_error
          in: query
        - schema:
            anyOf:
              - type: string
                enum:
                  - 'true'
              - type: string
                enum:
                  - 'false'
              - type: string
                enum:
                  - '1'
              - type: string
                enum:
                  - '0'
            default: false
          required: false
          name: dry_run
          in: query
      requestBody:
        required: true
        description: A CSV file, or a JSON envelope { rows, on_error?, dry_run? }
        content:
          text/csv:
            schema:
              type: string
          application/json:
            schema:
              type: object
              properties:
                rows:
                  type: array
                  items:
                    type: object
                    additionalProperties:
                      nullable: true
                on_error:
                  type: string
                  enum:
                    - stop
                    - continue
                dry_run:
                  type: boolean
              required:
                - rows
      responses:
        '200':
          description: Per-row import result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImportResult'
        '400':
          description: >-
            Bad request - a field is missing, malformed, or not allowed
            (VALIDATION_FAILED, BAD_REQUEST, INVALID_CURSOR)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            No credentials, or a key that is invalid, revoked, or expired
            (UNAUTHORIZED)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            Authenticated but not allowed (FORBIDDEN, ORG_ACCESS_DENIED,
            LICENSE_CAP_REACHED, LICENSE_EXPIRED)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ImportResult:
      type: object
      properties:
        object:
          type: string
          enum:
            - import_result
        dry_run:
          type: boolean
        stopped:
          type: boolean
        counts:
          type: object
          properties:
            created:
              type: integer
            updated:
              type: integer
            skipped:
              type: integer
            failed:
              type: integer
          required:
            - created
            - updated
            - skipped
            - failed
        results:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              status:
                type: string
                enum:
                  - created
                  - updated
                  - skipped
                  - failed
              id:
                type: string
              error:
                type: string
            required:
              - index
              - status
      required:
        - object
        - dry_run
        - stopped
        - counts
        - results
    Error:
      type: object
      properties:
        code:
          type: string
          example: VALIDATION_FAILED
        message:
          type: string
          example: Validation failed
        request_id:
          type: string
          example: req_3702b7e7-...
        field:
          type: string
          description: Set when one input is at fault
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              message:
                type: string
            required:
              - field
              - message
          description: Set when several inputs are at fault
        details:
          type: object
          additionalProperties:
            nullable: true
      required:
        - code
        - message
        - request_id
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API key minted in Command Center (Settings -> API Keys), sent as
        `Authorization: Bearer 2501_ak_...`. A Command Center session cookie is
        also accepted.

````