---
title: "Generate Purchase Orders"
method: POST
path: "/api/v1/materials/generate-purchase-orders"
tags: ["v1", "Materials"]
---

# Generate Purchase Orders

`POST /api/v1/materials/generate-purchase-orders`

## Request

- Base URL: `https://api.jeevyfabrication.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.jeevyfabrication.com/api/v1/materials/generate-purchase-orders`
- Auth: none declared

Generate Purchase Order PDFs for multiple vendors.

For each PO group:
1. Resolves the PO number (minting one via next_vendor_po_number when the
   caller does not supply one) and generates a PO PDF
2. Uploads it, seeds a files row, and creates -- or on reissue updates --
   a procurement_documents row at lifecycle_status='DRAFT'

It writes NOTHING onto manual_material_items: not status, not po_number,
not po_document_id / po_date / vendor_id. The one exception is the
'doc_regenerated' state_history entry appended to the group's
representative item on a reissue.

So at this point the item -> PO association lives ONLY in the document's
metadata.item_ids / metadata.items snapshot; nothing on the item rows
points back to the document (JEEVY-1349). The caller is what advances
items: RaisePOConfirmModal PATCHes po_number and qs_state after this
returns, and /backfill-po-numbers repairs items that missed it. See the
NOTE at the end of the per-group loop below for why the status transition
is deliberately not performed here.

## Request body

- GeneratePurchaseOrdersBody
  - `project_id` integer, nullable
  - `purchase_orders` PurchaseOrderGroup[], required
    - `vendor_id` integer, required
    - `po_number` string, nullable
    - `po_date` string, nullable
    - `item_ids` integer[], required
    - `misc_items` PoMiscItem[], nullable
      - `description` string, required
      - `unit_price` number
    - `written_client_name` string, nullable: Display name for the buyer (shop) block on the PDF; defaults to shop name from DB.
    - `terms_and_conditions` string, nullable
    - `line_quantities` PoLineQuantity[], nullable
      - `item_id` integer, required
      - `quantity` number, nullable
      - `unit_price` number, nullable
    - `selected_dba_name` string, nullable: DBA name selected for this vendor on this PO; appears in the vendor block.
    - `include_expected_delivery` boolean, nullable: If true, add an 'Expected Delivery' column to the PO PDF showing lead time labels.
    - `our_poc` OurPoc, nullable: User-edited 'our side' point of contact sent with a generation request.
      - `name` string, nullable
      - `email` string, email, nullable
      - `phone` string, nullable
    - `delivery_address` string, nullable: Where the vendor ships this order. Stored on the PO header; blank keeps the stored value.
    - `ship_method` string, nullable: Carrier or service the vendor should use (e.g. UPS Red). Stored on the PO header.
    - `attachments` object[], nullable
  - `reissue` boolean
  - `preview` boolean

## Response `200`

Successful Response

- object

## Other responses

- `422`: Validation Error

## Changes

- **2026-11-10** `41b136ff38ef`: 1 info
  - added the new optional request property `purchase_orders/items/attachments`
- **2026-11-09** `d9ef00c0253a`: 3 info
  - added the new optional request property `preview`
  - added the new optional request property `purchase_orders/items/delivery_address`
  - added the new optional request property `purchase_orders/items/ship_method`

[Operation history](https://skmtc.dev/jeevyfabrication/apis/bom-generation-api/changes/api/v1/materials/generate-purchase-orders/post.md)

---

[API](https://skmtc.dev/jeevyfabrication/apis/bom-generation-api.md) - [All operations](https://skmtc.dev/jeevyfabrication/apis/bom-generation-api/llms.txt) - [OpenAPI document](https://skmtc.dev/jeevyfabrication/apis/bom-generation-api/revisions/ad9a01abeac9?raw)
