---
title: "Update purchase order"
method: PATCH
path: "/v1/erp/payouts/purchase_orders/{id}"
tags: ["Purchase Order"]
---

# Update purchase order

`PATCH /v1/erp/payouts/purchase_orders/{id}`

Updates an existing purchase order's description, amount, currency, or items. When the total amount changes, item amounts are automatically recalculated based on their percentages.

## Important Notes
- Purchase order must not be approved or completed
- User must have admin or owner role
- Item percentages must sum to 100% after update
- When amount_cents changes, all item amounts are recalculated
- Items can be created, updated, or deleted using nested attributes

## Authorization
- User must be admin or owner of the company
- Purchase order cannot be approved or completed

## Nested Item Updates
You can create, update, or delete items in the same request:
- **Create**: Include item without `id` field
- **Update**: Include item with existing `id` field
- **Delete**: Include item with `id` and `_destroy: true`

## Path parameters

- `id` string, uuid, required

## Parameters

- `#/paths/~1v1~1erp~1payouts~1rules/get/parameters/0` — unresolved $ref

## Request body

- object
  - `purchase_order` object
    - `description` string
    - `amount_cents` integer
    - `currency` 'CLP' | 'UF' | 'USD'
    - `items_attributes` object[]
      - `id` string, uuid — Include for update/delete, omit for create
      - `number` integer — Order number (unique within the purchase order)
      - `name` string
      - `percentage` number
      - `_destroy` boolean — Set to true to delete this item

## Response `200`

Purchase order updated successfully

- Schema — unresolved $ref

## Other responses

- `401` — Unauthorized — invalid/missing authentication token, or the caller is not authorized to update this purchase order (Pundit policy). **The response body is empty** (Pundit renders nothing); branch on the status code, not the body.
- `404` — Purchase order not found (also returned when the `company-id` header points to a company the caller cannot access, or the id is not scoped to it).
- `422` — Validation errors

---

[API](https://skmtc.dev/cardda/apis/banking-api.md) · [All operations](https://skmtc.dev/cardda/apis/banking-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/cardda/banking-api/revisions/ff1aeb3fda8b/schema)
