(pickups)
A pickup is when you schedule a carrier to collect a package for delivery. Use Shippo’s pickups endpoint to schedule pickups with USPS and DHL Express for eligible shipments that you have already created.
- create - Create a pickup
Creates a pickup object. This request is for a carrier to come to a specified location to take a package for shipping.
import { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const result = await shippo.pickups.create({
carrierAccount: "adcfdddf8ec64b84ad22772bce3ea37a",
location: {
address: {
name: "Shwan Ippotle",
company: "Shippo",
street1: "215 Clayton St.",
street3: "",
streetNo: "",
city: "San Francisco",
state: "CA",
zip: "94117",
country: "US",
phone: "+1 555 341 9393",
email: "[email protected]",
isResidential: true,
metadata: "Customer ID 123456",
validate: true,
},
buildingLocationType: "Front Door",
buildingType: "apartment",
instructions: "Behind screen door",
},
requestedEndTime: new Date("2023-06-18T07:14:55.338Z"),
requestedStartTime: new Date("2023-12-01T17:06:07.804Z"),
transactions: [
"adcfdddf8ec64b84ad22772bce3ea37a",
],
});
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { ShippoCore } from "shippo/core.js";
import { pickupsCreate } from "shippo/funcs/pickupsCreate.js";
// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const res = await pickupsCreate(shippo, {
carrierAccount: "adcfdddf8ec64b84ad22772bce3ea37a",
location: {
address: {
name: "Shwan Ippotle",
company: "Shippo",
street1: "215 Clayton St.",
street3: "",
streetNo: "",
city: "San Francisco",
state: "CA",
zip: "94117",
country: "US",
phone: "+1 555 341 9393",
email: "[email protected]",
isResidential: true,
metadata: "Customer ID 123456",
validate: true,
},
buildingLocationType: "Front Door",
buildingType: "apartment",
instructions: "Behind screen door",
},
requestedEndTime: new Date("2023-06-18T07:14:55.338Z"),
requestedStartTime: new Date("2023-12-01T17:06:07.804Z"),
transactions: [
"adcfdddf8ec64b84ad22772bce3ea37a",
],
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.PickupBase | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Pickup>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |