# Shipment Resource

Shipment resources are read-only by default.

### **Attention**

Shipment resources are read-only by default. Please contact us at [max.mustermann@example.com](mailto:max.mustermann@example.com) if you need write permissions.

---

## Get Shipments

GET /api/shipments.json

- **GET /api/shipments.json**will return the first 150 (default limit) items. You can increase the limit to a maximum of 250 items.

**Example:**

```bash
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X GET \
https://shop_subdomain.versacommerce.de/api/shipments.json
```

```
Status: 200 OK

[
  {
    "shipment": {
      "carrier_name": "DHL",
      "created_at": "2013-04-24",
      "id": 100,
      "order_id": 1000,
      "partial_delivery": false,
      "pickup_at": "2000-01-01T14:00:00Z",
      "pickup_on": "2013-04-24",
      "status": "delivered",
      "tracking_code": "12345"
    }
  },
  {
    "shipment": {
      "carrier_name": "DHL",
      "created_at": "2013-10-11",
      "id": 101,
      "order_id": 1001,
      "partial_delivery": false,
      "pickup_at": "2000-01-01T14:00:00Z",
      "pickup_on": "2013-10-11",
      "status": "undelivered",
      "tracking_code": "123456"
    }
  }
]
```

---

## Get Shipments for Order

GET /api/orders/:oder_id/shipments.json

- **GET /api/orders/:oder_id/shipments.json** will return the shipments for the specified order.

**Example:**

```
curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X GET \
https://shop_subdomain.versacommerce.de/api/orders/:oder_id/shipments.json
```

```
Status: 200 OK

[
  {
    "shipment": {
      "carrier_name": "Spedition",
      "created_at": "2013-10-11",
      "id": 100,
      "order_id": 1000,
      "partial_delivery": true,
      "pickup_at": "2000-01-01T08:00:00Z",
      "pickup_on": "2013-10-14",
      "status": "delivered",
      "tracking_code": "123..."
    }
  },
  {
    "shipment": {
      "carrier_name": "DHL",
      "created_at": "2013-10-11",
      "id": 101,
      "order_id": 1000,
      "partial_delivery": false,
      "pickup_at": "2000-01-01T08:00:00Z",
      "pickup_on": "2013-10-14",
      "status": "delivered",
      "tracking_code": "456..."
    }
  }
]
```

This will return  **200 OK** with the current JSON representation of the shipments array for the specified order.

---

## Get Shipment for Order

GET /api/orders/:oder_id/shipments/:shipment_id.json

- **GET /api/orders/:oder_id/shipments/:shipment_id.json** will return the shipment for the specified order.

**Example:**

```
curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X GET \
https://shop_subdomain.versacommerce.de/api/orders/:oder_id/shipments/:shipment_id.json
```

```
Status: 200 OK

{
  "shipment": {
    "carrier_name": "Spedition",
    "created_at": "2013-10-11",
    "id": 100,
    "order_id": 1000,
    "partial_delivery": true,
    "pickup_at": "2000-01-01T08:00:00Z",
    "pickup_on": "2013-10-14",
    "status": "delivered",
    "tracking_code": "123..."
  }
}
```

---

## Update Shipment for Order

POST /api/shipments.json

- **POST /api/shipments.json** lets you create a shipment for the specified order.
- If you set "deliver" to true, the order will be marked as shipped

```
curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u api:YOUR_API_KEY \
-X POST \
-d \
'{
"shipment": {
"order_id": 963698,
"item_ids": [1575436],
"tracking_code": "123456789",
"tracking_url": "https://gls.com/123456789%22,
"origin_name": "WAKUE",
"origin_id": "-1",
"deliver": "true"
}
}' \
https://shop-subdomain.versacommerce.de/api/shipments.json
```
