VoidLabels()
This method is used to void a previously created label.
Syntax
module.exports = async function VoidLabels(request) { // Your code here}
import { VoidLabelsRequest, VoidLabelsResponse } from "@shipengine/connect-carrier-api";export default async function VoidLabels( request: VoidLabelsRequest): Promise<VoidLabelsResponse> { // Your code here}
Parameters
VoidLabelsRequest
An object containing information about the labels to void.
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. | |
void_requests | Array of void requests |
Void Requests Object
This object extends Shipped Shipment
Name | Type | Nullable? | Description |
---|---|---|---|
...Shipped Shipment | All fields described in the shipped shipment. | ||
void_request_id | string | Uniquely identifies this request to void a label. Must be returned in a void response. | |
ship_from | The shipment sender's address. It may or may not have been validated. |
Return Value
VoidLabelsResponse
This object model represents the response from a successful void labels 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. | ||
void_responses | object[] | ✔ | Array of void responses |
void_responses[]
.void_request_id | string | ✔ | This unique identifier should be related to the void_request_id in the VoidLabelsRequest. |
void_responses[].message | string | User facing text describing the void process. May be left blank to present a default value. | |
void_responses[].errors | string[] | A list of errors preventing this label from being voided. If no errors are returned the void is considered successful. If any errors are returned the void is considered failed. |
Example
module.exports = async function VoidLabels(request) { // STEP 1: Validation // STEP 2: Create the data that the carrier's API expects let data = { operation: "void_labels", session_id: request.metadata.id, void_labels: request.void_requests.map((void_request) => { const { void_request_id, tracking_number, carrier_transaction_id } = void_request; return { void_request_id: void_request_id, 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 formatVoidLabel(response.data);}
import { VoidLabelsRequest, VoidLabelsResponse} from "@shipengine/connect-carrier-api";export default async function VoidLabels(request: VoidLabelsRequest): Promise<VoidLabelsResponse> { // STEP 1: Validation // STEP 2: Create the data that the carrier's API expects let data: VoidLabelsAPIRequest = { operation: "void_labels", session_id: request.metadata.id, void_labels: request.void_requests.map((void_request) => { const { void_request_id, tracking_number, carrier_transaction_id } = void_request; return { void_request_id: void_request_id, tracking_number: tracking_number, carrier_transaction_id: carrier_transaction_id }; }), }; // STEP 3: Call the carrier's API const response = await apiClient.request<VoidLabelsAPIResponse>({ data }); // STEP 4: Create the output data that ShipEngine expects return formatVoidLabel(response.data);}