> For the complete documentation index, see [llms.txt](https://docs.ems.com.vn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ems.com.vn/en/manage-shipment/create-shipment.md).

# Create shipment

## /shipments

<mark style="color:green;">`POST`</mark>&#x20;

#### Query Parameters

| Name            | Type   | Description                           |
| --------------- | ------ | ------------------------------------- |
| merchant\_token | string | Token is created in management system |

#### Headers

| Name         | Type   | Description      |
| ------------ | ------ | ---------------- |
| Accept       | string | application/json |
| Content-Type | string | application/json |

#### Request Body

| Name                  | Type    | Description                                                                      |
| --------------------- | ------- | -------------------------------------------------------------------------------- |
| warehouse\_code       | string  | Warehouse code                                                                   |
| customer\_code        | string  | Customer code (if any)                                                           |
| to\_name              | string  | Recipient                                                                        |
| to\_phone             | string  | Recipient's phone number                                                         |
| to\_province          | string  | Recipient's province code                                                        |
| to\_district          | string  | Recipient's district code                                                        |
| to\_ward              | string  | Recipient's ward code                                                            |
| to\_address           | string  | Recipient's address                                                              |
| order\_code           | string  | Order code                                                                       |
| money\_collect        | string  | Total money collect                                                              |
| description           | string  | Description                                                                      |
| payment\_config       | boolean | <p>Set 1 if recipient pays shipping fee<br>Set 0 if sender pays shipping fee</p> |
| service\_type         | string  | Main services                                                                    |
| addition\_service     | array   | Additonal services (array additional services ex: \['COD', 'PTT',...])           |
| can\_check            | boolean | Can check package or not                                                         |
| is\_fragile           | boolean | Fragile goods                                                                    |
| is\_related\_product  | boolean | Shipment inlcudes products at inventory                                          |
| product\_name         | string  | Product name (not required if order does not include related products)           |
| total\_amount         | string  | Total amount (not required if order does not include related products)           |
| total\_quantity       | integer | Total quantity (not required if order does not included related products)        |
| total\_weight         | integer | Total weight (not required if order does not include related products)           |
| items                 | array   | Array products (required if order includes related products)                     |
| items.\*.product\_sku | string  | Related product SKU                                                              |
| items.\*.quantity     | integer | Related product quantity                                                         |

{% tabs %}
{% tab title="201 Create shipment successfully." %}

```javascript
{
    "code": "SM0000000001",
    "warehouse_code": "1",
    "order_code": "1",
    "state": "waitForPick",
    "ref_code": "SM0000000001",
    "product_name": "San pham A",
    "total_amount": "100000.00",
    "total_quantity": 10,
    "total_weight": 10,
    "money_collect": "100000.00",
    "total_fee": "0.00",
    "description": null,
    "can_check": 0,
    "is_fragile": 0,
    "service_type": 0,
    "addition_service": "",
    "payment_config": 1,
    "estimated_delivery_time": 0,
    "created_at": "2019-04-04T18:07:11.000000Z"
}
```

{% endtab %}
{% endtabs %}

{% hint style="danger" %}
If **is\_related\_product: true** then some fields below are requied: **items, items.\*.product\_sku, items.\*.quantity**.&#x20;
{% endhint %}

{% hint style="danger" %}
If **is\_related\_product: false** then some fields below are required:  **product\_name, total\_amount, total\_quantity, total\_weight.**
{% endhint %}

#### Sample data request

{% tabs %}
{% tab title="is\_related\_product: false " %}

```php
{
	"warehouse_code": "WH0000000009",
	"to_name": "Nguyen Van A",
	"to_phone": "01234567898",
	"to_province": "88",
	"to_district": "8843",
	"to_ward": "88435",
	"to_address": "address",
	"order_code": "ma_don_hang",
	"money_collect": 100000,
	"description": "description",
	"payment_config": 1,
	"service_type": "ECOD",
	"can_check": 1,
	"is_fragile":true,
	"is_related_product":false,
	"product_name":"sản phẩm 1",
	"total_amount":17,
	"total_quantity":19,
	"total_weight":19
}
```

{% endtab %}

{% tab title="is\_related\_product: true " %}

```php
{
  "warehouse_code": "WH0000000002",
  "to_name":"a",
  "to_phone":"0321461132",
  "to_province":"10",
  "to_district":"1100",
  "to_ward":"11170",
  "to_address":"sss",
  "order_code":"HD768876",
  "money_collect":400000,
  "description":"qq",
  "payment_config":1,
  "total_amount":400000,
  "service_type": "ECOD",
  "can_check": false, 
  "is_fragile": true,
  "is_related_product":true,
  "items":[{"product_sku":"SP000001","quantity":9}, 
          {"product_sku":"SP000002","quantity":1}],
  "product_name": "Sản phẩm 1",
  "total_quantity": 1,
  "total_weight": 500
}
```

{% endtab %}
{% endtabs %}
