# Export purchase orders by issue date

```http
POST https://secure.yoprint.com/v1/api/store/{team_slug}/purchase_order/export
```

- API version: v1
- Operation ID: `v1_public_purchase_order_export`
- Section: Purchasing › [Purchase orders](https://developer.yoprint.com/reference/purchase-orders.md)
- Web page: https://developer.yoprint.com/reference/purchase-orders/v1-purchase-order-export/
- Authentication: `Authorization: Bearer YOUR_API_KEY`

Exports the team's purchase orders whose issue date falls between `start_date` and `end_date`.

- By default the answer is a CSV file (`purchase_order_export_<time>.csv`) with these columns: `purchase_order_id`, `issue_date`, `due_date`, `vendor`, `billing_address_label`, `warehouse_label`, `creator`, `status`, `received_subtotal`, `received_tax`, `received_total`, `ordered_subtotal`, `ordered_tax`, `ordered_total`, `related_orders`, `related_customers`, `internal_note`, `vendor_note`.
- With `list_only: true` the same purchase orders come back as JSON rows instead.

For the CSV, no purchase order in the range is a 422; with `list_only: true` it is an empty `data` list. The Download Center export (`data_export/export_purchase_order_list`) builds the same kind of file in the background.

## Permission

Needs the View Reports permission.

## Business rules

- Covers every purchase order of the team in the range, whoever it is assigned to.

## Path parameters

- `team_slug` (string, required): Your team slug, shown as Team ID next to your API key in Profile. Example `your-team`.

## Request body

Content type `application/json`, required.

Fields:

- `end_date` (string (date-time), required): ISO 8601 date and time. Issue dates on or before it, compared the same way.
- `start_date` (string (date-time), required): ISO 8601 date and time. Issue dates on or after it. The offset is not applied: the date and time are compared as written with issue dates kept in UTC, so send UTC times.
- `list_only` (boolean, optional): True for JSON rows instead of a CSV file. Default `false`.

### Example request

```bash
curl -X POST 'https://secure.yoprint.com/v1/api/store/your-team/purchase_order/export' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'X-Yoprint-Decimal-Format: exact-v1' \
  -H 'Content-Type: application/json' \
  -d '{
    "end_date": "2026-10-31T23:59:59+00:00",
    "list_only": true,
    "start_date": "2026-10-01T00:00:00+00:00"
  }'
```

## Response

`200` A CSV file by default; JSON rows with `list_only: true`.

Fields:

- `data` (array of objects, required)
  - Each item:
    - `ordered_total` (string, required)
    - `purchase_order_id` (string | integer, required): The purchase order number people see, not its id.
    - `status` (string | null, required)
    - `vendor` (string | null, required): The vendor's name.
    - `billing_address_label` (string | null, optional)
    - `creator` (string, optional): Who created it, or an empty string.
    - `due_date` (string, optional): `YYYY-MM-DD` in the team's time zone, or an empty string.
    - `internal_note` (string | null, optional)
    - `issue_date` (string, optional): `YYYY-MM-DD` in the team's time zone, or an empty string.
    - `name` (string | null, optional)
    - `ordered_subtotal` (string, optional): A decimal string with two decimals, such as `"120.00"`; parse it as a decimal.
    - `ordered_tax` (string, optional)
    - `received_subtotal` (string, optional): A decimal string with two decimals, such as `"125.00"`; parse it as a decimal.
    - `received_tax` (string, optional)
    - `received_total` (string, optional)
    - `related_customers` (string | null, optional): Their customers, one per line.
    - `related_orders` (string | null, optional): Linked sales order numbers, one per line.
    - `vendor_note` (string | null, optional)
    - `warehouse_label` (string | null, optional)
- `status` (integer, required)
- `success` (boolean, required)

Example response:

```json
{
  "data": [
    {
      "billing_address_label": "Head office",
      "creator": "Alex Rivera",
      "due_date": "2026-10-19",
      "internal_note": null,
      "issue_date": "2026-10-05",
      "name": null,
      "ordered_subtotal": "120.00",
      "ordered_tax": "0.00",
      "ordered_total": "120.00",
      "purchase_order_id": "PO0042",
      "received_subtotal": "120.00",
      "received_tax": "0.00",
      "received_total": "120.00",
      "related_customers": "Northwind Apparel",
      "related_orders": "SO1001",
      "status": "Received",
      "vendor": "Example Blanks Co",
      "vendor_note": null,
      "warehouse_label": "Main warehouse"
    }
  ],
  "status": 200,
  "success": true
}
```

## Errors

- `401` The API key is missing or wrong (`unauthenticated`).
- `403` You are not allowed to do this. `api_access_not_in_plan`: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only `{"message": "Insufficient Permission"}`. Other refusals use the error envelope, with `unauthorized` or `user_is_not_authorized`.
  - When: Your role cannot view reports. This 403 has a short body, `{"message": "Insufficient Permission"}`, with no `success` or `error`. Fix: Ask a team owner for View Reports.
- `404` Not found. `page_not_found`: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. `code: null`, with a message that starts "No query results for": there is no record with that id.
- `422` The request was refused and changed nothing. `validation_failed` lists what to fix in `error.fields`; other codes name a business rule, explained in `error.message`. A few checks answer with only `{"message": "..."}`. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer `connect_timeout` ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.
  - When: CSV only: no purchase order has an issue date in the range (`error.code` `purchase_order_export_error`, "Purchase Order not found"). With `list_only: true` the answer is an empty list instead. Fix: Widen the range.
  - When: A date is missing or not ISO 8601. `error.code` is `validation_failed`. Fix: Send both dates.

## Related

- [Export purchase orders in a date range to CSV](https://developer.yoprint.com/reference/data-exports/v1-data-export-export-purchase-order-list.md): `POST /v1/api/store/{team_slug}/data_export/export_purchase_order_list`
- [List a purchase order's history](https://developer.yoprint.com/reference/purchase-orders/v1-purchase-order-history.md): `GET /v1/api/store/{team_slug}/purchase_order/{hash_id}/history`
