SchedulePickup()

This method is used to schedule a pickup with a carrier.

Syntax

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

Parameters

SchedulePickupRequest

An object containing information about the pickup being scheduled.

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.

location

pickup location details object

Where it's being picked up. Contact information for the pickup, like an on-duty manager that would be able to oversee the pickup at the location.

contactobject

Contact information about the person there to meet the driver.

contact.first_namestring

The first name of the person who will be there for the pickup.

contact.last_namestring

The last name of the person who will be there for the pickup.

contact.emailstring

The e-mail address of the person who will be there for the pickup.

contact.phone_numberstring

The phone number of the person who will be there for the pickup.

contact   .phone_number_extensionstring

The phone extension of the person who will be there for the pickup.

pickup_detailsobject

What is being picked up.

pickup_details   .pickup_service_codestring

Service category for the carrier (ground, express, next_day).

pickup_details.shipments

shipped shipment[]

The shipments that will be picked up.

requested_pickup_window

pickup window object

The time window that the user is requesting for the pickup to be made.

Return Value

SchedulePickupResponse

This object model represents the response from a successful schedule pickup 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.

confirmation

pickup confirmation object

The confirmation code associated with the successful creation of a pickup.

pickup_windows

pickup window object[]

A list of dates and times when the carrier intends to be available to pickup.

remarksstring

A custom message returned from the carrier.

custom_propertiesobject

A grab bag of custom properties that will be persisted and sent back with the cancel pickup request.

billing_line_items

billing line item object[]

Individual Billing Line items for the rate.

Example

module.exports = async function SchedulePickup(request) {
// STEP 1: Validation
// STEP 2: Create the data that the carrier's API expects
let data = {
operation: "schedule_pickup",
session_id: request.metadata.id,
pickup_time: request.requested_pickup_window,
pickup_location: request.location,
packages: request.pickup_details.shipments,
};
// STEP 3: Call the carrier's API
const response = await apiClient.request({ data });
// STEP 4: Create the output data that ShipEngine expects
return formatSchedulePickup(response.data);
}
import {
SchedulePickupRequest,
SchedulePickupResponse
} from "@shipengine/connect-carrier-api";
export default async function SchedulePickup(request: SchedulePickupRequest): Promise<SchedulePickupResponse> {
// STEP 1: Validation
// STEP 2: Create the data that the carrier's API expects
let data: SchedulePickupAPIRequest = {
operation: "schedule_pickup",
session_id: request.metadata.id,
pickup_time: request.requested_pickup_window,
pickup_location: request.location,
packages: request.pickup_details.shipments,
};
// STEP 3: Call the carrier's API
const response = await apiClient.request<SchedulePickupAPIResponse>({ data });
// STEP 4: Create the output data that ShipEngine expects
return formatSchedulePickup(response.data);
}