CreateManifest()

This method is used to create a manifest.

Syntax

module.exports = async function CreateManifest(request) {
// Your code here
}
import { CreateManifestRequest, CreateManifestResponse } from "@shipengine/connect-carrier-api";
export default async function CreateManifest(
request: CreateManifestRequest
): Promise<CreateManifestResponse> {
// Your code here
}

Parameters

CreateManifestRequest

An object containing information about the labels to manifest.

NameTypeNullable?Description
authorization

authorization object

The authorization information necessary to fulfill this request.

metadata

metadata object

This object should contain all of the necessary properties needed to make authenticated requests with the carrier when an AuthProcess has not been configured. Every property included here will be persisted by ShipEngine Connect and included on each subsequent request from this user.

ship_from

shipping address object

The shipment sender's address. It may or may not have been validated.

included_labels

shipped shipment object

The shipments to include in the manifest. There should be at least one shipment included in a manifest.

excluded_labels

shipped shipment object

The shipments to exclude from the manifest.

open_datetimestring

The date and time of the earliest shipment being manifested.

Formatted per the https://tools.ietf.org/html/rfc3339 spec

close_datetimestring

The date and time of the last shipment being manifested.

Formatted per the https://tools.ietf.org/html/rfc3339 spec

advanced_optionsobject

This is a schemaless object. It is for open ended customizations unique to particular carriers. If the field is absent it should be interpreted as the default value for any applicable options, e.g. false for booleans.

Return Value

CreateManifestResponse

This object model represents the response from a successful create manifest request.

NameTypeRequired?Description
metadata

metadata object

This object should contain all of the necessary properties needed to make authenticated requests with the carrier. Every property included here will be persisted by ShipEngine Connect and included on each subsequent request from this user.

transaction_idstring

The transaction ID uniquely represents this request. If the request is retried then this transaction ID will be the same. You should only perform the requested action once per given transaction ID.

manifestsobject[]

The manifests created from this request. It should contain either a href or data, but not both.

manifests[].manifest_idstring

The unique identifier for this manifest.

manifests[]   .document_downloadobject

The resource for where the manifest documentation can be downloaded.

manifests[]   .document_download   .hrefstring

The public url where the manifest documentation can be downloaded.

manifests[]   .document_download   .datastring

The base64 encoded resource data.

Example

module.exports = async function CreateManifest(request) {
// STEP 1: Validation
// STEP 2: Create the data that the carrier's API expects
let data = {
operation: "create_manifest",
session_id: request.metadata.id,
create_manifest: request.included_labels.map((label) => {
const { tracking_number } = label;
const { value : carrier_transaction_id } = label.alternative_identifiers.filter(id => id.type === 'carrier_transaction_id');
return {
tracking_number: tracking_number,
carrier_transaction_id: carrier_transaction_id
};
}),
};
// STEP 3: Call the carrier's API
const response = await apiClient.request({ data });
// STEP 4: Create the output data that ShipEngine expects
return formatCreateManifest(response.data);
}
import {
CreateManifestRequest,
CreateManifestResponse
} from "@shipengine/connect-carrier-api";
export default async function CreateManifest(request: CreateManifestRequest): Promise<CreateManifestResponse> {
// STEP 1: Validation
// STEP 2: Create the data that the carrier's API expects
let data: CreateManifestAPIRequest = {
operation: "create_manifest",
session_id: request.metadata.id,
create_manifest: request.included_labels.map((label) => {
const { tracking_number } = label;
const { value : carrier_transaction_id } = label.alternative_identifiers.filter(id => id.type === 'carrier_transaction_id');
return {
tracking_number: tracking_number,
carrier_transaction_id: carrier_transaction_id
};
}),
};
// STEP 3: Call the carrier's API
const response = await apiClient.request<CreateManifestAPIResponse>({ data });
// STEP 4: Create the output data that ShipEngine expects
return formatCreateManifest(response.data);
}