> ## 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.

# Create Portfolio Items Bulk

> Create Business portfolio items for many completed searches.

Request-level authorization and group lookup failures still fail the
full request. Per-search failures are returned in ``errors`` so the
caller can add every eligible row from a checkbox selection without
retrying successful rows.

Bulk success and error rows are intentionally lightweight. The
frontend only needs IDs and stable error codes for row correlation,
cache refreshes, and summary toasts, so the endpoint avoids full
PortfolioItem serialization and verbose per-row errors.



## OpenAPI

````yaml /api-reference/openapi.json post /portfolio/items/bulk
openapi: 3.1.0
info:
  title: baselayer-api-service
  version: 0.1.0
servers:
  - url: https://api.baselayer.com/
security: []
paths:
  /portfolio/items/bulk:
    post:
      tags:
        - Portfolio Monitoring
      summary: Create Portfolio Items Bulk
      description: |-
        Create Business portfolio items for many completed searches.

        Request-level authorization and group lookup failures still fail the
        full request. Per-search failures are returned in ``errors`` so the
        caller can add every eligible row from a checkbox selection without
        retrying successful rows.

        Bulk success and error rows are intentionally lightweight. The
        frontend only needs IDs and stable error codes for row correlation,
        cache refreshes, and summary toasts, so the endpoint avoids full
        PortfolioItem serialization and verbose per-row errors.
      operationId: create_portfolio_items_bulk_portfolio_items_bulk_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddPortfolioItemsBulkRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddPortfolioItemsBulkResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    AddPortfolioItemsBulkRequest:
      properties:
        business_search_ids:
          items:
            type: string
            format: uuid
          type: array
          maxItems: 250
          minItems: 1
          title: Business Search Ids
          description: The UUIDs of the business searches to add to portfolio monitoring.
          examples:
            - - ede786f3-33ae-4894-843d-af2025f1d5b0
              - e1d5e9e1-6de2-46c0-8492-564998a7426a
        group_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Group Id
          description: The optional UUID of the group to add the newly created items to.
          examples:
            - ede786f3-33ae-4894-843d-af2025f1d5b0
      type: object
      required:
        - business_search_ids
      title: AddPortfolioItemsBulkRequest
      description: Request body for adding multiple BusinessSearches to monitoring.
    AddPortfolioItemsBulkResponse:
      properties:
        items:
          items:
            $ref: '#/components/schemas/AddPortfolioItemsBulkItemResponse'
          type: array
          title: Items
          description: Portfolio items successfully created.
        errors:
          items:
            $ref: '#/components/schemas/AddPortfolioItemsBulkError'
          type: array
          title: Errors
          description: Per-search failures that did not block the whole request.
      type: object
      title: AddPortfolioItemsBulkResponse
      description: Partial-success response for bulk portfolio item creation.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AddPortfolioItemsBulkItemResponse:
      properties:
        business_search_id:
          type: string
          format: uuid
          title: Business Search Id
          description: The business search that was imported.
        portfolio_item_id:
          type: string
          format: uuid
          title: Portfolio Item Id
          description: The created portfolio item ID.
        business_id:
          type: string
          format: uuid
          title: Business Id
          description: The monitored business ID for targeted frontend cache refresh.
      type: object
      required:
        - business_search_id
        - portfolio_item_id
        - business_id
      title: AddPortfolioItemsBulkItemResponse
      description: |-
        Minimal success payload for a created bulk portfolio item.

        Keep bulk successes small on purpose. The frontend needs these IDs for
        counts, row correlation, and targeted cache refresh; full PortfolioItem
        hydration belongs behind the single-item GET endpoint.
    AddPortfolioItemsBulkError:
      properties:
        business_search_id:
          type: string
          format: uuid
          title: Business Search Id
          description: The business search that failed to import.
        code:
          $ref: '#/components/schemas/AddPortfolioItemsBulkErrorCode'
          description: A stable error code for the failed import.
          examples:
            - not_found
            - already_exists
            - ineligible
        existing_item_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Existing Item Id
          description: The existing portfolio item ID for already monitored rows.
      type: object
      required:
        - business_search_id
        - code
      title: AddPortfolioItemsBulkError
      description: >-
        Minimal per-search failure returned by the bulk portfolio item endpoint.


        Keep bulk row errors small on purpose. The frontend needs row
        correlation,

        a stable code for summaries, and the existing item ID when the business
        is

        already monitored.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    AddPortfolioItemsBulkErrorCode:
      type: string
      enum:
        - not_found
        - already_exists
        - ineligible
        - duplicate_request
      title: AddPortfolioItemsBulkErrorCode
      description: Stable per-search error codes returned by the bulk add endpoint.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````