# Delete a sales order or quote

```http
DELETE https://secure.yoprint.com/v2/api/store/{team_slug}/v2/sales_order/{order_unique_key}
```

- API version: v2
- Operation ID: `v2_public_order_destroy`
- Section: Sales › [Sales orders](https://developer.yoprint.com/reference/sales-orders.md)
- Web page: https://developer.yoprint.com/reference/sales-orders/v2-order-destroy/
- Authentication: `Authorization: Bearer YOUR_API_KEY`

Deletes a sales order or quote. You can bring it back with Restore.

Deleting a published sales order also undoes its money and stock: payments on it are moved to the customer's credit (not on Shopify orders), its stock workflows are cancelled and its stock reservations released. Its invoices, jobs, shipments and messages are deleted with it, and its Shippo labels are voided.

Deleting an order that is already deleted succeeds and changes nothing. The answer has no data.

`{order_unique_key}` is the sales order or quote `id` (for example `V4keXwwxMQyXw7`) or its `unique_key` (it starts with `ord_`). The order number people see, such as SO1001, is not accepted here.

## Permission

Needs permission to edit this sales order or quote:

- The team owner
- A role with `update_all_order`
- A role with `update_self_order`, when the order was created by or is assigned to the API key's user
- The person who created a draft, with `create_order`

Quotes use the same sales order permissions.

## Business rules

- A Shopify-linked draft can't be deleted until it is published: "Publish this order before deleting a Shopify-linked order."
- A draft with a shipping label bought through YoPrint can't be deleted: "Publish this order before deleting an order with a shipping label."
- An order (other than a Shopify order) can't be deleted while a payment holding money on it is frozen by an open dispute or review: 422 `customer_payment_disputed_funds_unavailable` ("This order can't be deleted while a payment on it is under dispute. You can delete it once <provider> decides.") or `invoice_payment_funding_withheld` ("This order can't be deleted while a payment on it is under review. You can delete it once the review is finished."), with `error.reason`, `error.provider` and `error.provider_label`. Nothing changes.

## Side effects

- Moves every payment on a published order to the customer's credit (money from a Customer Portal payment goes back to that payment's credit). Shopify orders keep their payments.
- Cancels stock workflows and releases stock reservations.
- Deletes the order's invoices, jobs, shipments, packages and messages.
- Voids Shippo labels bought for the order and asks Shippo for their refund (a provider call).
- On a Shopify order, cancels the fulfillments YoPrint created in Shopify.
- Sends the `order.deleted` webhook (`quote.deleted` for a quote), drafts included, and on a published order updates the customer's totals.
- When the team syncs to QuickBooks Online automatically, queues a sync that removes the order's payments and invoices from QuickBooks.

## Path parameters

- `team_slug` (string, required): Your team slug, shown as Team ID next to your API key in Profile. Example `your-team`.
- `order_unique_key` (string, required): The sales order's or quote's `id` (a hash id), or its `unique_key` (`ord_…`). The order number (`scoped_id`) does not work. Example `V4keXwwxMQyXw7`.

## Request body

This operation takes no request body.

### Example request

```bash
curl -X DELETE 'https://secure.yoprint.com/v2/api/store/your-team/v2/sales_order/V4keXwwxMQyXw7' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'X-Yoprint-Decimal-Format: exact-v1'
```

## Response

`200` Successful response.

Fields:

- `data` (null, required): No data.
- `status` (integer, required)
- `success` (boolean, required)

Example response:

```json
{
  "data": null,
  "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: The API key's role can't edit this order. Fix: Ask the team owner for sales order edit permission.
- `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.
  - When: No such order in this team. Fix: Check the 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: A Shopify-linked draft, or a draft with a bought shipping label. Fix: Publish it first, then delete.
  - When: A payment on the order is frozen by an open dispute or review (`customer_payment_disputed_funds_unavailable` or `invoice_payment_funding_withheld`). Fix: Wait for the provider's decision, then delete.

## Related

- [Restore a deleted sales order or quote](https://developer.yoprint.com/reference/sales-orders/v2-order-restore.md): `PATCH /v2/api/store/{team_slug}/v2/sales_order/{order_unique_key}/restore`
- [Move all of an order's payments to customer credit](https://developer.yoprint.com/reference/payments/v2-sales-order-credit-refund-all-to-customer-credit.md): `PATCH /v2/api/store/{team_slug}/v2/sales_order/{hash_id}/credit/refund_all_to_customer_credit`
