HyperTrackDocs
Orders

Track Orders

POST
/orders/track

This API allows the creation and immediate tracking of order fulfillment. If the route has been planned and exists in the HyperTrack system, then tracking can be initiated using the route_handle.

Send your own route_handle with orders to create a route under that handle. A retry with the same handle returns the same route (200) and does not create a second one; the orders of a retry are ignored. A handle of a route with a different worker, of a completed route, or of a route with other times returns 409.

Shift routes. Send scheduled_start_at (and auto_complete_at), or tracking_window: shift, to make a shift route. Times that you send always win. With tracking_window: shift, the times that you do not send come from the worker's schedule, else from the schedule of the worker's ops group. The response shows the resolved scheduled_start_at and auto_complete_at. A route with hours from a schedule follows later edits of that schedule until it completes: a route that waits moves to the new hours, a tracking route takes the new end of the current shift. It keeps its times when the edit leaves no current shift, breaks a limit, or overlaps another shift. A route with times you sent, or with times set by a PATCH, does not follow schedule edits. Without tracking_window, a missing auto_complete_at is scheduled_start_at plus 24 hours.

Limits for shift routes: scheduled_start_at is at most 24 hours in the past, and a past start starts tracking at once; auto_complete_at is in the future, after the start, and at most 24 hours after it. A start in the future (at most 24 hours ahead) creates the route as assigned with no tracking; HyperTrack starts tracking at scheduled_start_at, within about one minute, with the route's own track_mode. A call by handle before the start returns the route and does not start it. Another open shift route of the same worker at the same time returns 409 (shift_overlap). A start by handle of a shift route that is not tracking and whose auto_complete_at has passed returns 409 (shift_ended). A shift route needs worker_handle. track_mode stays required; the route keeps the mode of the call.

Schedules are read in the timezone of the worker's ops group (else the ops group of the call) when it is set and is not UTC; else in the timezone of the worker's device; else in UTC. An 08:00 schedule read in UTC starts at 08:00 UTC. A call that sends only auto_complete_at makes a route that is not a shift route, as before.

Authorization

AuthorizationBasic <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/orders/track" \  -H "Content-Type: application/json" \  -d '{    "worker_handle": "james@ht.com",    "track_mode": "full_shift",    "ops_group_handle": "SAN_JOSE_WH",    "orders": [      {        "order_handle": "order-1",        "type": "pick",        "scheduled_at": "2023-11-02T02:00:00Z",        "destination": {          "address": "1709 Automation Pkwy, San Jose, CA 95101",          "geometry": {            "type": "Point",            "coordinates": [              17.803927,              34.832173            ]          },          "radius": 100        }      },      {        "order_handle": "order-2",        "type": "drop",        "scheduled_at": "2023-11-02T02:00:00Z",        "destination": {          "address": "748 Story Rd, San Jose, CA 95112",          "geometry": {            "type": "Point",            "coordinates": [              17.803927,              34.832173            ]          },          "radius": 100        }      }    ]  }'

{  "track_mode": "full_shift",  "route_handle": "7ac07153-5590-46c5-9ada-a6ca84f5b48f",  "status": "tracking",  "version": 1,  "embed_url": "https://embed.hypertrack.com/routes/7ac07153-5590-46c5-9ada-a6ca84f5b48f?publishable_key=a4pvdQPekFgLSuZrwivhJS_Squ6irX1n9sRBIn9nl3PTK-5y3BO56rolpGuzhp1pIoH4TiDyqWIq8IEkOJF5ed",  "orders": [    {      "order_handle": "order-1",      "fulfillment_attempt": 0,      "status": "ongoing",      "destination": {        "geometry": {          "type": "Point",          "coordinates": [            17.803927,            34.832173          ]        },        "address": "1709 Automation Pkwy, San Jose, CA 95101",        "radius": 100      },      "track_mode": "full_shift",      "scheduled_at": "2023-11-02T02:00:00.000Z",      "started_at": "2023-11-01T22:47:56.027Z",      "type": "pick",      "type_index": 0,      "expected_service_time": 0,      "capacity_used": 1,      "share_url": "https://trck.at/PvR4MmWOpw",      "device_id": "FFA58DDB-5CA0-4CD5-8BDE-E4EC7E077E3D",      "worker_handle": "james@ht.com",      "created_at": "2023-11-01T22:47:53.512Z",      "assigned_at": "2023-11-01T22:47:53.857Z",      "route_handle": "7ac07153-5590-46c5-9ada-a6ca84f5b48f",      "planned_at": "2023-11-01T22:47:53.512Z"    },    {      "order_handle": "order-2",      "fulfillment_attempt": 0,      "status": "ongoing",      "destination": {        "geometry": {          "type": "Point",          "coordinates": [            17.803926,            34.832174          ]        },        "address": "748 Story Rd, San Jose, CA 95112",        "radius": 100      },      "track_mode": "full_shift",      "scheduled_at": "2023-11-02T02:00:00.000Z",      "started_at": "2023-11-01T22:47:56.092Z",      "type": "drop",      "type_index": 0,      "expected_service_time": 0,      "capacity_used": 1,      "share_url": "https://trck.at/NqV7Xm22pC",      "device_id": "FFA58DDB-5CA0-4CD5-8BDE-E4EC7E077E3D",      "worker_handle": "james@ht.com",      "created_at": "2023-11-01T22:47:53.512Z",      "assigned_at": "2023-11-01T22:47:53.914Z",      "route_handle": "7ac07153-5590-46c5-9ada-a6ca84f5b48f",      "planned_at": "2023-11-01T22:47:53.512Z"    }  ],  "started_at": "2023-11-01T22:47:54.867Z",  "assigned_at": "2023-11-01T22:47:53.968Z",  "created_at": "2023-11-01T22:47:53.659Z",  "device_id": "FFA58DDB-5CA0-4CD5-8BDE-E4EC7E077E3D",  "worker_handle": "james@ht.com",  "planned_at": "2023-11-01T22:47:53.658Z"}

{  "code": "driver_not_linked_to_device",  "title": "Worker needs to be linked to a device first",  "detail": {    "description": "The worker is not yet linked to a device"  }}

{  "code": "string",  "title": "string",  "detail": "string"}

{  "code": "driver_not_found",  "title": "Worker Not Found",  "detail": {    "description": "Worker not found for handle <driver_handle>"  }}

{  "code": "route_handle_conflict",  "title": "Route Handle Conflict",  "detail": {    "description": "Route <route_handle> does not match this request"  }}