CancelPickup()

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

Syntax

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

Parameters

CancelPickupRequest

An object containing information about the pickup being canceled.

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.

confirmation

pickup confirmation object

The confirmation information provided by the SchedulePickup response.

location

pickup location details object

Where was it going to be picked up.

cancellation_detailsobject

Why the pickup is being cancelled.

cancellation_details   .reasonstring

The reason the customer is cancelling their pickup request.

Valid values include the following:

  • other - There is a reason not defined below
  • not_ready - The customer is not ready to have their packages picked up
  • cost_too_high - The cost for picking up was too much
  • service_too_slow - The service pick up would have been too slow
  • carrier_failed_pickup - The carrier didn't pick up when they said they would
cancellation_details   .cancellation_optionsobject

Additional properties about the cancellation.

cancellation_details   .remarksstring

Remarks about why the customer is cancelling the pickup.

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 was scheduled to be picked up.

pickup_details   .pickup_service_codestring

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

pickup_details.shipments

shipped shipment[]

The shipments that were scheduled to be picked up.

pickup_windows

pickup window object[]

The time windows that the carrier returned in the SchedulePickup Response.

custom_propertiesobject

The grab bag of properties necessary to cancel the pickup.

Return Value

CancelPickupResponse

This object model represents the response from a successful cancel 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_idstring

The confirmation id from the carrier associated with the cancellation request.

successfulboolean

A flag for whether or not the cancellation was successful.

statusstring

The optional status returned by the carrier.

custom_propertiesobject

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

Example

module.exports = async function CancelPickup(request) {
// STEP 1: Validation
// STEP 2: Create the data that the carrier's API expects
let data = {
operation: "cancel_pickup",
session_id: request.metadata.id,
pickup_id: request.confirmation.confirmation_id,
pickup_location: request.location,
packages: request.pickup_details.shipments,
reason: request.cancellation_details.reason
};
// STEP 3: Call the carrier's API
const response = await apiClient.request({ data });
// STEP 4: Create the output data that ShipEngine expects
return formatCancelPickup(response.data);
}
import {
CancelPickupRequest,
CancelPickupResponse
} from "@shipengine/connect-carrier-api";
export default async function CancelPickup(request: CancelPickupRequest): Promise<CancelPickupResponse> {
// STEP 1: Validation
// STEP 2: Create the data that the carrier's API expects
let data: CancelPickupAPIRequest = {
operation: "cancel_pickup",
session_id: request.metadata.id,
pickup_id: request.confirmation.confirmation_id,
pickup_location: request.location,
packages: request.pickup_details.shipments,
reason: request.cancellation_details.reason
};
// STEP 3: Call the carrier's API
const response = await apiClient.request<CancelPickupAPIResponse>({ data });
// STEP 4: Create the output data that ShipEngine expects
return formatCancelPickup(response.data);
}