Engine API

Engine API

Jobs, nodes and actions: the model under every delivery.

Markdown

Every delivery runs as an engine job. The Engine API gives you the job itself, for work a delivery does not describe: several stops, custom actions, your own hooks.

The model

A job is a list of nodes (stops) a bot visits in order. Each node has actions to do there. Packages are what the job carries.

Text
Job ES-5867
├── node pickup    (point V1StGXR8Z5jdHi6BmyT2q)
│   └── action load      (type load,   package pkg-1)
└── node dropoff   (lat 4.6602, lng -74.0521)
    └── action unload    (type unload, package pkg-1)
  • The bot drives to a node, then the node's actions run. When the last one finishes, the bot moves on.
  • An action is hard (blocks the bot and the other actions) or soft (blocks only the bot).
  • load and unload actions are handled by the engine. Other action types are yours: complete them with the API.
  • Hooks call your URL when job events match. Events are the job's history.

Create a job

POST /engine/jobs takes the whole job in one call:

JSON
{
  "namespace": "partner_example",
  "externalId": "order-4821",
  "locationId": "7Nk2QhVpXrLmT4wZaBcDe",
  "name": "Order #4821",
  "nodes": [
    { "name": "pickup", "pointId": "V1StGXR8Z5jdHi6BmyT2q", "actions": [{ "name": "load", "type": "load", "packageName": "pkg-1" }] },
    { "name": "dropoff", "lat": 4.6602, "lng": -74.0521, "actions": [{ "name": "unload", "type": "unload", "packageName": "pkg-1" }] }
  ],
  "packages": [{ "name": "pkg-1" }]
}

By default a bot is assigned for you (assignation: auto) and the job starts once the bot is free (start: auto).

The calls you will use

CallWhen
POST /engine/jobsCreate a job.
GET /engine/jobs/{id}Read it, with its nodes and actions.
POST /engine/jobs/{jobId}/nodes/{nodeName}/actions/{actionName}/completeFinish one of your actions.
POST /engine/jobs/{jobId}/nodes/{nodeName}/actions/{actionName}/loadConfirm a package is in the bot.
POST /engine/jobs/{id}/cancelCall it off.

Next: Job lifecycle, Hooks and events, the API reference.

Edits and versions

Every job has a version that goes up on each change. Send the next version as nextVersion on a change to reject concurrent edits.