---
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}`

## Request

- Base URL: `https://api.cardda.com`
- URL: `https://api.cardda.com/v1/erp/payouts/purchase_orders/{id}`
- Auth: HTTP bearer

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: Ignored (recalculated from `net_amount_cents`) when the order has a `tax_treatment`.
    - `tax_treatment` 'taxable' | 'exempt' | 'null', nullable: Changing it recalculates `amount_cents` and the item amounts. See `tax_treatment` on create. Sending both `tax_treatment` and `net_amount_cents` as `null` un-declares IVA: the order goes back to "IVA not declared" and keeps its current gross `amount_cents` and item amounts. Clearing only one of the two is rejected. Omitting both leaves the IVA condition unchanged.
    - `net_amount_cents` integer, nullable: Net amount (before IVA). Only accepted on an order that has, or is given, a `tax_treatment`; `amount_cents` is recalculated from it.
    - `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/erp-api.md) - [All operations](https://skmtc.dev/cardda/apis/erp-api/llms.txt) - [OpenAPI document](https://skmtc.dev/cardda/apis/erp-api/revisions/0730ed26bc3c?raw)
