# Update a shipment

To [update](https://docs.commercelayer.io/core/updating-resources) an existing shipment, send a `PATCH` request to the `/api/shipments/:id` endpoint, where `id` is the ID of the resource that you want to update.

Here below the list of all the possible arguments that you can pass with the request body.

## Request

**PATCH** <https://yourdomain.commercelayer.io/api/shipments/:id>

### Arguments

| Body Parameter                               | Type      | Required |
| -------------------------------------------- | --------- | -------- |
| **type**                                     | `string`  | Required |
| **id**                                       | `string`  | Required |
| attributes.**number**                        | `string`  | Optional |
| attributes.**\_upcoming**                    | `boolean` | Optional |
| attributes.**\_cancel**                      | `boolean` | Optional |
| attributes.**\_on\_hold**                    | `boolean` | Optional |
| attributes.**\_picking**                     | `boolean` | Optional |
| attributes.**\_packing**                     | `boolean` | Optional |
| attributes.**\_ready\_to\_ship**             | `boolean` | Optional |
| attributes.**\_ship**                        | `boolean` | Optional |
| attributes.**\_deliver**                     | `boolean` | Optional |
| attributes.**\_reserve\_stock**              | `boolean` | Optional |
| attributes.**\_release\_stock**              | `boolean` | Optional |
| attributes.**\_decrement\_stock**            | `boolean` | Optional |
| attributes.**\_get\_rates**                  | `boolean` | Optional |
| attributes.**selected\_rate\_id**            | `string`  | Optional |
| attributes.**\_purchase**                    | `boolean` | Optional |
| attributes.**\_add\_tags**                   | `string`  | Optional |
| attributes.**\_remove\_tags**                | `string`  | Optional |
| attributes.**reference**                     | `string`  | Optional |
| attributes.**reference\_origin**             | `string`  | Optional |
| attributes.**metadata**                      | `object`  | Optional |
| relationships.**shipping\_category**         | `object`  | Optional |
| relationships.**inventory\_stock\_location** | `object`  | Optional |
| relationships.**shipping\_address**          | `object`  | Optional |
| relationships.**shipping\_method**           | `object`  | Optional |
| relationships.**tags**                       | `array`   | Optional |

### Example

{% tabs %}
{% tab title="Request" %}
The following request updates the shipment identified by the ID "XAyRWNUzyN":

```shell
curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "shipments",
    "id": "xYZkjABcde",
    "attributes": {
      "_upcoming": true
    },
    "relationships": {
      "shipping_category": {
        "data": {
          "type": "shipping_categories",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `200 OK` status code, returning the updated resource object:

```json
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "shipments",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN"
    },
    "attributes": {
      "number": "#1234/S/001",
      "status": "draft",
      "currency_code": "EUR",
      "cost_amount_cents": 1000,
      "cost_amount_float": 10.0,
      "formatted_cost_amount": "€10,00",
      "skus_count": 2,
      "selected_rate_id": "rate_f89e4663c3ed47ee94d37763f6d21d54",
      "rates": [
        {
          "id": "rate_f89e4663c3ed47ee94d37763f6d21d54",
          "rate": "45.59",
          "carrier": "DHLExpress",
          "service": "MedicalExpress"
        }
      ],
      "purchase_error_code": "SHIPMENT.POSTAGE.FAILURE",
      "purchase_error_message": "Account not allowed for this service.",
      "get_rates_errors": [
        {
          "carrier": "DHLExpress",
          "message": "to_address.postal_code: Shorter than minimum length 3",
          "type": "rate_error"
        }
      ],
      "get_rates_started_at": "2018-01-01T12:00:00.000Z",
      "get_rates_completed_at": "2018-01-01T12:00:00.000Z",
      "purchase_started_at": "2018-01-01T12:00:00.000Z",
      "purchase_completed_at": "2018-01-01T12:00:00.000Z",
      "purchase_failed_at": "2018-01-01T12:00:00.000Z",
      "on_hold_at": "2018-01-01T12:00:00.000Z",
      "picking_at": "2018-01-01T12:00:00.000Z",
      "packing_at": "2018-01-01T12:00:00.000Z",
      "ready_to_ship_at": "2018-01-01T12:00:00.000Z",
      "shipped_at": "2018-01-01T12:00:00.000Z",
      "delivered_at": "2018-01-01T12:00:00.000Z",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "order": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/order",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/order"
        }
      },
      "shipping_category": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/shipping_category",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/shipping_category"
        }
      },
      "inventory_stock_location": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/inventory_stock_location",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/inventory_stock_location"
        }
      },
      "stock_location": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/stock_location",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/stock_location"
        }
      },
      "origin_address": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/origin_address",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/origin_address"
        }
      },
      "shipping_address": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/shipping_address",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/shipping_address"
        }
      },
      "shipping_method": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/shipping_method",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/shipping_method"
        }
      },
      "delivery_lead_time": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/delivery_lead_time",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/delivery_lead_time"
        }
      },
      "pickup": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/pickup",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/pickup"
        }
      },
      "stock_line_items": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/stock_line_items",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/stock_line_items"
        }
      },
      "stock_transfers": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/stock_transfers",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/stock_transfers"
        }
      },
      "line_items": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/line_items",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/line_items"
        }
      },
      "available_shipping_methods": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/available_shipping_methods",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/available_shipping_methods"
        }
      },
      "carrier_accounts": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/carrier_accounts",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/carrier_accounts"
        }
      },
      "parcels": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/parcels",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/parcels"
        }
      },
      "attachments": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/attachments",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/attachments"
        }
      },
      "events": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/events",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/events"
        }
      },
      "tags": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/tags",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/tags"
        }
      },
      "versions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/versions",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/versions"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/shipments/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "mode": "test",
      "organization_id": "xRRkjDFafe",
      "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
    }
  }
}
```

{% endtab %}
{% endtabs %}
