Integrations

Ship.Cars provides an easy way to receive updates for events related to your company through different channels.

Payload

Please refer here for the structure of the payload used for every single event sent from the Ship.Cars platform:

{
  "action": null,
  "actor": "/api/users/gx86/",
  "actor_pk": "gx86",
  "created": false,
  "data": {},
  "deleted": false,
  "event_pk": "99wnyy",
  "object_pk": "386rw4",
  "object_type": "attachment",
  "parent_pk": "k0w6g1",
  "parent_type": "load",
  "timestamp": 1658821836420,
  "url": "/api/events/99wnyy/"
}

Actions

The actions you may receive for each object_type can be found here:

object_typeaction
attachmentpost_to_epod
attachmentNULL
orderaccept
orderassign
orderbroker_cancel
ordercancel
orderclaim
orderdecline
orderdeliver
orderdispatch_to_carrier
orderdriver_seen
orderdump_delivery
orderdump_pickup
orderexpire
ordermark_paid
orderpick_up
orderposted_externally
orderpost_to_epod
orderremove_from_epod
orderrevision
orderset_driver_instructions
ordershipper_cancel
orderstop_demo
orderunassign
orderwill_expire
orderwill_expire_driver_verification
orderNULL
revisionaccept
revisionNULL
vehicleassign
vehicledeliver
vehicledispatch_to_carrier
vehiclepick_up
vehiclepost_to_epod
vehiclepost_to_loadboard
vehiclerevision
vehicleunassign
vehicleNULL

***NULL means that the object was created/deleted or updated, for that you can use created and deleted properties of the payload

Webhooks

When an event related to your company occurs in the Ship.Cars platform, you'll receive an HTTP POST payload to the webhook's configured URL. For security reasons, you should make sure that the incoming request is sent from Ship.Cars. The easiest way to do that is to set up a secret token and validate the information. When your secret token is set, Ship.Cars uses it to create a hash signature with each payload using SHA-256 algoritm. This hash signature is included with the headers of each request as X-Signature.

Example

const express = require('express');
const bodyParser = require('body-parser');
const crypto = require('crypto');

const app = express();
const port = 8080;
const SECRET = "test";

const rawBodyBuffer = (req, res, buf, encoding) => {
  if (buf && buf.length) {
    req.rawBody = buf.toString(encoding || 'utf8');
  }
};

app.use(bodyParser.urlencoded({ verify: rawBodyBuffer, extended: true }));
app.use(bodyParser.json({ verify: rawBodyBuffer }));

app.post('/', (req, res) => {
  const hash = crypto.createHash('sha256').update(SECRET).update(req.rawBody).digest('hex');
  const signatureHeader = req.get("x-signature");
  res.send(hash === signatureHeader ? "yes" : "no");
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})