# Update an order

`PATCH /v2/orders`

**Base URLs:**

- Sandbox: `https://api.sandbox.bobgo.co.za`
- Production: `https://api.bobgo.co.za`

**Authentication:** Bearer token required (see the Authentication page).

## Example request

```bash
curl -X PATCH 'https://api.sandbox.bobgo.co.za/v2/orders' \
  -H "content-type: application/json" \
  -H "Authorization: Bearer <API_KEY>" \
  -d '{
  "id": 123,
  "payment_status": "paid"
}'
```

Updates an existing order. Send the `id` and only the fields that changed;
anything you leave out is left alone. The order lines are the exception, see
`order_items` below.

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | integer | yes | The Bob Go order id, from the create response. An id that is not on your account returns `404`. |

Everything else is optional and matches the fields on
[`POST /v2/orders`](order_create.md), with these exceptions:

- **`order_items` only applies to orders from your manual, CSV or API
  channel.** On an order from a store integration it is ignored.
- **`order_items` replaces the whole list.** Lines you leave out are deleted and
  lines without an `id`, or with one that is not on this order, are added as
  new lines, so send every line you want to keep. You cannot remove every line.
- **Send each line you keep in full.** Every field on it is overwritten, so a
  field you leave out is cleared: `unit_price` becomes 0, the image goes, and
  without `qty` the line counts as quantity 0, which deletes it, or fails if
  any of it is fulfilled. `description` is the exception: a line without one is
  rejected with a `400`.
- **`channel_image_url` is not copied to Bob Go on update**, as it is on create:
  `image_url` serves the URL you send.
- **`status`** can only be set to `completed` or `cancelled`. Other values are
  ignored.
- **`buyer_selected_shipping_cost` and `buyer_selected_shipping_method`** only
  change on orders from your manual or CSV channel.

A cancelled order cannot be changed.

The common case is payment: an order created `unpaid` and patched to `paid`
once the gateway settles. Rules that only act on paid orders will then pick it
up.
