# Update packages

`POST /v2/packages`

**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 POST 'https://api.sandbox.bobgo.co.za/v2/packages' \
  -H "content-type: application/json" \
  -H "Authorization: Bearer <API_KEY>" \
  -d '{
  "packages": [
    {
      "id": 2241,
      "name": "Standard sleeve updated",
      "is_default": true,
      "length_cm": 40,
      "height_cm": 5,
      "width_cm": 38
    },
    {
      "id": 2242,
      "name": "Box updated",
      "length_cm": 40,
      "height_cm": 5,
      "width_cm": 38
    }
  ]
}'
```

The same endpoint as [Create packages](packages_create.md). Include a package's
`id` on an entry and that package is updated rather than created, so one call
can mix new and changed packages. An `id` that does not exist is created as a
new package rather than rejected.

Send every field on each entry you update, not only the ones that changed: the
entry replaces the package.

**Changing the default package.** Any entry can take over as the default by
setting `is_default: true`, and the old default is cleared. But if the current
default is in the body and no entry sets `is_default: true`, the call fails
with a `500` and `Cannot unset default package.`, even when all you changed
was its name.
Send `is_default: true` whenever you update the default package.

The fields are the same as on [Create packages](packages_create.md), plus:

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `packages[].id` | integer | yes | The package to update. |

The response is the same bare array as on create, holding only the packages
you sent.
