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_type | action |
---|---|
attachment | post_to_epod |
attachment | NULL |
order | accept |
order | assign |
order | broker_cancel |
order | cancel |
order | claim |
order | decline |
order | deliver |
order | dispatch_to_carrier |
order | driver_seen |
order | dump_delivery |
order | dump_pickup |
order | expire |
order | mark_paid |
order | pick_up |
order | posted_externally |
order | post_to_epod |
order | remove_from_epod |
order | revision |
order | set_driver_instructions |
order | shipper_cancel |
order | stop_demo |
order | unassign |
order | will_expire |
order | will_expire_driver_verification |
order | NULL |
revision | accept |
revision | NULL |
vehicle | assign |
vehicle | deliver |
vehicle | dispatch_to_carrier |
vehicle | pick_up |
vehicle | post_to_epod |
vehicle | post_to_loadboard |
vehicle | revision |
vehicle | unassign |
vehicle | NULL |
***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}`)
})
Updated over 2 years ago