Skip to content

Export purchase orders by issue date

Open .md

POST/v1/api/store/{team_slug}/purchase_order/export

v1Operation ID v1_public_purchase_order_export

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_slugstringrequired

    Your team slug, shown as Team ID next to your API key in Profile.

    • Example your-team

Request body

application/json, required.

  • end_datestring (date-time)required

    ISO 8601 date and time. Issue dates on or before it, compared the same way.

  • start_datestring (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_onlyboolean

    True for JSON rows instead of a CSV file.

    • Default false

Response

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

Errors

  • 401The API key is missing or wrong (unauthenticated).

  • 403You 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.
  • 404Not 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.

  • 422The 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.