List tasks

List tasks

📘

Get Tasks already assigned to Worker

If you are looking for a list tasks or a "route" of a worker, please refer to Get single worker or List Worker's Assigned Tasks.

This section returns a paginated collection of all tasks in your organization.

The from and to time range query parameters are considered differently depending on task state.

  • Completed tasks: time comparison performed on task completion time
  • All other task states: time comparison performed on task creation time

The returned tasks are always sorted by creation time. Each request will return up to 64 tasks but may return fewer and still include a lastId. lastId will be missing from the response once the last page of the results has been reached, so if the lastId is present, you should continue to paginate through the results.

Query parameters

NameDescription
fromRequired. The starting time in Unix time of the search range. Tasks created or completed at or after this time will be included.
toOptional. If missing, defaults to the current time. The ending time in Unix time of the range. Tasks created or completed before this time will be included.
lastIdOptional. Used to walk the paginated response, if there is one. Tasks created after this ID will be returned.
stateOptional. A comma-separated list of task states.
workerOptional. The ID of a worker whom is currently assigned to the tasks or has previously completed the tasks.
completeBeforeBeforeOptional. The timestamp in Unix time before which the task completeBefore value must be.
completeAfterAfterOptional. The timestamp in Unix time after which the task completeAfter value must be.
dependenciesOptional. A comma-separated list of dependency task ids. A task gets returned in the response if it has at least one of the dependencies provided.

📘

Unix Time

Onfleet API only accepts time formatted in Unix to the millisecond precision. Any other formats are not accepted and may produce unexpected results.

📘

Data Types and Response Formats

For more information on datatype and formats, please see Data Types and Response Formats or free conversion tool online here.

🚧

502 Internal Timed out

Onfleet has an internal system timeout of 70 seconds, which can be encountered when listing tasks. If the 502 error comes up, try narrowing your search parameters so that query can be executed more quickly.

🚧

Parameters

When a search parameter key contains more than one value, the acceptable method is to supply those parameters with comma delimiters. For example:

Valid Input: /api/v2/tasks/all?from=1455072025000&state=1,2,3

Invalid input: /api/v2/tasks/all?from=1455072025000&state=1&state=2&state=3

To walk through the pagination of all tasks from the from timestamp, append another query parameter of lastId=<lastId_from_previous_response> to your HTTP request (see examples on the side bar).

curl -X GET "https://onfleet.com/api/v2/tasks/all?from=1455072025000" \
       -u "cd3b3de84cc1ee040bf06512d233719c:"
$ curl -X GET "https://onfleet.com/api/v2/tasks/all?from=1455072025000&lastId=tPMO~h03sOIqFbnhqaOXgUsd" \
       -u "cd3b3de84cc1ee040bf06512d233719c:"
onfleet.tasks.get(queryParams={"from":1455072025000, "lastId": "tPMO~h03sOIqFbnhqaOXgUsd"})
onfleet.tasks.get({"from":1455072025000, "lastId": "tPMO~h03sOIqFbnhqaOXgUsd"});
$onfleet->tasks->get(["from"=>1455072025000, "lastId"=> "tPMO~h03sOIqFbnhqaOXgUsd"]);
{
  "lastId": "tPMO~h03sOIqFbnhqaOXgUsd",
  "tasks": [
    {
      "id": "11z1BbsQUZFHD1XAd~emDDeK",
      "timeCreated": 1455072025000,
      "timeLastModified": 1455072025278,
      "organization": "yAM*fDkztrT3gUcz9mNDgNOL",
      "shortId": "31aac0a5",
      "trackingURL": "https://onf.lt/31aac0a5c",
      "worker": "h*wSb*apKlDkUFnuLTtjPke7",
      "merchant": "yAM*fDkztrT3gUcz9mNDgNOL",
      "executor": "yAM*fDkztrT3gUcz9mNDgNOL",
      "creator": "EJmsbJgHiRLPjNVE7GEIPs7*",
      "dependencies": [],
      "state": 1,
      "completeAfter": null,
      "completeBefore": null,
      "pickupTask": false,
      "notes": "",
      "completionDetails": {
        "events": [],
        "time": null
      },
      "feedback": [],
      "metadata": [],
      "overrides": {},
      "container": {
        "type": "WORKER",
        "worker": "h*wSb*apKlDkUFnuLTtjPke7"
      },
      "recipients": [
        {
          "id": "xX87G1gSkeLvGXlHn2tn0~iB",
          "organization": "yAM*fDkztrT3gUcz9mNDgNOL",
          "timeCreated": 1455072004000,
          "timeLastModified": 1455072025272,
          "name": "Blake Turing",
          "phone": "+16505552811",
          "notes": "",
          "skipSMSNotifications": false,
          "metadata": []
        }
      ],
      "destination": {
        "id": "pfT5L1JclTdhvRnP9GQzMFuL",
        "timeCreated": 1455072025000,
        "timeLastModified": 1455072025264,
        "location": [
          -122.41289010000003,
          37.787933
        ],
        "address": {
          "apartment": "",
          "state": "California",
          "postalCode": "94109",
          "country": "United States",
          "city": "San Francisco",
          "street": "Post Street",
          "number": "666"
        },
        "notes": "",
        "metadata": []
      }
    },
    {
      "id": "kc8SS1tzuZ~jqjlebKGrUmpe",
      "timeCreated": 1455156667000,
      "timeLastModified": 1455156667234,
      "organization": "yAM*fDkztrT3gUcz9mNDgNOL",
      "shortId": "8f983639",
      "trackingURL": "https://onf.lt/8f98363993",
      "worker": "1LjhGUWdxFbvdsTAAXs0TFos",
      "merchant": "yAM*fDkztrT3gUcz9mNDgNOL",
      "executor": "yAM*fDkztrT3gUcz9mNDgNOL",
      "creator": "EJmsbJgHiRLPjNVE7GEIPs7*",
      "dependencies": [],
      "state": 1,
      "completeAfter": 1455151071727,
      "completeBefore": null,
      "pickupTask": false,
      "notes": "Order 332: 24oz Stumptown Finca El Puente, 10 x Aji de Gallina Empanadas, 13-inch Lelenitas Tres Leches",
      "completionDetails": {
        "events": [],
        "time": null
      },
      "feedback": [],
      "metadata": [],
      "overrides": {
        "recipientSkipSMSNotifications": null,
        "recipientNotes": null,
        "recipientName": null
      },
      "container": {
        "type": "WORKER",
        "worker": "1LjhGUWdxFbvdsTAAXs0TFos"
      },
      "recipients": [
        {
          "id": "G7rcM2nqblmh8vj2do1FpaOQ",
          "organization": "yAM*fDkztrT3gUcz9mNDgNOL",
          "timeCreated": 1455156667000,
          "timeLastModified": 1455156667229,
          "name": "Blas Silkovich",
          "phone": "+16505554481",
          "notes": "Knows Neiman, VIP status.",
          "skipSMSNotifications": false,
          "metadata": []
        }
      ],
      "destination": {
        "id": "zrVXZi5aDzOZlAghZaLfGAfA",
        "timeCreated": 1455156667000,
        "timeLastModified": 1455156667220,
        "location": [
          -122.4438337,
          37.7940329
        ],
        "address": {
          "apartment": "",
          "state": "California",
          "postalCode": "94123",
          "country": "United States",
          "city": "San Francisco",
          "street": "Vallejo Street",
          "number": "2829"
        },
        "notes": "Small green door by garage door has pin pad, enter *4821*",
        "metadata": []
      }
    },
    // ...
  ]
}
{
    "tasks": [
        {
            "id": "bWL10V21mB6giapTE7PypWU2",
            "timeCreated": 1621442960000,
            "timeLastModified": 1621442960755,
            "organization": "uxwrkxcKznAJjGB*jGUAwM3t",
            "shortId": "f1b4a2da",
            "trackingURL": "https://onf.lt/f1b4a2dab4",
            "worker": null,
            "merchant": "uxwrkxcKznAJjGB*jGUAwM3t",
            "executor": "uxwrkxcKznAJjGB*jGUAwM3t",
            "creator": "UBbmzKBzn5LMFmTZ5Hla~J2D",
            "dependencies": [],
            "state": 0,
            "completeAfter": 1622131200000,
            "completeBefore": 1622142000000,
            "pickupTask": false,
            "notes": "Kappa, rock, jacka (2)\nKavaj (3)\n",
            "completionDetails": {
                "failureNotes": "",
                "failureReason": "NONE",
                "events": [],
                "actions": [],
                "time": null,
                "firstLocation": [],
                "lastLocation": [],
                "unavailableAttachments": []
            },
            "feedback": [],
            "metadata": [
                {
                    "visibility": [
                        "api"
                    ],
                    "name": "meta",
                    "type": "array",
                    "subtype": "string",
                    "value": [
                        "keg8oWpeXzREJy5xUVurwPVS4tn2",
                        "-Ma4WyOgFd1DthKwxi23",
                        false
                    ]
                }
            ],
            "overrides": {
                "recipientName": null,
                "recipientNotes": null,
                "recipientSkipSMSNotifications": null,
                "useMerchantForProxy": null
            },
            "quantity": 0,
            "serviceTime": 0,
            "identity": {
                "failedScanCount": 0,
                "checksum": null
            },
            "appearance": {
                "triangleColor": null
            },
            "container": {
                "type": "ORGANIZATION",
                "organization": "uxwrkxcKznAJjGB*jGUAwM3t"
            },
            "trackingViewed": false,
            "delayTime": null,
            "estimatedCompletionTime": null,
            "estimatedArrivalTime": null,
            "eta": null,
            "destination": {
                "id": "WsVFLcIylXOOsdxTit9Yyt~u",
                "timeCreated": 1621442960000,
                "timeLastModified": 1621442960697,
                "location": [
                    18.0997411,
                    59.43327010000001
                ],
                "address": {
                    "apartment": "Floor: 0",
                    "state": "Stockholm",
                    "postalCode": "183 57",
                    "country": "Sweden",
                    "street": "Vallarevägen 7",
                    "city": "Stockholm"
                },
                "notes": "Doorcode: 0000",
                "metadata": [],
                "googlePlaceId": null,
                "warnings": []
            },
            "recipients": [
                {
                    "id": "pQyZC7LP0meRKczgOracihH8",
                    "timeCreated": 1621442954000,
                    "timeLastModified": 1621442960714,
                    "name": "Yvonne  Perman",
                    "phone": "+46723863419",
                    "notes": "\n\nLämna på baksidan om ingen öppnar ",
                    "organization": "uxwrkxcKznAJjGB*jGUAwM3t",
                    "skipSMSNotifications": false,
                    "metadata": []
                }
            ]
        },
        {
            "id": "Z7nHQLn4AWJO5VC4c3W0TNUO",
            "timeCreated": 1621443102000,
            "timeLastModified": 1621443102960,
            "organization": "uxwrkxcKznAJjGB*jGUAwM3t",
            "shortId": "cbd16edb",
            "trackingURL": "https://onf.lt/cbd16edb0b",
            "worker": null,
            "merchant": "uxwrkxcKznAJjGB*jGUAwM3t",
            "executor": "uxwrkxcKznAJjGB*jGUAwM3t",
            "creator": "UBbmzKBzn5LMFmTZ5Hla~J2D",
            "dependencies": [],
            "state": 0,
            "completeAfter": 1621612800000,
            "completeBefore": 1621623600000,
            "pickupTask": true,
            "notes": "Kavaj (2)\n",
            "completionDetails": {
                "failureNotes": "",
                "failureReason": "NONE",
                "events": [],
                "actions": [],
                "time": null,
                "firstLocation": [],
                "lastLocation": [],
                "unavailableAttachments": []
            },
            "feedback": [],
            "metadata": [
                {
                    "visibility": [
                        "api"
                    ],
                    "name": "meta",
                    "type": "array",
                    "subtype": "string",
                    "value": [
                        "Wdll09C3sqcJUVia1yJIB8pwHfs2",
                        "-Ma4XYbeD5J5__algrSX",
                        false
                    ]
                }
            ],
            "overrides": {
                "recipientName": null,
                "recipientNotes": null,
                "recipientSkipSMSNotifications": null,
                "useMerchantForProxy": null
            },
            "quantity": 0,
            "serviceTime": 0,
            "identity": {
                "failedScanCount": 0,
                "checksum": null
            },
            "appearance": {
                "triangleColor": null
            },
            "container": {
                "type": "ORGANIZATION",
                "organization": "uxwrkxcKznAJjGB*jGUAwM3t"
            },
            "trackingViewed": false,
            "delayTime": null,
            "estimatedCompletionTime": null,
            "estimatedArrivalTime": null,
            "eta": null,
            "destination": {
                "id": "WXgnrgZWriCYGeUhCA5NlqHp",
                "timeCreated": 1621443102000,
                "timeLastModified": 1621443102909,
                "location": [
                    18.0996115,
                    59.2838634
                ],
                "address": {
                    "apartment": "Floor: 2",
                    "state": "Stockholm",
                    "postalCode": "",
                    "country": "Sweden",
                    "street": "Gamla Tyresövägen 310",
                    "city": "Stockholm"
                },
                "notes": "Doorcode: 1134",
                "metadata": [],
                "googlePlaceId": null,
                "warnings": []
            },
            "recipients": [
                {
                    "id": "73CcIiay*gX879vJdzYyc4LR",
                    "timeCreated": 1621443102000,
                    "timeLastModified": 1621443106518,
                    "name": "Lovisa Fhager Havdelin",
                    "phone": "+46709137551",
                    "notes": "\n\nundefined",
                    "organization": "uxwrkxcKznAJjGB*jGUAwM3t",
                    "skipSMSNotifications": false,
                    "metadata": []
                }
            ]
        },
    // ...
  ]
}