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.
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. | |
confirmation | ✔ | The confirmation information provided by the SchedulePickup response. | |
location | ✔ | Where was it going to be picked up. | |
cancellation_details | object | ✔ | Why the pickup is being cancelled. |
cancellation_details
.reason | string | The reason the customer is cancelling their pickup request. Valid values include the following:
| |
cancellation_details
.cancellation_options | object | ✔ | Additional properties about the cancellation. |
cancellation_details
.remarks | string | ✔ | Remarks about why the customer is cancelling the pickup. |
contact | object | ✔ | Contact information about the person there to meet the driver. |
contact.first_name | string | The first name of the person who will be there for the pickup. | |
contact.last_name | string | ✔ | The last name of the person who will be there for the pickup. |
contact.email | string | The e-mail address of the person who will be there for the pickup. | |
contact.phone_number | string | The phone number of the person who will be there for the pickup. | |
contact
.phone_number_extension | string | ✔ | The phone extension of the person who will be there for the pickup. |
pickup_details | object | ✔ | What was scheduled to be picked up. |
pickup_details
.pickup_service_code | string | ✔ | Service category for the carrier (ground, express, next_day). |
pickup_details.shipments | ✔ | The shipments that were scheduled to be picked up. | |
pickup_windows | The time windows that the carrier returned in the SchedulePickup Response. | ||
custom_properties | object | ✔ | 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.
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. | ||
confirmation_id | string | The confirmation id from the carrier associated with the cancellation request. | |
successful | boolean | ✔ | A flag for whether or not the cancellation was successful. |
status | string | The optional status returned by the carrier. | |
custom_properties | object | 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);}