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.
Name | Type | Nullable? | Description |
---|---|---|---|
authorization | ✔ | The authorization information necessary to fulfill this request. | |
metadata | ✔ | 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 | ✔ | The shipment sender's address. It may or may not have been validated. | |
included_labels | ✔ | The shipments to include in the manifest. There should be at least one shipment included in a manifest. | |
excluded_labels | ✔ | The shipments to exclude from the manifest. | |
open_datetime | string | ✔ | The date and time of the earliest shipment being manifested. Formatted per the https://tools.ietf.org/html/rfc3339 spec |
close_datetime | string | ✔ | The date and time of the last shipment being manifested. Formatted per the https://tools.ietf.org/html/rfc3339 spec |
advanced_options | ✔ | This contains an optional set of properties describing the advanced options a user might select. |
Return Value
CreateManifestResponse
This object model represents the response from a successful create manifest request.
Name | Type | Required? | Description |
---|---|---|---|
metadata | 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_id | string | ✔ | 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. |
manifests | object[] | ✔ | The manifests created from this request. It should contain either a href or data, but not both. |
manifests[].manifest_id | string | The unique identifier for this manifest. | |
manifests[]
.document_download | object | The resource for where the manifest documentation can be downloaded. | |
manifests[]
.document_download
.href | string | The public url where the manifest documentation can be downloaded. | |
manifests[]
.document_download
.data | string | 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);}