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

# Generate purchase orders report

> Async pdf export of the purchase orders list (`GET /purchase_orders`), filtered and ordered like it. Renders `js_report_template` through jsreport with the fields picked in `used_fields` (see `schema`). pdf only. With `project_id` the rows are that project's (any project of the workspace) and the report broadcasts on its project stream; without, on the workspace stream. Needs `reports_create` and `procurement_view`.



## OpenAPI

````yaml /openapi.yaml post /reports/purchase_orders_list
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:
  /reports/purchase_orders_list:
    post:
      tags:
        - Report
      summary: Generate purchase orders report
      description: >-
        Async pdf export of the purchase orders list (`GET /purchase_orders`),
        filtered and ordered like it. Renders `js_report_template` through
        jsreport with the fields picked in `used_fields` (see `schema`). pdf
        only. With `project_id` the rows are that project's (any project of the
        workspace) and the report broadcasts on its project stream; without, on
        the workspace stream. Needs `reports_create` and `procurement_view`.
      operationId: reports/purchase_orders_list#create
      parameters:
        - name: X-Workspace-ID
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/requestBodyReportPurchaseOrdersListCreate'
        required: true
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/report'
        '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:
    requestBodyReportPurchaseOrdersListCreate:
      type: object
      properties:
        report_extension:
          type: string
          enum:
            - pdf
          description: pdf only (the default); anything else is `report_extension_invalid`.
        project_id:
          type: integer
          description: >-
            Optional: the project whose procurement tab is exporting. Narrows
            the rows to it (overriding `filter.project_ids`) and fills the
            `project` record. Any project of the workspace (no membership
            needed).
        filter:
          type: object
          description: >-
            The Purchase orders list filter (`GET /purchase_orders` params).
            Voided orders are left out unless `status` asks for them.
          properties:
            search:
              type: string
            supplier:
              type: string
            status:
              type: array
              items:
                type: string
                enum:
                  - draft
                  - open
                  - closed
                  - cancelled
                  - voided
            supplier_company_name:
              type: array
              items:
                type: string
            project_ids:
              type: array
              items:
                type: integer
            supplier_ids:
              type: array
              items:
                type: integer
            purchase_order_items:
              type: object
              properties:
                package_ids:
                  type: array
                  items:
                    type: integer
                package_section_ids:
                  type: array
                  items:
                    type: integer
                category_ids:
                  type: array
                  items:
                    type: integer
        per_page:
          type: integer
          description: >-
            Internal fetch batch size while building the report; does not limit
            the report's total row count. Defaults to 50, silently clamped to a
            max of 100.
        used_fields:
          type: object
          description: >-
            Selects which schema-defined record and collection fields to resolve
            (see the kind's `schema`).
          properties:
            records:
              type: array
              items:
                type: object
                properties:
                  record_path:
                    type: string
                  fields:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                      required:
                        - path
                required:
                  - record_path
            collections:
              type: array
              items:
                type: object
                properties:
                  collection_path:
                    type: string
                  fields:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                      required:
                        - path
                required:
                  - collection_path
        js_report_template:
          type: object
          properties:
            content:
              type: string
            engine:
              type: string
              enum:
                - handlebars
            recipe:
              type: string
              enum:
                - chrome-pdf
            chrome:
              type: object
    report:
      type: object
      properties:
        id:
          type: integer
        status:
          type: string
          enum:
            - processing
            - completed
            - failed
        report_kind:
          type: string
          enum:
            - projects_list
            - project_items_list
            - product_items_list
            - cross_project_items_list
            - project_items_matrix
            - package_baseline_items_list
            - cross_project_baseline_items_list
            - purchase_orders_list
            - goods_receipts_list
            - supplier_invoices_list
            - purchase_order_record
            - supplier_invoice_record
            - goods_receipt_record
        report_extension:
          type: string
          enum:
            - xlsx
            - pdf
        job_id:
          type: string
          format: uuid
        project_id:
          type: integer
          nullable: true
        project:
          type: object
          nullable: true
          properties:
            id:
              type: integer
            name:
              type: string
          required:
            - id
            - name
        file_url:
          type: string
          nullable: true
        error_message:
          type: string
          nullable: true
          description: Free-text failure reason (only set for failed reports)
        created_at:
          type: string
          format: date-time
      required:
        - id
        - status
        - report_kind
        - report_extension
        - job_id
        - project
        - error_message
        - created_at
    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
  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.