**版本：202201**

# 创建履约

**POST** `/openapi/2022-01/orders/:order_id/fulfillments`

为指定订单的商品项创建履约，并更新发货信息。

## 请求

**Path参数**

- `order_id` string (required)

  订单 ID。

**application/json**

**请求体 | 示例**

**请求体**

- `line_item_ids` string[]

  Order's Line Item IDs, If you need split the quantity on different fulfillments on same product, leave this field empty, and use line_items below instead.
- `line_items` object[]

  Array of line item id and the quantity of each item, If you need split the quantity on different fulfillments on same product, you can use this field, if you don't, you can leave this field empty , and use the line_item_ids instead.

  *   Array [

  - `id` string (required)

    The order's line item ID
  - `ship_quantity` int32 (required)

    The order's product quantity, `0` means all of the quantity will ship together.
  *   ]
- `tracking_number` string (required)

  Tracking Number, for example: `DHL1231232113`
- `tracking_company` string

  Tracking Company, for example: `DHL`
- `tracking_company_code` string

  Tracking Company's code, for example: `dhl`
- `tracking_url` string

  Tracking Url

```json
{
  "line_item_ids": [
    "string"
  ],
  "line_items": [
    {
      "id": "string",
      "ship_quantity": 0
    }
  ],
  "tracking_number": "string",
  "tracking_company": "string",
  "tracking_company_code": "string",
  "tracking_url": "string"
}
```

## 响应

**200 | 404 | 422**

200

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `fulfillment` object

  - `id` string

    **示例：** `51c7dd5d-8f49-40c3-b2c1-5dfdeef9946d`
  - `order_id` string

    **示例：** `633130-00000007`
  - `status` string

    **示例：** `shipped`
  - `tracking_company` string

    **示例：** `燕文物流`
  - `tracking_number` string

    **示例：** `11111111111`
  - `tracking_company_code` string

    **示例：** `DJ-11343`
  - `tracking_url` string

    **示例：**
  - `created_at` string

    **示例：** `2024-04-22T08:37:12Z`
  - `updated_at` string

    **示例：** `2024-04-22T08:37:12Z`
  - `line_items` object[]

    *   Array [

    - `id` string

      **示例：** `ed8af005-1f4e-42d1-859d-99b0fd420781`
    - `product_id` string

      **示例：** `a1a88be0-a1d4-47e4-a2f2-ba6e131cf447`
    - `variant_id` string

      **示例：** `a7175820-36b3-4fc6-9baf-51e3035242ba`
    - `variant_title` string

      **示例：** `L-blue-T`
    - `product_title` string

      **示例：** `shirt`
    - `product_handle` string

      **示例：** `shirt`
    - `quantity` integer

      **默认值：** `0`

      **示例：** `1`
    - `note` string

      **示例：**
    - `fulfillment_status` string

      **示例：** `shipped`
    - `sku` string

      **示例：** `T-M-L-blue-T-A001008`
    - `weight_unit` string

      **示例：** `kg`
    - `vendor` string

      **示例：** `shoplazza`
    - `product_url` string

      **示例：** `/products/shirt`
    - `compare_at_price` string

      **示例：** `97.00`
    - `image` string

      **示例：** `//cdn.shoplazza.com/ccf0794c594bad32a320eea0d6bfe40c.jpeg`
    - `price` string

      **示例：** `81.00`
    - `total` string

      **示例：** `81.00`
    - `weight` string

      **示例：** `1.10`
    - `properties` object[]

      *   Array [

      - `name` string

        **示例：** `size`
      - `value` string

        **示例：** `L`
      *   ]
    - `custom_properties` object

      - `` object
    - `refund_quantity` integer

      **默认值：** `0`

      **示例：** `0`
    - `refund_total` string

      **示例：** `0.00`
    - `taxable` boolean

      **默认值：** `true`

      **示例：** `true`
    - `requires_shipping` boolean

      **默认值：** `true`

      **示例：** `true`
    - `shipping_quantity` integer

      **默认值：** `0`

      **示例：** `1`
    *   ]

```json
{
  "fulfillment": {
    "id": "51c7dd5d-8f49-40c3-b2c1-5dfdeef9946d",
    "order_id": "633130-00000007",
    "status": "shipped",
    "tracking_company": "燕文物流",
    "tracking_number": "11111111111",
    "tracking_company_code": "DJ-11343",
    "tracking_url": "",
    "created_at": "2024-04-22T08:37:12Z",
    "updated_at": "2024-04-22T08:37:12Z",
    "line_items": [
      {
        "id": "ed8af005-1f4e-42d1-859d-99b0fd420781",
        "product_id": "a1a88be0-a1d4-47e4-a2f2-ba6e131cf447",
        "variant_id": "a7175820-36b3-4fc6-9baf-51e3035242ba",
        "variant_title": "L-blue-T",
        "product_title": "shirt",
        "product_handle": "shirt",
        "quantity": 1,
        "note": "",
        "fulfillment_status": "shipped",
        "sku": "T-M-L-blue-T-A001008",
        "weight_unit": "kg",
        "vendor": "shoplazza",
        "product_url": "/products/shirt",
        "compare_at_price": "97.00",
        "image": "//cdn.shoplazza.com/ccf0794c594bad32a320eea0d6bfe40c.jpeg",
        "price": "81.00",
        "total": "81.00",
        "weight": "1.10",
        "properties": [
          {
            "name": "size",
            "value": "L"
          }
        ],
        "custom_properties": {},
        "refund_quantity": 0,
        "refund_total": "0.00",
        "taxable": true,
        "requires_shipping": true,
        "shipping_quantity": 1
      }
    ]
  }
}
```

```json
{
    "fulfillment": {
        "id": "51c7dd5d-8f49-40c3-b2c1-5dfdeef9946d",
        "order_id": "633130-00000007",
        "status": "shipped",
        "tracking_company": "燕文物流",
        "tracking_number": "11111111111",
        "tracking_company_code": "DJ-11343",
        "tracking_url": "",
        "created_at": "2024-04-22T08:37:12Z",
        "updated_at": "2024-04-22T08:37:12Z",
        "line_items": [
            {
                "id": "ed8af005-1f4e-42d1-859d-99b0fd420781",
                "product_id": "a1a88be0-a1d4-47e4-a2f2-ba6e131cf447",
                "variant_id": "a7175820-36b3-4fc6-9baf-51e3035242ba",
                "variant_title": "L-blue-T",
                "product_title": "shirt",
                "product_handle": "shirt",
                "quantity": 1,
                "note": "",
                "fulfillment_status": "shipped",
                "sku": "T-M-L-blue-T-A001008",
                "weight_unit": "kg",
                "vendor": "shoplazza",
                "product_url": "/products/shirt",
                "compare_at_price": "97.00",
                "image": "//cdn.shoplazza.com/ccf0794c594bad32a320eea0d6bfe40c.jpeg",
                "price": "81.00",
                "total": "81.00",
                "weight": "1.10",
                "properties": [
                    {
                        "name": "size",
                        "value": "L"
                    },
                    {
                        "name": "color",
                        "value": "blue"
                    },
                    {
                        "name": "type",
                        "value": "T"
                    }
                ],
                "custom_properties": {},
                "refund_quantity": 0,
                "refund_total": "0.00",
                "taxable": true,
                "requires_shipping": true,
                "shipping_quantity": 1
            }
        ]
    }
}
```

404

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "Record not found"
  ]
}
```

```json
{ "errors": ["Record not found"] }
```

422

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "invalid line_item id"
  ]
}
```

```json
{
  "errors": [
    "invalid line_item id",
    "Shipment not allowed under current status.",
     "The fulfill failed due to insufficient remaining fulfillment quantity",
    "ShipQuantity is required"

  ]
}
```
