1. Containers
  2. Write Containers

Containers

Write Containers

As the shipping provider, you are able to create, update, and delete containers.

WARNING

A container is limited to 250 status changes. They are intended to be used for a single trip and typically range between 10 - 25 tracking updates.

Create Container

POST
`/v1/containers`

You can create a container with no request body, but ideally you would provide an array for container IDs that you wanted to include in the container. You can, however, always add those deliveries later.

js
        const data = {
  deliveries: ["del_82A6o62SfaFeLRctFCMBrt"],
};

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

      

Add Deliveries To Container

POST
`/v1/containers/:container/deliveries`

To update the deliveries in a container, send the deliveries that you want to add as an array and the new deliveries will be appended to the list of existing deliveries in this container.

js
        const data = {
  deliveries: ["del_82A6o62SfaFeLRctFCMBrt"],
};

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

      

Remove Deliveries From Container

DELETE
`/v1/containers/:container/deliveries`

To remove deliveries from a container, send an array of the deliveries that you want to delete. If you delete the whole container, all of the deliveries from that container will be automatically unlinked.

js
        const data = {
  deliveries: ["del_82A6o62SfaFeLRctFCMBrt"],
};

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

      

Update Container

When updating a container, you can update the tracking status which will be appended to the history of the container and can trigger notifications if those are set up. You can also send the location coordinates as often as you would like, though we recommend limiting this to a maximum of once every 30 seconds.

Update Tracking Status

The tracking status for container is updated the same way as it is for deliveries.

js
        const data = {
  tracking_update: {
    //Most providers 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_container",
    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 container
  },
};

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

      

Update Coordinates

You can update the coordinates for the container at any time. This will not create a tracking update but can be used to show the live location on a map.

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

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

const container = response.data;

      

Delete Container

DELETE
`/v1/containers/:container`

When a container is deleted, all deliveries from the container will automatically be unlinked.

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