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

# Group baseline items

> Baseline rows of one package grouped by fixed row fields. Rows are paginated, then each page is grouped; within a group rows keep the `find_items` order (`position` descending).



## OpenAPI

````yaml /openapi.yaml post /projects/{project_id}/packages/{package_id}/baseline_items/group_items
openapi: 3.0.1
info:
  title: GetSpecs REST API
  description: REST API documentation for GetSpecs.
  version: 1.0.0
servers:
  - url: /v1
  - url: https://demo-api.getspecs.io/v1
security: []
paths:
  /projects/{project_id}/packages/{package_id}/baseline_items/group_items:
    post:
      tags:
        - BaselineItem
      summary: Group baseline items
      description: >-
        Baseline rows of one package grouped by fixed row fields. Rows are
        paginated, then each page is grouped; within a group rows keep the
        `find_items` order (`position` descending).
      operationId: baseline_items#group_items
      parameters:
        - name: X-Workspace-ID
          in: header
          required: true
          schema:
            type: string
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
        - name: package_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/requestBodyBaselineItemGroupItems'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                required:
                  - groups
                properties:
                  groups:
                    type: array
                    items:
                      $ref: '#/components/schemas/package_baseline_item_group'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      security:
        - apiKey: []
          workspaceId: []
components:
  schemas:
    requestBodyBaselineItemGroupItems:
      type: object
      required:
        - groups
      properties:
        groups:
          type: array
          description: >-
            Group levels, outermost first. `package_section` groups by the row's
            own section (label is its full "Parent / Child" path, ordered
            parent-first along the section tree); rows without a value in a
            plain text field (`unit_type`, any `supplier_*`) form a `null`
            group, sorted last.
          items:
            type: object
            required:
              - field
            properties:
              field:
                type: string
                enum:
                  - package_section
                  - category
                  - unit_type
                  - origin
                  - supplier_company_name
                  - supplier_contact_name
                  - supplier_contact_email
                  - supplier_contact_phone
                  - supplier_address
              sort:
                type: string
                enum:
                  - asc
                  - desc
                description: Default asc.
        filter:
          $ref: '#/components/schemas/baseline_item_filter'
        page:
          type: integer
        per_page:
          type: integer
          description: >-
            Default 25, max 100. Paginates rows; each page's rows are grouped on
            their own.
    package_baseline_item_group:
      type: object
      required:
        - key
        - label
        - items
        - groups
      properties:
        key:
          type: string
          nullable: true
          description: >-
            Section id (as a string) for package_section, otherwise the field
            value.
        label:
          type: string
          nullable: true
        items:
          type: array
          items:
            $ref: '#/components/schemas/package_baseline_item'
        groups:
          type: array
          items:
            $ref: '#/components/schemas/package_baseline_item_group'
    error:
      type: object
      properties:
        error:
          type: string
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                nullable: true
              code:
                type: string
                nullable: true
              message:
                type: string
            required:
              - message
    baseline_item_filter:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
          description: Baseline item ids; exact match.
        project_item_ids:
          type: array
          items:
            type: integer
          description: Source spec item ids; scoped to this package.
        origin:
          type: array
          items:
            type: string
            enum:
              - package
              - custom
        search:
          type: string
          description: >-
            Case-insensitive substring match on identifier, name and
            description.
        category:
          type: array
          items:
            type: string
          description: Category paths; each matches that path and every path under it.
        package_section_ids:
          type: array
          items:
            type: integer
          description: Section ids; exact match (subsections are not included).
        supplier:
          type: string
          description: Case-insensitive substring match across every supplier field.
        supplier_company_name:
          type: array
          items:
            type: string
          description: Exact match.
        supplier_contact_name:
          type: array
          items:
            type: string
          description: Exact match.
        supplier_contact_email:
          type: array
          items:
            type: string
          description: Exact match.
        supplier_contact_phone:
          type: array
          items:
            type: string
          description: Exact match.
        supplier_address:
          type: array
          items:
            type: string
          description: Exact match.
        remaining:
          type: boolean
          description: >-
            true keeps only rows with something left to order (quantity above
            the procured quantity), e.g. to order everything shown without
            hitting `baseline_item_fully_ordered`.
    package_baseline_item:
      type: object
      description: >-
        One flat, frozen row of a package's baseline. `origin` `package` rows
        are written once when the package is started and never change; `custom`
        rows are managed by users. Category and supplier are stored twice, as
        the id they were picked from (`category_id`, `supplier_id`) and as
        frozen text (category is the full path joined with ` / `). A rename
        never changes the text; `current_category` /
        `current_supplier_company_name` give the live names. Within one package
        an id always has the same text. The section is a reference to the
        package's section; sections are frozen once the package leaves `draft`.
        Fields hidden from the viewer's role (`field_access.baseline_fields`)
        are left out of the object: name, description, unit_type, the supplier
        fields, image, the quantity fields and the price fields.
      properties:
        id:
          type: integer
        package:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
          required:
            - id
            - name
        project_id:
          type: integer
        project_item_id:
          type: integer
          nullable: true
          description: >-
            Source project item for `package` rows, null for `custom` rows.
            Informational only.
        origin:
          type: string
          enum:
            - package
            - custom
        identifier:
          type: string
        name:
          type: string
          nullable: true
        position:
          type: integer
        category_id:
          type: integer
          description: The category the row was committed with. May no longer exist.
        category:
          type: string
          example: Furniture / Seating
          description: >-
            The category path frozen when the row was committed (at Start the
            path at that time; for a custom row the name the package already
            held for the id, else the path at that time).
        current_category:
          type: string
          nullable: true
          example: Furniture / Chairs
          description: >-
            The category's live path; differs from `category` after a rename.
            Null when the category was deleted.
        package_section:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
          required:
            - id
            - name
        description:
          type: string
          nullable: true
        unit_type:
          type: string
          nullable: true
        project_currency:
          type: string
          nullable: true
          example: USD
          description: >-
            ISO 4217 code Cost Price and Client Price are in; null = no
            currency. Starts as its project's currency when the row is committed
            (built or added as a custom row); changing the project's currency
            later doesn't relabel it. Editable until the row is ordered.
            Visible/editable when any price field is (field access).
        supplier_currency:
          type: string
          nullable: true
          example: EUR
          description: >-
            ISO 4217 code Unit Cost Price is in; null = no currency. Set to the
            supplier company's currency, else the project currency, when the row
            is committed and whenever its supplier changes (unless the request
            sends one). Purchase orders created from the baseline default to it.
            Editable until the row is ordered; field access like
            `project_currency`. Amounts are never converted between the two.
        supplier_id:
          type: integer
          nullable: true
          description: >-
            The supplier company the row was committed with; null when it has no
            supplier. May no longer exist.
        supplier_company_name:
          type: string
          nullable: true
          description: >-
            Company on the source item's `supplier` contact, frozen like
            `category`.
        current_supplier_company_name:
          type: string
          nullable: true
          description: >-
            The company's live name; null without a supplier or when the company
            was deleted.
        supplier_contact_name:
          type: string
          nullable: true
          description: >-
            The company's primary person (first by position when none is
            primary), first and last name.
        supplier_contact_email:
          type: string
          nullable: true
        supplier_contact_phone:
          type: string
          nullable: true
        supplier_address:
          type: string
          nullable: true
          description: >-
            The contact's address — street, city, state, postal code and country
            joined with `, `.
        quantity:
          type: string
          nullable: true
          example: '24.00'
          description: >-
            Effective quantity — the pack count when the source item is sold in
            packs, otherwise the plain quantity.
        procured_quantity:
          type: string
          example: '10.00'
          description: >-
            Σ quantity of the purchase order items linked to this row on draft,
            open and closed purchase orders (cancelled and voided ones don't
            count). The ordered quantity, whatever was delivered.
        remaining_quantity:
          type: string
          nullable: true
          description: >-
            quantity − procured_quantity, never below 0 (an order item's
            quantity can be raised past the baseline). Null when the row has no
            quantity. New purchase order items from this row get this quantity.
        unit_cost_price:
          type: string
          nullable: true
        cost_price:
          type: string
          nullable: true
          description: Item total.
        client_price:
          type: string
          nullable: true
          description: Item total.
        image:
          type: object
          nullable: true
          properties:
            id:
              type: integer
            url:
              type: string
            name:
              type: string
              description: >-
                The name the image was uploaded with (the stored name for images
                from before names were kept).
          required:
            - id
            - url
            - name
        created_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - package
        - project_id
        - origin
        - identifier
        - position
        - category_id
        - category
        - current_category
        - package_section
        - created_at
        - updated_at
  securitySchemes:
    apiKey:
      type: apiKey
      name: authorization
      in: header
    workspaceId:
      type: apiKey
      name: X-Workspace-ID
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.