1. Deliveries
  2. Update Deliveries

Deliveries

Update Deliveries

As the shipping provider, you are able to update the status and location properties of the delivery.

Create Delivery

POST `/v1/deliveries`
EXPERIMENTAL

Adding your own deliveries is coming soon


Update Delivery

POST `/v1/deliveries/:delivery`

When you are ready to update a delivery, you can update the status of the delivery which will typically send notifications to the sender and recipient, depending on what notifications they have enabled. You can also update the coordinates of the delivery without updating the status for a better user experience.

Update Status

js
const data = {
  tracking_update: {
    //Most provider just add the city, state, and postal code.
    //You don't need to provide an address if you will be sending coordinates
    address: {
      city: "San Diego",
      state: "California",
    },
    status: "out_for_delivery",
    comment: "Should be coming in 5 mins", //This is optional
    images: [], //An array of base64 images
    tracking_number: "PKGX-1234567-ABCDEFG", //Only required if there are multiple parcels in the delivery
  },
  location: {
    coordinates: [40.7531386, -73.9894616],
  },
};

fetch(`https://api.packagex.io/v1/deliveries/${delivery.id}`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
});

Update Location

This will not trigger an event and is typically used by on-demand providers for a better user experience.

js
const data = {
  location: {
    coordinates: [40.7531386, -73.9894616],
  },
};

const response = await fetch(`https://api.packagex.io/v1/deliveries/${delivery.id}`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
});

const delivery = response.data;