Site Logo

🎉 ShipEngine is becoming ShipStation API 🎉

Over the next few months you'll notice the ShipEngine website, documentation portal, and dashboard being rebranded as ShipStation API. For our ShipEngine customers, you don't need to take any action or change any of your integrations in any way. All endpoints will remain the same and continue to function as they always have.

To learn more about what's coming, review our New ShipStation API page.

Void Label Element

The Void Label Element enables a user to void a specific shipping label.

React Component

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { VoidLabel, ElementsProvider } from '@shipengine/elements';
import { themeConfig } from '../themeConfig';
const tokenPath = '/path/to/token/endpoint';
const Foo = ({ labelId }) => {
const getToken = useCallback(() => {
return fetch(tokenPath).then((res) => res.text());
}, []);
return (
<ElementsProvider
getToken={getToken}
themeConfig={themeConfig}
onError={handleError}
>
<VoidLabel.Element
labelId={labelId}
onComplete={() => {
console.log('Label Voided');
}}
onViewShipment={() => {
console.log('Go back to shipment');
}}
/>
</ElementsProvider>
);
};

SDK

1
2
3
4
5
6
7
8
9
10
11
12
// Creates a new instance of the Elements SDK.
const elements = new ElementsSDK(getToken, {
onError: (err: Error) => console.error(err),
themeConfig: themeConfig,
locale: 'en-US',
});
const voidLabel = elements.create('voidLabel', {
labelId: 'se-44356221134',
onComplete: () => console.log('Label Voided'),
onViewShipment: () => console.log('Go back to shipment'),
});
Args/PropsRequired?Description
labelIdrequiredstring, The unique identifier for the label you wish to void.
onCompleterequiredfunction, (request: SE.VoidRequest, shipment: SE.SalesOrderShipment) => void A callback function that will be invoked when the request to void a given shipping label is completed.
onSuccessoptionalfunction, (label: SE.Label, shipment: SE.SalesOrderShipment) => void A callback function that will be invoked when the request to void a given shipping label is successful.
onViewShipmentrequiredfunction, (shipment: SE.SalesOrderShipment) => void;A callback function that will be invoked when the user clicks the View Shipment button.

We recommend using this callback to render the Shipment Summary Element.