### Route Optimization Setup Source: https://docs.onfleet.com/reference/initialize-route-optimization-on-demand Sets up the parameters for route optimization and previews the results. This step should be used for error handling before starting the actual route optimization. ```APIDOC ## POST /optimize/routes ### Description Sets up route optimization parameters and previews potential results. This endpoint is crucial for validating input and identifying issues before initiating a full route optimization. ### Method POST ### Endpoint /optimize/routes ### Parameters #### Query Parameters None #### Request Body - **jobType** (string) - Optional - Type of job, e.g., "ON-DEMAND". - **maxTasksPerRoute** (number) - Optional - Maximum number of tasks allowed per route. - **date** (number) - Optional - Timestamp for the optimization date. - **timezone** (string) - Optional - Timezone for the optimization, e.g., "America/Toronto". - **mode** (number) - Optional - Optimization mode identifier. - **serviceTime** (number) - Optional - Default service time for tasks in minutes. - **tasks** (Array of strings) - Optional - An array of task IDs to include in the optimization. - **teams** (object) - Optional - An object mapping team IDs to arrays of worker IDs. - **schedulingMethod** (number) - Optional - Identifier for the scheduling method. - **routeStart** (string) - Required - Specifies the starting point for routes. Allowed values: "teams://DEFAULT", "workers://ROUTING_ADDRESS", "hub://{hub_id}". - **routeEnd** (string) - Required - Specifies the ending point for routes. Allowed values: "teams://DEFAULT", "workers://ROUTING_ADDRESS", "hub://{hub_id}". - **maxViolationTime** (number) - Optional - Maximum allowed violation time in minutes. - **defaultSchedule** (Array of objects) - Optional - Default scheduling details, including date, slots, owner, and timezone. - **date** (number) - Required - Date for the schedule slot. - **slots** (Array of objects) - Required - Time slots for the schedule. - **start** (string) - Required - Start time of the slot (e.g., "0000"). - **end** (string) - Required - End time of the slot (e.g., "2359"). - **owner** (string) - Required - Owner of the schedule slot. - **timezone** (string) - Required - Timezone for the schedule slot. - **osaRouteZoneCount** (Number) - Optional - Only used if RouteZone is involved. ### Request Example ```json { "jobType": "ON-DEMAND", "maxTasksPerRoute": 30, "date": 1718728193838, "timezone": "America/Toronto", "mode": 1, "serviceTime": 15, "tasks": [ "atnk3APxhJrgfx9mgWaRhByQ", "4kA7bOH*Kz7K0YA6~NpqWDke" ], "teams": { "5y1jHFp7OBfFU6SekbwwwRfL": [ "GLlLB2123ABCkXOJAHPklMPZ", "~jCf16ZaT07pdtf~oFb~XAH9" ] }, "schedulingMethod": 1, "routeStart": "teams://DEFAULT", "routeEnd": "teams://DEFAULT", "maxViolationTime": 0, "defaultSchedule": [ { "date": 1718683200000, "slots": [ { "start": "0000", "end": "2359" } ], "owner": "pOoPktB~Hry706w2JT30rJGi", "timezone": "America/Toronto" } ] } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the optimization. Omitted if issues include an error. - **shortId** (string) - A shortened identifier for the optimization. - **issues** (Array of objects) - A list of issues encountered during optimization setup. - **type** (string) - Type of issue: "warning" or "error". Warnings allow optimization to proceed, errors prevent it. - **message** (string) - A user-friendly description of the issue. - **shortId** (string) - The short ID of the entity (e.g., task) causing the issue. - **reason** (string) - An identifier for the specific issue. - **summary** (object) - Provides a summary of the optimization results. Omitted if issues include an error. - **workers** (object) - **count** (number) - Number of workers included. - **tasks** (object) - **count** (number) - Number of tasks included. - **cost** (number) - The cost associated with the tasks. - **routeZones** (object) - **count** (number) - Number of route zones included. - **total** (number) - The total cost of the optimization. #### Response Example ```json { "id": "CQ6rFedL7VBL2VjURsGnb1cx", "issues": [ { "type": "warning", "message": "Task 611552d3 does not have a time range (completeAfter/completeBefore) specified. Add time range for better optimization.", "entityType": "task", "entityId": "atnk3APxhJrgfx9mgWaRhByQ", "shortId": "682589c95927064e", "reason": "no-time-range" }, { "type": "warning", "message": "Task 08607990 does not have a time range (completeAfter/completeBefore) specified. Add time range for better optimization.", "entityType": "task", "entityId": "4kA7bOH*Kz7K0YA6~NpqWDke", "shortId": "08607990", "reason": "no-time-range" } ], "summary": { "workers": { "count": 2 }, "tasks": { "count": 2, "cost": 0.2 }, "routeZones": { "count": 0 }, "total": 0.2 }, "shortId": "682589c95927064e" } ``` ``` -------------------------------- ### List Tasks via cURL Source: https://docs.onfleet.com/reference/list-workers-assigned-tasks Example of listing tasks for a specific worker using cURL. It demonstrates the basic structure of an authenticated GET request to the Onfleet API. ```shell curl -X GET "https://onfleet.com/api/v2/workers/ZKb4r4B*8zWLd4Yam*I77kau/tasks" \ -u "cd3b3de84cc1ee040bf06512d233719c:" ``` -------------------------------- ### GET /websites/onfleet_reference Source: https://docs.onfleet.com/reference/webhook-payload-examples Retrieves information about a specific Onfleet job, including details about the organization, plan, tasks, and processing status. ```APIDOC ## GET /websites/onfleet_reference ### Description Retrieves detailed information about an Onfleet job, including its associated tasks, routing plan, and completion status. ### Method GET ### Endpoint /websites/onfleet_reference ### Parameters #### Query Parameters - **organization** (string) - Optional - The ID of the organization. - **plan** (object) - Optional - Details of the routing plan. - **routes** (array) - Optional - An array of route objects. - **routeId** (string) - Optional - The unique identifier for the route. - **stops** (array) - Optional - An array of stop objects within the route. - **arrivalTime** (number) - Optional - The timestamp when the stop is arrived. - **departTime** (number) - Optional - The timestamp when the stop is departed. - **id** (string) - Optional - The unique identifier for the stop. - **type** (string) - Optional - The type of stop (e.g., TASK). - **unplanned** (array) - Optional - An array of unplanned tasks. - **tasks** (array) - Optional - An array of task objects. - **additionalQuantities** (object) - Optional - Additional quantity details. - **quantityA** (number) - Optional - Quantity A. - **quantityB** (number) - Optional - Quantity B. - **quantityC** (number) - Optional - Quantity C. - **completeAfter** (number) - Optional - The earliest time the task can be completed. - **completeBefore** (number) - Optional - The latest time the task must be completed. - **id** (string) - Optional - The unique identifier for the task. - **pickupTask** (boolean) - Optional - Indicates if the task is a pickup task. - **quantity** (number) - Optional - The quantity for the task. - **shortId** (string) - Optional - A short, unique identifier for the task. - **team** (string) - Optional - The ID of the team associated with the job. - **options** (object) - Optional - Configuration options for the job. - **maxAllowedDelay** (number) - Optional - The maximum allowed delay in minutes. - **maxTasksPerRoute** (number) - Optional - The maximum number of tasks allowed per route. - **routeEnd** (string) - Optional - The destination for the route. - **scheduleTimeWindow** (array) - Optional - An array of two timestamps representing the schedule time window. - **serviceTime** (number) - Optional - The estimated service time in minutes. - **taskTimeWindow** (array) - Optional - An array of two timestamps representing the task time window. - **processingDetails** (object) - Optional - Details about the job processing. - **endTime** (number) - Optional - The timestamp when the processing ended. - **startTime** (number) - Optional - The timestamp when the processing started. - **status** (string) - Optional - The status of the processing (e.g., success). ### Response #### Success Response (200) - **options** (object) - Job configuration options. - **organization** (string) - The organization ID. - **plan** (object) - The routing plan details. - **processingDetails** (object) - Processing status and times. - **tasks** (array) - Array of task objects. - **team** (string) - The team ID. - **dispatchId** (string) - The dispatch ID. - **taskId** (string) - The task ID (null if not applicable). - **time** (number) - Timestamp of the event. - **triggerId** (number) - The ID of the trigger. - **triggerName** (string) - The name of the trigger. - **workerId** (string) - The worker ID (null if not applicable). #### Response Example ```json { "options": { "maxAllowedDelay": 10, "maxTasksPerRoute": 50, "routeEnd": "teams://DEFAULT", "scheduleTimeWindow": [ 1659727323264, 1659748923264 ], "serviceTime": 4, "taskTimeWindow": [ 1659712923264, 1659741723264 ] }, "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "plan": { "routes": [ { "routeId": "ZxcnkJi~79nonYaMTQ960Mg2", "stops": [ { "arrivalTime": 1659729556337, "departTime": 1659729796337, "id": "LdvrBX7fADEvlNuFUZJu8d9S", "type": "TASK" }, { "arrivalTime": 1659733290968, "departTime": 1659733530968, "id": "~JA*OXe7f6sLzy~zo6brH6xp", "type": "TASK" }, { "arrivalTime": 1659737162319, "departTime": 1659737402319, "id": "bn50Lcsu8rqETDWJTIdecufy", "type": "TASK" }, { "arrivalTime": 1659738493969, "departTime": 1659738733969, "id": "Sef4w3TakQk6dQJBhQDYglsO", "type": "TASK" } ], "type": "WORKER" } ], "unplanned": [] }, "processingDetails": { "endTime": 1659727327650, "startTime": 1659727323428, "status": "success" }, "tasks": [ { "additionalQuantities": { "quantityA": 0, "quantityB": 0, "quantityC": 0 }, "completeAfter": null, "completeBefore": null, "id": "Sef4w3TakQk6dQJBhQDYglsO", "pickupTask": false, "quantity": 0, "shortId": "2770e3e3" }, { "additionalQuantities": { "quantityA": 0, "quantityB": 0, "quantityC": 0 }, "completeAfter": 1659726000000, "completeBefore": 1659751200000, "id": "LdvrBX7fADEvlNuFUZJu8d9S", "pickupTask": false, "quantity": 0, "shortId": "ce6439b7" }, { "additionalQuantities": { "quantityA": 0, "quantityB": 0, "quantityC": 0 }, "completeAfter": 1659726000000, "completeBefore": 1659747600000, "id": "bn50Lcsu8rqETDWJTIdecufy", "pickupTask": false, "quantity": 0, "shortId": "6d87d2bf" }, { "additionalQuantities": { "quantityA": 0, "quantityB": 0, "quantityC": 0 }, "completeAfter": 1659726000000, "completeBefore": 1659754800000, "id": "~JA*OXe7f6sLzy~zo6brH6xp", "pickupTask": false, "quantity": 0, "shortId": "2e2f201c" } ], "team": "K3FXFtJj2FtaO2~H60evRrDc", "dispatchId": "XaSPx65XPOTiyzu7hbjlgTxN", "taskId": null, "time": 1659727327697, "triggerId": 18, "triggerName": "autoDispatchJobCompleted", "workerId": null } ``` ``` -------------------------------- ### Route Plan Started Webhook Source: https://docs.onfleet.com/reference/webhook-payload-examples This webhook is triggered when a route plan associated with a worker begins. It provides detailed information about the worker and the route plan. ```APIDOC ## Route Plan Started Webhook ### Description This webhook event is triggered when a worker starts a route plan. It includes comprehensive details about the worker initiating the route and the specific route plan that has been started. ### Method POST ### Endpoint `/webhooks` (This is a conceptual endpoint; actual webhook URLs are configured in the Onfleet dashboard) ### Parameters No path or query parameters are typically used for webhook endpoints. All information is contained within the request body. #### Request Body - **workerId** (string) - The unique identifier of the worker who started the route plan. - **actionContext** (object) - Contextual information about the action that triggered the webhook. - **type** (string) - The type of action context, typically 'WORKER'. - **id** (string) - The ID associated with the action context, usually the worker ID. - **triggerId** (integer) - A numerical ID representing the trigger event. - **triggerName** (string) - The name of the trigger event, e.g., 'routePlanStarted'. - **taskId** (string | null) - The ID of the task associated with the trigger, if applicable. - **adminId** (string | null) - The ID of the administrator who initiated the action, if applicable. - **data** (object) - Contains the main payload of the webhook. - **worker** (object) - Detailed information about the worker. - **id** (string) - Worker's unique identifier. - **timeCreated** (integer) - Timestamp when the worker was created (Unix milliseconds). - **timeLastModified** (integer) - Timestamp when the worker was last modified (Unix milliseconds). - **organization** (string) - The organization ID the worker belongs to. - **name** (string) - The worker's name. - **displayName** (string) - The worker's display name. - **phone** (string) - The worker's phone number. - **activeTask** (string) - The ID of the worker's currently active task. - **tasks** (array of strings) - List of task IDs assigned to the worker. - **onDuty** (boolean) - Indicates if the worker is currently on duty. - **timeLastSeen** (integer) - Timestamp of the worker's last activity (Unix milliseconds). - **capacity** (integer) - The worker's total capacity. - **additionalCapacities** (object) - Worker's additional capacity details (e.g., capacityA, capacityB). - **userData** (object) - User-specific data from the worker's app. - **platform** (string) - Operating system of the worker's device. - **appVersion** (string) - Version of the Onfleet app used by the worker. - **deviceDescription** (string) - Description of the worker's device. - **batteryLevel** (float) - Current battery level of the worker's device. - **accountStatus** (string) - The worker's account status (e.g., 'ACCEPTED'). - **metadata** (array) - Array of metadata associated with the worker. - **timezone** (string) - The worker's timezone. - **teams** (array of strings) - List of team IDs the worker belongs to. - **imageUrl** (string | null) - URL of the worker's image, if available. - **delayTime** (integer | null) - Delay time in minutes, if applicable. - **vehicle** (object) - Details about the worker's vehicle. - **id** (string) - Vehicle's unique identifier. - **type** (string) - Type of vehicle (e.g., 'CAR'). - **description** (string) - Description of the vehicle. - **licensePlate** (string) - Vehicle's license plate number. - **color** (string) - Color of the vehicle. - **timeCreated** (integer) - Timestamp when the vehicle was created (Unix milliseconds). - **timeLastModified** (integer) - Timestamp when the vehicle was last modified (Unix milliseconds). - **location** (array of floats) - The worker's current geographical coordinates [longitude, latitude]. - **hasRecentlyUsedSpoofedLocations** (boolean) - Indicates if the worker has recently used spoofed locations. - **routePlan** (object) - Detailed information about the route plan. - **id** (string) - Route plan's unique identifier. - **name** (string) - Name of the route plan. - **state** (string) - Current state of the route plan (e.g., 'IN_PROGRESS'). - **color** (string) - Color code associated with the route plan. - **tasks** (array of strings) - List of task IDs included in the route plan. - **organization** (string) - The organization ID the route plan belongs to. - **team** (string) - The team ID assigned to the route plan. - **worker** (string) - The worker ID assigned to the route plan. - **vehicleType** (string) - The type of vehicle designated for the route plan. - **startTime** (integer) - Scheduled start time of the route plan (Unix milliseconds). - **endTime** (integer) - Scheduled end time of the route plan (Unix milliseconds). - **actualStartTime** (integer | null) - Actual start time of the route plan (Unix milliseconds). - **actualEndTime** (integer | null) - Actual end time of the route plan (Unix milliseconds). - **startAt** (string) - Where the route plan starts (e.g., 'HUB'). - **endAt** (string) - Where the route plan ends (e.g., 'HUB'). - **startingHubId** (string) - ID of the starting hub. - **endingHubId** (string) - ID of the ending hub. - **shortId** (string) - A shorter identifier for the route plan. - **timeCreated** (integer) - Timestamp when the route plan was created (Unix milliseconds). - **timeLastModified** (integer) - Timestamp when the route plan was last modified (Unix milliseconds). - **timezone** (string) - The timezone of the route plan's location. - **isOverdue** (boolean) - Indicates if the route plan is overdue. - **taskStates** (array of integers) - Status codes for each task in the route plan. - **status** (string) - Overall status of the route plan (e.g., 'ON_TIME'). - **statusTimeDifference** (integer) - Time difference in seconds related to the status. - **routePlanId** (string) - The ID of the route plan that was started. - **time** (integer) - Timestamp when the webhook event occurred (Unix milliseconds). ### Request Example ```json { "workerId": "ZxcnkJi~79nonYaMTQ960Mg2", "actionContext": { "type": "WORKER", "id": "ZxcnkJi~79nonYaMTQ960Mg2" }, "triggerId": 23, "triggerName": "routePlanStarted", "taskId": null, "adminId": null, "data": { "worker": { "id": "ZxcnkJi~79nonYaMTQ960Mg2", "timeCreated": 1618618787000, "timeLastModified": 1740187269639, "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "name": "Test", "displayName": "", "phone": "+16265551352", "activeTask": "3BYnnvosDgeC6EYx9pl3Q*df", "tasks": [ "6rotzvbI9B~ndLEjc83dte7z", "OGeFpIlO0n0QaYpXZERGU2qk", "Oq6yHKB54KgkTR*Lfc6MkZIB", "3Fz3Ql*02UzzqvqWbxgust8T", "RPvhr0DBIPvFG204hkTA03WK" ], "onDuty": true, "timeLastSeen": 1740187267010, "capacity": 99999, "additionalCapacities": { "capacityA": 99999, "capacityB": 99999, "capacityC": 99999 }, "userData": { "platform": "ANDROID", "appVersion": "2.3.15", "deviceDescription": "Google Pixel 6 (Android 15)", "batteryLevel": 0.35 }, "accountStatus": "ACCEPTED", "metadata": [], "timezone": "America/Los_Angeles", "teams": [ "E2*f4lzgvpwwNMvDEHPLJVrr", "K3FXFtJj2FtaO2~H60evRrDc", "ALgQiBXohg7AmGptc5mZ7khM", "pLRndrnaT3TLJQ~Tul*V0CtM" ], "imageUrl": null, "delayTime": null, "vehicle": { "id": "~SI~KQpoXCcjBcIfQP2MbxE4", "type": "CAR", "description": "Hondi", "licensePlate": "www.msn.com", "color": "Zorak", "timeCreated": 1726865929000, "timeLastModified": 1726865929427 }, "location": [ -117.8901201, 33.8933597 ], "hasRecentlyUsedSpoofedLocations": false }, "routePlan": { "id": "NttBsEQR6lDe9dt3SsK3EQTO", "name": "Create Route Plan Test 3", "state": "IN_PROGRESS", "color": "#D864D8", "tasks": [ "3BYnnvosDgeC6EYx9pl3Q*df", "RPvhr0DBIPvFG204hkTA03WK" ], "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "team": "K3FXFtJj2FtaO2~H60evRrDc", "worker": "ZxcnkJi~79nonYaMTQ960Mg2", "vehicleType": "CAR", "startTime": 1740187800000, "endTime": 1740189659999, "actualStartTime": 1740187269648, "actualEndTime": null, "startAt": "HUB", "endAt": "HUB", "startingHubId": "FK9Uny9sQzcvBmEqHXqwWSeV", "endingHubId": "FK9Uny9sQzcvBmEqHXqwWSeV", "shortId": "e1e8075f", "timeCreated": 1740187150310, "timeLastModified": 1740187269649, "timezone": "America/Los_Angeles", "isOverdue": false, "taskStates": [ 2, 1 ], "status": "ON_TIME", "statusTimeDifference": 0 } }, "routePlanId": "NttBsEQR6lDe9dt3SsK3EQTO", "time": 1740187269650 } ``` ### Response Webhooks do not typically return a response body in the traditional sense. The receiving server should return an HTTP status code (e.g., 200 OK) to acknowledge receipt of the webhook. Errors may be indicated by non-2xx status codes, which the sending service might retry based on its configuration. #### Success Response (200 OK) Indicates that the webhook was received successfully by the endpoint. #### Response Example (No explicit JSON response body is expected from the webhook receiver) ``` -------------------------------- ### Onfleet Task Started Event Structure Source: https://docs.onfleet.com/reference/webhook-payload-examples This JSON object details the structure of an 'taskStarted' event in Onfleet. It includes comprehensive information about the task that has commenced, including its destination, recipient, and associated worker. ```json { "actionContext": { "id": "COwfwH~Zogm1LXIZYbPlLAyw", "type": "WORKER" }, "adminId": null, "data": { "task": { "appearance": { "triangleColor": null }, "completeAfter": 1612987200000, "completeBefore": 1613008800000, "completionDetails": { "actions": [], "events": [], "failureNotes": "", "failureReason": "NONE", "firstLocation": [], "lastLocation": [], "time": null, "unavailableAttachments": [] }, "container": { "type": "WORKER", "worker": "COwfwH~Zogm1LXIZYbPlLAyw" }, "creator": "vjw*RDMKDljKVDve1Vtcplgu", "dependencies": [], "destination": { "address": { "apartment": "", "city": "Anaheim", "country": "United States", "name": "Honda Center", "number": "2695", "postalCode": "92806", "state": "California", "street": "East Katella Avenue" }, "id": "I5rMyWx4YHDcMGIwfD3TL8nf", "location": [ -117.8764687, 33.8078476 ], "metadata": [], "notes": "This is a destination note", "timeCreated": 1613002583000, "timeLastModified": 1613002583913 }, "estimatedArrivalTime": null, "estimatedCompletionTime": null, "executor": "nYrkNP6jZMSKgBwG9qG7ci3J", "feedback": [], "id": "txiK2xHBIaUwAKB~BJrjscKu", "identity": { "checksum": null, "failedScanCount": 0 }, "merchant": "nYrkNP6jZMSKgBwG9qG7ci3J", "metadata": [], "notes": "This is a Task note", "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "overrides": {}, "pickupTask": false, "quantity": 1, "recipients": [ { "id": "A~pBTrc5~dTMBBImswg7U4YT", "metadata": [], "name": "Test User One", "notes": "This is a recipient note", "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "phone": "+17145554231", "skipSMSNotifications": false, "timeCreated": 1613002583000, "timeLastModified": 1613002583931 } ], "serviceTime": 3, "shortId": "fab829cf", "state": 2, "timeCreated": 1613002583000, "timeLastModified": 1613004361613, "trackingURL": "https://onf.lt/fab829cf81", "trackingViewed": false, "worker": "COwfwH~Zogm1LXIZYbPlLAyw" } }, "taskId": "txiK2xHBIaUwAKB~BJrjscKu", "time": 1613004361894, "triggerId": 0, "triggerName": "taskStarted", "workerId": "COwfwH~Zogm1LXIZYbPlLAyw" } ``` -------------------------------- ### Route Plan Data Structure (JSON) Source: https://docs.onfleet.com/reference/webhook-payload-examples Details of a route plan, including its ID, name, state, color, associated tasks, organization, team, worker, vehicle type, planned start and end times, actual times, and status. Also includes planning metrics like distance and duration, and overdue status. ```json { "id": "zx24ffE4UZ7di*ABoHMXWTpp", "name": "RSL_01-23-2025_0000", "state": "PENDING", "color": "#A8E7F0", "tasks": [ "pAXUqLIff26zYzf0cG5hsCwz", "tsDD0Wa2liTy6sjTSYBhGqIH" ], "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "team": "E2*f4lzgvpwwNMvDEHPLJVrr", "worker": "ZKb4r4B*8zWLd4Yam*I77kau", "vehicleType": "CAR", "startTime": 1737619200000, "endTime": null, "actualStartTime": null, "actualEndTime": null, "startAt": "WORKER_LOCATION", "endAt": "WORKER_LOCATION", "startingHubId": null, "endingHubId": null, "shortId": "b26daebf", "timeCreated": 1737676265844, "timeLastModified": 1737676265844, "timezone": "America/Los_Angeles", "plannedDistance": 139990.0802512778, "plannedDuration": 7998.590480200946, "isOverdue": true, "taskStates": [ 1, 1 ], "status": "LATE", "statusTimeDifference": 6801081332 } ``` -------------------------------- ### Route Plan Started Webhook Data - JSON Source: https://docs.onfleet.com/reference/webhook-payload-examples This JSON object details the payload for a 'routePlanStarted' webhook event. It contains information about the worker and the route plan that has just begun, including task assignments and current status. This data can be used to initiate real-time tracking or update operational dashboards. ```json { "workerId": "ZxcnkJi~79nonYaMTQ960Mg2", "actionContext": { "type": "WORKER", "id": "ZxcnkJi~79nonYaMTQ960Mg2" }, "triggerId": 23, "triggerName": "routePlanStarted", "taskId": null, "adminId": null, "data": { "worker": { "id": "ZxcnkJi~79nonYaMTQ960Mg2", "timeCreated": 1618618787000, "timeLastModified": 1740187269639, "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "name": "Test", "displayName": "", "phone": "+16265551352", "activeTask": "3BYnnvosDgeC6EYx9pl3Q*df", "tasks": [ "6rotzvbI9B~ndLEjc83dte7z", "OGeFpIlO0n0QaYpXZERGU2qk", "Oq6yHKB54KgkTR*Lfc6MkZIB", "3Fz3Ql*02UzzqvqWbxgust8T", "RPvhr0DBIPvFG204hkTA03WK" ], "onDuty": true, "timeLastSeen": 1740187267010, "capacity": 99999, "additionalCapacities": { "capacityA": 99999, "capacityB": 99999, "capacityC": 99999 }, "userData": { "platform": "ANDROID", "appVersion": "2.3.15", "deviceDescription": "Google Pixel 6 (Android 15)", "batteryLevel": 0.35 }, "accountStatus": "ACCEPTED", "metadata": [], "timezone": "America/Los_Angeles", "teams": [ "E2*f4lzgvpwwNMvDEHPLJVrr", "K3FXFtJj2FtaO2~H60evRrDc", "ALgQiBXohg7AmGptc5mZ7khM", "pLRndrnaT3TLJQ~Tul*V0CtM" ], "imageUrl": null, "delayTime": null, "vehicle": { "id": "~SI~KQpoXCcjBcIfQP2MbxE4", "type": "CAR", "description": "Hondi", "licensePlate": "www.msn.com", "color": "Zorak", "timeCreated": 1726865929000, "timeLastModified": 1726865929427 }, "location": [ -117.8901201, 33.8933597 ], "hasRecentlyUsedSpoofedLocations": false }, "routePlan": { "id": "NttBsEQR6lDe9dt3SsK3EQTO", "name": "Create Route Plan Test 3", "state": "IN_PROGRESS", "color": "#D864D8", "tasks": [ "3BYnnvosDgeC6EYx9pl3Q*df", "RPvhr0DBIPvFG204hkTA03WK" ], "organization": "nYrkNP6jZMSKgBwG9qG7ci3J", "team": "K3FXFtJj2FtaO2~H60evRrDc", "worker": "ZxcnkJi~79nonYaMTQ960Mg2", "vehicleType": "CAR", "startTime": 1740187800000, "endTime": 1740189659999, "actualStartTime": 1740187269648, "actualEndTime": null, "startAt": "HUB", "endAt": "HUB", "startingHubId": "FK9Uny9sQzcvBmEqHXqwWSeV", "endingHubId": "FK9Uny9sQzcvBmEqHXqwWSeV", "shortId": "e1e8075f", "timeCreated": 1740187150310, "timeLastModified": 1740187269649, "timezone": "America/Los_Angeles", "isOverdue": false, "taskStates": [ 2, 1 ], "status": "ON_TIME", "statusTimeDifference": 0 } }, "routePlanId": "NttBsEQR6lDe9dt3SsK3EQTO" } ``` -------------------------------- ### POST /taskBatchCreateJobCompleted Source: https://docs.onfleet.com/reference/webhook-payload-examples Handles the completion of a batch of tasks, reporting the number of tasks received, created, and any errors encountered. ```APIDOC ## POST /taskBatchCreateJobCompleted ### Description This endpoint is triggered upon the completion of a batch task creation job. It reports the status of the job, including the number of tasks processed and any errors that occurred. ### Method POST ### Endpoint /taskBatchCreateJobCompleted ### Request Body - **jobId** (string) - Required - The unique identifier for the batch job. - **status** (string) - Required - The completion status of the job (e.g., "completedWithErrors"). - **tasksReceived** (number) - Required - The total number of tasks received for processing. - **tasksCreated** (number) - Required - The number of tasks successfully created. - **tasksErrored** (number) - Required - The number of tasks that resulted in an error. - **errors** (array) - Optional - An array of error objects if any tasks failed. - **statusCode** (number) - Required - The HTTP status code associated with the error. - **errorCode** (number) - Required - A specific error code from Onfleet. ### Request Example ```json { "jobId": "C1i7NK46Jtxod2WIkZDGf1~1", "status": "completedWithErrors", "tasksReceived": 3, "tasksCreated": 2, "tasksErrored": 1, "errors": [ { "statusCode": 400, "errorCode": 1000 } ] } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the job completion was processed. #### Response Example ```json { "message": "Task batch job completion recorded successfully." } ``` ```