Fulfillment

Important

Apps are required to specify a location_id when creating fulfillments. For more information, see Managing fulfillments.

You can use the Fulfillment resource to view, create, modify, or delete an order’s or fulfillment order‘s fulfillments. A fulfillment order represents a group of one or more items in an order that are to be fulfilled from the same location. A fulfillment represents work that is completed as part of a fulfillment order and can include one or more items. You can use the Fulfillment resource to manage fulfillments for both orders and fulfillment orders.

Fulfillment - 图1

This resource is most often used in apps that perform shipping-related actions, such as making tracking and delivery updates, or creating additional shipments as required for an order or fulfillment order.

Each fulfillment supports a single tracking number. If you need to use multiple tracking numbers, then you should create separate fulfillments.

What you can do with Fulfillment

The Shopify API lets you do the following with the Fulfillment resource. More detailed versions of these general actions may be available:

Fulfillment properties

created_at plain "created_at": "2012-03-13T16:09:54-04:00" The date and time when the fulfillment was created. The API returns this value in ISO 8601 format.
id plain "id": 255858046 The ID for the fulfillment.
line_items plain "line_items": [ { "id": 466157049, "variant_id": 39072856, "title": "IPod Nano - 8gb", "quantity": 1, "price": "199.00", "grams": 200, "sku": "IPOD2008GREEN", "variant_title": "green", "vendor": null, "fulfillment_service": "manual", "product_id": 632910392, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "IPod Nano - 8gb - green", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "total_discount": "0.00", "fulfillment_status": null, "tax_lines": [], "duties": [ { "id": "2", "harmonized_system_code": "520300", "country_code_of_origin": "CA", "shop_money": { "amount": "164.86", "currency_code": "CAD" }, "presentment_money": { "amount": "105.31", "currency_code": "EUR" }, "tax_lines": [ { "title": "VAT", "price": "16.486", "rate": 0.1, "price_set": { "shop_money": { "amount": "16.486", "currency_code": "CAD" }, "presentment_money": { "amount": "10.531", "currency_code": "EUR" } } } ], "admin_graphql_api_id": "gid://shopify/Duty/2" } ] } ] A historical record of each item in the fulfillment:
+ id: The ID of the line item within the fulfillment.
+ variant_id: The ID of the product variant being fulfilled.
+ title: The title of the product.
+ quantity: The number of items in the fulfillment.
+ price: The price of the item.
+ grams: The weight of the item in grams.
+ sku: The unique identifier of the item in the fulfillment.
+ variant_title: The title of the product variant being fulfilled.
+ vendor: The name of the supplier of the item.
+ fulfillment_service: The service provider who is doing the fulfillment.
+ product_id: The unique numeric identifier for the product in the fulfillment.
+ requires_shipping: Whether a customer needs to provide a shipping address when placing an order for this product variant.
+ taxable: Whether the line item is taxable.
+ gift_card: Whether the line item is a gift card.
+ name: The name of the product variant.
+ variant_inventory_management: The name of the inventory management system.
+ properties: Any additional properties associated with the line item.
+ product_exists: Whether the product exists.
+ fulfillable_quantity: The amount available to fulfill. This is the quantity - max (refunded_quantity, fulfilled_quantity) - pending_fulfilled_quantity - open_fulfilled_quantity.
+ total_discount: The total of any discounts applied to the line item.
+ fulfillment_status: The status of an order in terms of the line items being fulfilled. Valid values: fulfilled, null, or partial.
+ tax_lines: The title, price, and rate of any taxes applied to the line item.
+ duties: A list of duty objects, each containing information about a duty on the line item.
location_id plain "location_id": 40642626 The unique identifier of the location that the fulfillment should be processed for. To find the ID of the location, use the Location resource.
name plain "name": "#1001.1" The uniquely identifying fulfillment name, consisting of two parts separated by a .. The first part represents the order name and the second part represents the fulfillment number. The fulfillment number automatically increments depending on how many fulfillments are in an order (e.g. #1001.1, #1001.2).
notify_customer plain "notify_customer": true Whether the customer should be notified. If set to true, then an email will be sent when the fulfillment is created or updated. For orders that were initially created using the API, the default value is false. For all other orders, the default value is true.
order_id plain "order_id": 450789469 The unique numeric identifier for the order.
receipt plain "receipt": { "testcase": true, "authorization": "123456" } A text field that provides information about the receipt:
+ testcase: Whether the fulfillment was a testcase.
+ authorization: The authorization code.
service plain "service": "manual" The type of service used.
shipment_status plain "shipment_status": "confirmed" The current shipment status of the fulfillment. Valid values:
+ label_printed: A label for the shipment was purchased and printed.
+ label_purchased: A label for the shipment was purchased, but not printed.
+ attempted_delivery: Delivery of the shipment was attempted, but unable to be completed.
+ ready_for_pickup: The shipment is ready for pickup at a shipping depot.
+ confirmed: The carrier is aware of the shipment, but hasn’t received it yet.
+ in_transit: The shipment is being transported between shipping facilities on the way to its destination.
+ out_for_delivery: The shipment is being delivered to its final destination.
+ delivered: The shipment was succesfully delivered.
+ failure: Something went wrong when pulling tracking information for the shipment, such as the tracking number was invalid or the shipment was canceled.
status plain "status": "failure" The status of the fulfillment. Valid values:
+ pending: The fulfillment is pending.
+ open: The fulfillment has been acknowledged by the service and is in processing.
+ success: The fulfillment was successful.
+ cancelled: The fulfillment was cancelled.
+ error: There was an error with the fulfillment request.
+ failure: The fulfillment request failed.
tracking_company plain "tracking_company": "China Post" The name of the tracking company.
+ 4PX
+ APC
+ Amazon Logistics UK
+ Amazon Logistics US
+ Anjun Logistics
+ Australia Post
+ Bluedart
+ Canada Post
+ Canpar
+ China Post
+ Chukou1
+ Correios
+ Couriers Please
+ DHL Express
+ DHL eCommerce
+ DHL eCommerce Asia
+ DPD
+ DPD Local
+ DPD UK
+ Delhivery
+ Eagle
+ FSC
+ FedEx
+ GLS
+ GLS (US)
+ Globegistics
+ Japan Post (EN)
+ Japan Post (JA)
+ La Poste
+ New Zealand Post
+ Newgistics
+ PostNL
+ PostNord
+ Purolator
+ Royal Mail
+ SF Express
+ SFC Fulfillment
+ Sagawa (EN)
+ Sagawa (JA)
+ Sendle
+ Singapore Post
+ StarTrack
+ TNT
+ Toll IPEC
+ UPS
+ USPS
+ Whistl
+ Yamato (EN)
+ Yamato (JA)
+ YunExpress
Important
When creating a fulfillment for a supported carrier, send the tracking_company exactly as written in the list above. If the tracking company doesn’t match one of the supported entries, then the shipping status might not be updated properly during the fulfillment process.
tracking_numbers plain "tracking_numbers": [ "112345Z2345" ] A list of tracking numbers, provided by the shipping company.
Important
It is highly recommended that you send the tracking company and the tracking URL as well. If neither one of these is sent, then the tracking company will be determined automatically. This can result in an invalid tracking URL.
The tracking URL is displayed in the shipping confirmation email, which can optionally be sent to the customer. When accounts are enabled, it is also displayed in the customer’s order history.
tracking_urls plain "tracking_urls": [ "http://track-chinapost.com/startairmail.php?code=112345Z2345" ] The URLs of tracking pages for the fulfillment.
updated_at plain "updated_at": "2012-05-01T14:22:25-04:00" The date and time (ISO 8601 format) when the fulfillment was last modified..
variant_inventory_management plain "variant_inventory_management": "shopify" The name of the inventory management service.

Endpoints

GET/admin/api/2021-01/orders/{order_id}/fulfillments.json Retrieves fulfillments associated with an order. Note: As of version 2019-10, this endpoint implements pagination by using links that are provided in the response header. Sending the <font style="background-color:#F4F6F8;">page</font> parameter will return an error. To learn more, see Making requests to paginated REST Admin API endpoints.
created_at_max Show fulfillments created before date (format: 2014-04-25T16:15:47-04:00).
created_at_min Show fulfillments created after date (format: 2014-04-25T16:15:47-04:00).
fields A comma-separated list of fields to include in the response.
limit Limit the amount of results.
(default: 50
, maximum: 250
)
since_id Restrict results to after the specified ID.
updated_at_max Show fulfillments last updated before date (format: 2014-04-25T16:15:47-04:00).
updated_at_min Show fulfillments last updated after date (format: 2014-04-25T16:15:47-04:00).

Retrieve a list of all fulfillments for an order

GET /admin/api/2021-01/orders/450789469/fulfillments.json

View Response

Retrieve all fulfillments after the specified ID

GET /admin/api/2021-01/orders/450789469/fulfillments.json?since_id=255858046

View Response

GET/admin/api/2021-01/fulfillment_orders/{fulfillment_order_id}/fulfillments.json Retrieves fulfillments associated with a fulfillment order.
fulfillment_order_id The ID of the fulfillment order that is associated with the fulfillments.

Retrieve a list of all fulfillments for a fulfillment order

GET /admin/api/2021-01/fulfillment_orders/1046000777/fulfillments.json

View Response

GET/admin/api/2021-01/orders/{order_id}/fulfillments/count.json Retrieves a count of fulfillments associated with a specific order
created_at_min Count fulfillments created after date (format: 2014-04-25T16:15:47-04:00).
created_at_max Count fulfillments created before date (format: 2014-04-25T16:15:47-04:00).
updated_at_min Count fulfillments last updated after date (format: 2014-04-25T16:15:47-04:00).
updated_at_max Count fulfillments last updated before date (format: 2014-04-25T16:15:47-04:00).

Count the total number of fulfillments for an order

GET /admin/api/2021-01/orders/450789469/fulfillments/count.json

View Response

GET/admin/api/2021-01/orders/{order_id}/fulfillments/{fulfillment_id}.json Retrieve a specific fulfillment
fields Comma-separated list of fields to include in the response.

Retrieve a specific fulfillment

GET /admin/api/2021-01/orders/450789469/fulfillments/255858046.json

View Response

POST/admin/api/2021-01/orders/{order_id}/fulfillments.json

Create a fulfillment for the specified order and line items.

The fulfillment’s status depends on the line items in the order:

  • If the line items in the fulfillment use a manual or custom fulfillment service, then the status of the returned fulfillment will be set immediately.
  • If the line items use an external fulfillment service, then they will be queued for fulfillment and the status will be set to pending until the external fulfillment service has been invoked.

A fulfillment might then transition to open, which implies it is being processed by the service, before transitioning to success when the items have shipped. If you don’t specify line item IDs, then all unfulfilled and partially fulfilled line items for the order will be fulfilled. However, if an order is refunded or if any of its individual line items are refunded, then the order can’t be fulfilled.

All line items being fulfilled must have the same fulfillment service.

Note

If you are using this endpoint with a Partner development store or a trial store, then you can create no more than 5 new fulfillments per minute.

About tracking urls

If you’re creating a fulfillment for a supported carrier, then you can send the tracking_company and tracking_numbers fields, and Shopify will generate the tracking_url for you. If you’re creating a fulfillment for an unsupported carrier (not in the tracking_company list), then send the tracking_company, tracking_numbers, and tracking_urls fields.

Note

If you send an unsupported carrier without a tracking URL, then Shopify will still try to generate a valid tracking URL by using pattern matching on the tracking number. However, Shopify does not validate the tracking URL, so you should make sure that your tracking URL is correct for the order and fulfillment.

Fulfill all line items for an order and send the shipping confirmation email. Not specifying line item IDs causes all unfulfilled and partially fulfilled line items for the order to be fulfilled.

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 487838322,
  2. "tracking_number": "123456789",
  3. "tracking_urls": [
  4. "https://shipping.xyz/track.php?num=123456789",
  5. "https://anothershipper.corp/track.php?code=abc"
  6. ],
  7. "notify_customer": true

}

}

View Response

Fulfill line items without a tracking number

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": null,
  3. "line_items": [
  4. {
  5. "id": 466157049
  6. },
  7. {
  8. "id": 518995019
  9. },
  10. {
  11. "id": 703073504
  12. }
  13. ]

}

}

View Response

Fulfill all line items for an order with multiple tracking numbers

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_numbers": [
  3. "9aec1ebb9adf2cfc129c731fa18685ac",
  4. "277542f9873f06d44f7723c7eaa2e5c6",
  5. "4d9f2013b4c08be6cbcaaf8ca38be7f3"
  6. ],
  7. "line_items": [
  8. {
  9. "id": 466157049
  10. },
  11. {
  12. "id": 518995019
  13. },
  14. {
  15. "id": 703073504
  16. }
  17. ]

}

}

View Response

Fulfill all line items for an order and use a custom tracking URL and company

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_url": "http://www.packagetrackr.com/track/somecarrier/1234567",
  3. "tracking_company": "Jack Black's Pack, Stack and Track",
  4. "line_items": [
  5. {
  6. "id": 466157049
  7. },
  8. {
  9. "id": 518995019
  10. },
  11. {
  12. "id": 703073504
  13. }
  14. ]

}

}

View Response

Fulfill without a location_id results in a bad request

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "tracking_url": "http://www.packagetrackr.com/track/somecarrier/1234567",
  2. "tracking_company": "Jack Black's Pack, Stack and Track",
  3. "line_items": [
  4. {
  5. "id": 466157049
  6. },
  7. {
  8. "id": 518995019
  9. },
  10. {
  11. "id": 703073504
  12. }
  13. ]

}

}

View Response

Fulfill an order using a supported tracking company (generates tracking URL)

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": "123456789",
  3. "tracking_company": "4PX",
  4. "line_items": [
  5. {
  6. "id": 466157049
  7. },
  8. {
  9. "id": 518995019
  10. },
  11. {
  12. "id": 703073504
  13. }
  14. ]

}

}

View Response

Fulfill an order using a supported tracking company in an incorrect format (uses fuzzy matches to generate tracking URL, but respects tracking company supplied)

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": "123456789010",
  3. "tracking_company": "fed ex",
  4. "line_items": [
  5. {
  6. "id": 466157049
  7. },
  8. {
  9. "id": 518995019
  10. },
  11. {
  12. "id": 703073504
  13. }
  14. ]

}

}

View Response

Fulfill an order using a supported tracking company in an incorrect format and custom tracking URL (respects sent URL)

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": "123456789010",
  3. "tracking_company": "fed ex",
  4. "tracking_url": "https://www.new-fedex-tracking.com/?number=123456789010",
  5. "line_items": [
  6. {
  7. "id": 466157049
  8. },
  9. {
  10. "id": 518995019
  11. },
  12. {
  13. "id": 703073504
  14. }
  15. ]

}

}

View Response

Fulfill an order using a non-supported tracking company without a tracking URL (generates best guess URL if number matches recognizable pattern)

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": "RR123456789CN",
  3. "tracking_company": "Chinese Post",
  4. "line_items": [
  5. {
  6. "id": 466157049
  7. },
  8. {
  9. "id": 518995019
  10. },
  11. {
  12. "id": 703073504
  13. }
  14. ]

}

}

View Response

Fulfill an order using a non-supported tracking company without a tracking URL. Does not generate a URL if tracking number does not match a recognizable pattern.

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": "1234567",
  3. "tracking_company": "Custom Tracking Company",
  4. "line_items": [
  5. {
  6. "id": 466157049
  7. },
  8. {
  9. "id": 518995019
  10. },
  11. {
  12. "id": 703073504
  13. }
  14. ]

}

}

View Response

Fulfill an order using only a tracking number and a custom tracking URL (respects tracking URL but attempts to generate tracking company if number matches recognizable pattern)

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": "CJ274101086US",
  3. "tracking_url": "http://www.custom-tracking.com/?tracking_number=CJ274101086US",
  4. "line_items": [
  5. {
  6. "id": 466157049
  7. },
  8. {
  9. "id": 518995019
  10. },
  11. {
  12. "id": 703073504
  13. }
  14. ]

}

}

View Response

Fulfill a single line item by explicitly specifying the line items to be fulfilled

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": null,
  3. "line_items": [
  4. {
  5. "id": 518995019
  6. }
  7. ]

}

}

View Response

Partially fulfill a single line item by specifying a line item and quantity to be fulfilled

POST /admin/api/2021-01/orders/450789469/fulfillments.json

{

“fulfillment”: {

  1. "location_id": 905684977,
  2. "tracking_number": null,
  3. "line_items": [
  4. {
  5. "id": 518995019,
  6. "quantity": 1
  7. }
  8. ]

}

}

View Response

POST/admin/api/2021-01/fulfillments.json Creates a fulfillment for one or many fulfillment orders. The fulfillment orders are associated with the same order and are assigned to the same location.

Create a fulfillment for the fulfillment order line items specified

POST /admin/api/2021-01/fulfillments.json

{

“fulfillment”: {

  1. "message": "The package was shipped this morning.",
  2. "notify_customer": false,
  3. "tracking_info": {
  4. "number": 1562678,
  5. "url": "https://www.my-shipping-company.com",
  6. "company": "my-shipping-company"
  7. },
  8. "line_items_by_fulfillment_order": [
  9. {
  10. "fulfillment_order_id": 1046000792,
  11. "fulfillment_order_line_items": [
  12. {
  13. "id": 1025578638,
  14. "quantity": 1
  15. }
  16. ]
  17. }
  18. ]

}

}

View Response

Creates a fulfillment for all fulfillment order line items if fulfillment_order_line_items is left blank

POST /admin/api/2021-01/fulfillments.json

{

“fulfillment”: {

"message": "The package was shipped this morning.",

"notify_customer": false,

"tracking_info": {

  "number": 1562678,

  "url": "https://www.my-shipping-company.com",

  "company": "my-shipping-company"

},

"line_items_by_fulfillment_order": [

  {

    "fulfillment_order_id": 1046000793

  }

]

}

}

View Response

PUT/admin/api/2021-01/orders/{order_id}/fulfillments/{fulfillment_id}.json Update information associated with a fulfillment

Update the tracking number for a fulfillment

PUT /admin/api/2021-01/orders/450789469/fulfillments/255858046.json

{

“fulfillment”: {

"tracking_number": "987654321",

"id": 255858046

}

}

View Response

POST/admin/api/2021-01/fulfillments/{fulfillment_id}/update_tracking.json Updates the tracking information for a fulfillment.

Update the tracking information for a fulfillment

POST /admin/api/2021-01/fulfillments/1022782903/update_tracking.json

{

“fulfillment”: {

"notify_customer": true,

"tracking_info": {

  "number": "1111",

  "url": "http://www.my-url.com",

  "company": "my-company"

}

}

}

View Response

POST/admin/api/2021-01/orders/{order_id}/fulfillments/{fulfillment_id}/complete.json Mark a fulfillment as complete

Complete a fulfillment

POST /admin/api/2021-01/orders/450789469/fulfillments/255858046/complete.json

{

}

View Response

POST/admin/api/2021-01/orders/{order_id}/fulfillments/{fulfillment_id}/open.json Mark a fulfillment as open

Transition a fulfillment from pending to open

POST /admin/api/2021-01/orders/450789469/fulfillments/255858046/open.json

{

}

View Response

POST/admin/api/2021-01/orders/{order_id}/fulfillments/{fulfillment_id}/cancel.json Cancel a fulfillment for a specific order ID

Cancel a fulfillment for a specific order ID

POST /admin/api/2021-01/orders/450789469/fulfillments/255858046/cancel.json

{

}

View Response

POST/admin/api/2021-01/fulfillments/{fulfillment_id}/cancel.json Cancels a fulfillment.

Cancel a fulfillment

POST /admin/api/2021-01/fulfillments/1022782904/cancel.json

{

}

View Response