shipmentCancelled()

This method is called when a shipment is cancelled for one or more items in one or more sales orders. A single shipment may contain items from multiple sales orders, and a single sales order may be fulfilled by multiple shipments.

Syntax

module.exports = async function shipmentCancelled(transaction, shipment) {
// Your code here
}
import { Transaction, SalesOrderShipment } from "@shipengine/connect";
export default async function shipmentCancelled(
transaction: Transaction,
shipment: SalesOrderShipment
): Promise<void> {
// Your code here
}

Parameters

transaction

A transaction object containing information about the transaction and session state.

shipment

The shipment that was cancelled.

NameTypeNullable?Description
trackingNumberstring

The master tracking number for the entire shipment. For single-piece shipments, this will be the same as the package tracking number. For multi-piece shipments, this may be a separate tracking number, or the same tracking number as one of the packages. This string will not contain newline characters.

identifiersobject

Your own identifiers for this shipment.

trackingURL

URL

The URL of a webpage where the customer can track the shipment.

salesOrderobject

The sales order associated with this shipment.

salesOrder.id

UUID

The marketplace's unique ID for the sales order.

salesOrder.identifiersobject

Your own identifiers for this sales order.

fulfillmentServicestring

If the shipment is being fulfilled using a well-known third-party carrier, such as UPS, FedEx, DHL, etc., then this field specifies the carrier service.

shipFrom

address + contact object

The sender's contact info and address.

shipTo

address + contact object

The recipient's contact info and address.

shipDateTime

DateTime

The date/time that the shipment was shipped or is expected to ship. This is not guaranteed to be in the future.

contentsobject[]

The items inside the package.

contents[].salesOrderItemobject

The sales order associated with this item.

contents[]   .salesOrderItem   .idstring

The marketplace's unique ID for the sales order item.

contents[]   .salesOrderItem   .skustring

The Stock Keeping Unit. This string must not contain newline characters.

contents[]   .salesOrderItem   .identifiersobject

Your own identifiers for this sales order item.

contents[].productobject

The product associated with this item.

contents[].product.idstring

The product catalog's unique ID for the order. This string must not contain newline characters.

contents[].product.skustring

The Stock Keeping Unit. This string must not contain newline characters.

contents[].product.upcstring

The Universal Product Code for this item. This string must not contain newline characters.

contents[].product.isbnstring

The International Standard Book Number for this item. This string must not contain newline characters.

contents[].product.asinstring

The Amazon Standard Identification Number for this item. This string must not contain newline characters.

contentes[]   .product   .fulfillmentSkustring

The Stock Keeping Unit related to the fulfillment of this item. This string must not contain newline characters.

contents[]   .product   .inventoryIDstring

The inventory ID for this item. This string must not contain newline characters.

contents[]   .product   .identifiersobject

Your own identifiers for this product.

contents[]   .product   .details

identifiers object

A list of details associated with this product.

Return Value

void

This method is used to notify your application when a shipment is cancelled. It does not return a value.

Example

async function shipmentCancelled(transaction, shipment) {
// STEP 1: Validation
// Add any desired validation here
// STEP 2: Create the data that the order source's API expects
const data = {
operation: "cancel_shipment",
session_id: transaction.session.id,
cancelled_shipment_id: shipment.trackingNumber
};
// STEP 3: Call the order source's API
await apiClient.request({ data });
}
export default async function shipmentCancelled(
transaction: Transaction<Session>,
shipment: SalesOrderShipment,
): Promise<void> {
// STEP 1: Validation
// Add any desired validation here
// STEP 2: Create the data that the order source's API expects
const data = {
operation: "cancel_shipment",
session_id: transaction.session.id,
cancelled_shipment_id: shipment.trackingNumber
};
// STEP 3: Call the order source's API
await apiClient.request({ data });
}