shipmentCreated()

This method is called when a shipment is created 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 shipmentCreated(transaction, shipment) {
// Your code here
}
import { Transaction, SalesOrderShipment } from "@shipengine/connect";
export default async function shipmentCreated(
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 created.

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.

identifiers

identifiers object

Your own identifiers for this shipment.

salesOrderobject

The sales order associated with this shipment.

salesOrder.id

UUID

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

salesOrder.identifiers

identifiers object

Your own identifiers for this sales order.

shipTo

address + contact info + pickup location object

The recipient's contact info and address.

shipDateTime

date/time object

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[].quantityobject

The quantity of this item in the sales order.

contents[].quantity.valuenumber

The quantity of items in this sales order item. The minimum value for this property is 1.

contents[].currencystring

The three character ISO 4217 code of the currency used for all monetary amounts.

contents[].notes

object[]

Additional notes associated with this notification or its sales order.

contents[].notes[].type

notes type string

The type for this note.

contents[].notes[].text

string

The note text itself.

contents[].salesOrderItemobject

The sales order associated with this item.

This property may be null. If it is provided, all its required properties, listed below, will be included.

contents[]   .salesOrderItem   .idstring

The marketplace's unique ID for the sales order item. This string must not contain newline characters.

contents[]   .salesOrderItem   .skustring

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

contents[]   .salesOrderItem   .identifiers

identifiers object

Your own identifiers for this sales order item.

contents[].productobject

The product associated with this item.

This property may be null. If it is provided, all its required properties, listed below, will be included.

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.

contents[]   .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   .identifiers

identifiers object

Your own identifiers for this product.

contents[]   .product   .details

identifiers object

A list of details associated with this product.

trackingURL

URL

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

carrierCodestring

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.

carrierServiceCodestring

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

fulfillmentService

fulfillment service string

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.

notifyBuyerboolean

Instructs the order source on whether to notify the buyer. Omit, or set to null, to retain the order source's default behavior.

fulfillmentCost

charge object

The amount it costs to fulfill this shipment.

insuranceCost

charge object

The amount of insurance purchased for this shipment.

Return Value

void

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

Example

async function shipmentCreated(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: "create_shipment",
session_id: transaction.session.id,
shipment_id: shipment.trackingNumber
};
// STEP 3: Call the order source's API
await apiClient.request({ data });
}
export default async function shipmentCreated(
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: "create_shipment",
session_id: transaction.session.id,
shipment_id: shipment.trackingNumber
};
// STEP 3: Call the order source's API
await apiClient.request({ data });
}