Querying metadata

Querying metadata

All Supported Entities have a /<entityNamePluralized>/metadata POST endpoint which you can use to retrieve a collection of entities that match one or more query metadata. For example:

Here is an example payload of metadata query requests for different entities .

$ curl -X POST "https://onfleet.com/api/v2/destinations/metadata" \
       -u "YourAPIKey:" \
       -d '[{"name":"hasDog","type":"boolean","value":true}]'
$ curl -X POST "https://onfleet.com/api/v2/admins/metadata" \
       -u "YourAPIKey:" \
       -d '[{"name":"isHighPerformer","type":"boolean","value":true}]'
$ curl -X POST "https://onfleet.com/api/v2/teams/metadata" \
       -u "YourAPIKey:" \
       -d '[{"name":"New_Location","type":"boolean","value":true}]'
$ curl -X POST "https://onfleet.com/api/v2/workers/metadata" \
       -u "YourAPIKey:" \
       -d '[{"name":"New_driver","type":"boolean","value":true}]'
$ curl -X POST "https://onfleet.com/api/v2/recipients/metadata" \
       -u "YourAPIKey:" \
       -d '[{"name":"otherCustomerConnections","type":"array","value":"value": ["walt-4864619e",
        "tuco-b7ec089b", "mike-6df58fee"]}]'
$ curl -X POST "https://onfleet.com/api/v2/tasks/metadata" \
       -u "YourAPIKey:" \
       -d '[{"name":"age_verified","type":"boolean","value":true}]'

Responses:

[
  {
    "id": "aCbtgPsM*w7lAf61t4YqQODO",
    // ...
    "metadata": [
      {
        "name": "hasDog",
        "type": "boolean",
        "value": true,
        "visibility": [
          "api"
        ]
      }
    ]
  },
  {
    "id": "YI**76lT7nu053HRWHPVLhKW",
    // ...
    "tasks": [],
    "metadata": [
      {
        "name": "hasDog",
        "type": "boolean",
        "value": true,
        "visibility": [
          "api"
        ]
      }
    ]
  }
]
[
        "metadata": [
            {
                "type": "number",
                "visibility": [
                    "api"
                ],
                "value": 331,
                "name": "supportRequestsHandled"
            },
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": true,
                "name": "isHighPerformer"
            }
        ]
       
[
    {
        "id": "9PVeSqj*RxI46~aD*M812DkY",
        "timeCreated": 1740590327000,
        "timeLastModified": 1774189583099,
        "name": "Team Kitchener",
        "workers": [
            "mQpa~QD~LYcG89bPdig8sREj",
            "sLB6mGxkXylco27jnJ0Ca2CF",
            "mM*PRrLDRSCzC~V6xNHiYS3~"
        ],
        "managers": [],
        "metadata": [
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": true,
                "name": "New_Location"
            }
        ],
        "hub": "NqP2A0*flulajomC~If3bnxD",
        "enableSelfAssignment": true
    }
]
[
    
        "metadata": [
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": true,
                "name": "New_driver"
            }
       
]
[
    
        "metadata": [
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": false,
                "name": "isHighNetWorth"
            },
            {
                "type": "array",
                "subtype": "string",
                "visibility": [
                    "api"
                ],
                "value": [
                    "walt-4864619e",
                    "tuco-b7ec089b",
                    "mike-6df58fee"
                ],
                "name": "otherCustomerConnections"
            }
        ]
    },
    {
        "id": "Hot0lXbB6F0BgjscPFmoQxEx",
        "timeCreated": 1774186147000,
        "timeLastModified": 1774186147776,
        "name": "Saul Goodman",
        "phone": "+12263742733",
        "notes": "Change for $100 always required.",
        "organization": "gz6~YVrx7HVI34ecvWOG1LfB",
        "skipSMSNotifications": false,
        "metadata": [
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": false,
                "name": "isHighNetWorth"
            },
            {
                "type": "array",
                "subtype": "string",
                "visibility": [
                    "api"
                ],
                "value": [
                    "walt-4864619e",
                    "tuco-b7ec089b",
                    "mike-6df58fee"
                ],
                "name": "otherCustomerConnections"
            }
        ]
    },
    {
        "id": "GeVz95ih6VufU*4jJ~zW27hG",
        "timeCreated": 1774464128000,
        "timeLastModified": 1774464128086,
        "name": "Saul Goodman",
        "phone": "+12263442733",
        "notes": "Change for $100 always required.",
        "organization": "gz6~YVrx7HVI34ecvWOG1LfB",
        "skipSMSNotifications": false,
        "metadata": [
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": false,
                "name": "isHighNetWorth"
            },
            {
                "type": "array",
                "subtype": "string",
                "visibility": [
                    "api"
                ],
                "value": [
                    "walt-4864619e",
                    "tuco-b7ec089b",
                    "mike-6df58fee"
                ],
                "name": "otherCustomerConnections"
            }
        ]
    },
    {
        "id": "2Bb1gg6VH7gy5Y*lmTgshktH",
        "timeCreated": 1774464337000,
        "timeLastModified": 1774464337433,
        "name": "Saul",
        "phone": "+12263002733",
        "notes": "Change for $100 always required.",
        "organization": "gz6~YVrx7HVI34ecvWOG1LfB",
        "skipSMSNotifications": false,
        "metadata": [
            {
                "type": "array",
                "subtype": "string",
                "visibility": [
                    "api"
                ],
                "value": [
                    "walt-4864619e",
                    "tuco-b7ec089b",
                    "mike-6df58fee"
                ],
                "name": "otherCustomerConnections"
            }
        ]
    }
]
[
    {
        "id": "D~TU2BtWMzLWJlY2Q7Ge4zIx",
        "timeCreated": 1774187036000,
        "timeLastModified": 1774187036384,
        "organization": "gz6~YVrx7HVI34ecvWOG1LfB",
        "shortId": "27213223",
        "orderShortId": null,
        "trackingURL": "https://onf.lt/27213223",
        "worker": null,
        "merchant": "gz6~YVrx7HVI34ecvWOG1LfB",
        "executor": "gz6~YVrx7HVI34ecvWOG1LfB",
        "creator": "r9UlWdZWMW1PiEyW7QboYSsf",
        "dependencies": [],
        "state": 0,
        "completeAfter": null,
        "completeBefore": null,
        "pickupTask": false,
        "type": 1,
        "notes": "",
        "completionDetails": {
            "failureNotes": "",
            "successNotes": "",
            "failureReason": "NONE",
            "events": [],
            "actions": [],
            "time": null,
            "signatureUploadId": null,
            "photoUploadId": null,
            "photoUploadIds": null,
            "firstLocation": [],
            "lastLocation": [],
            "unavailableAttachments": []
        },
        "feedback": [],
        "metadata": [
            {
                "type": "string",
                "visibility": [
                    "api",
                    "dashboard"
                ],
                "value": "ORD-88291",
                "name": "order_id"
            },
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": true,
                "name": "age_verified"
            },
            {
                "type": "number",
                "visibility": [
                    "api",
                    "dashboard"
                ],
                "value": 4,
                "name": "item_count"
            }
        ],
        "overrides": {},
        "quantity": 0,
        "additionalQuantities": {
            "quantityA": 0,
            "quantityB": 0,
            "quantityC": 0
        },
        "serviceTime": 0,
        "identity": {
            "failedScanCount": 0,
            "checksum": null
        },
        "appearance": {
            "triangleColor": null
        },
        "scanOnlyRequiredBarcodes": false,
        "customFieldGroup": null,
        "customRequirements": [],
        "customFields": [],
        "bulkTasks": [],
        "requirements": {
            "signature": false,
            "notes": false,
            "photo": false,
            "minimumAge": 0
        },
        "container": {
            "type": "ORGANIZATION",
            "organization": "gz6~YVrx7HVI34ecvWOG1LfB"
        },
        "trackingViewed": false,
        "recipients": [],
        "estimatedCompletionTime": null,
        "estimatedArrivalTime": null,
        "delayTime": null,
        "destination": {
            "id": "NxOnIRD4My8UlncxvPMtUKMW",
            "timeCreated": 1774187036000,
            "timeLastModified": 1774187036329,
            "location": [
                -122.396792,
                37.787697
            ],
            "address": {
                "number": "543",
                "street": "Howard Street",
                "city": "San Francisco",
                "state": "California",
                "postalCode": "94105",
                "country": "United States",
                "apartment": ""
            },
            "notes": "",
            "metadata": [],
            "googlePlaceId": "ChIJAQAwpGSAhYARgcRpLx2wzE8",
            "warnings": [],
            "useGPS": false
        }
    },
    {
        "id": "l6AA3a7COZvLs316QIsqMfWe",
        "timeCreated": 1774188813000,
        "timeLastModified": 1774188956545,
        "organization": "gz6~YVrx7HVI34ecvWOG1LfB",
        "shortId": "99681177",
        "orderShortId": null,
        "trackingURL": "https://onf.lt/99681177",
        "worker": null,
        "merchant": "gz6~YVrx7HVI34ecvWOG1LfB",
        "executor": "gz6~YVrx7HVI34ecvWOG1LfB",
        "creator": "r9UlWdZWMW1PiEyW7QboYSsf",
        "dependencies": [],
        "state": 0,
        "completeAfter": null,
        "completeBefore": null,
        "pickupTask": false,
        "type": 1,
        "notes": "",
        "completionDetails": {
            "failureNotes": "",
            "successNotes": "",
            "failureReason": "NONE",
            "events": [],
            "actions": [],
            "time": null,
            "signatureUploadId": null,
            "photoUploadId": null,
            "photoUploadIds": null,
            "firstLocation": [],
            "lastLocation": [],
            "unavailableAttachments": []
        },
        "feedback": [],
        "metadata": [
            {
                "type": "string",
                "visibility": [
                    "api",
                    "dashboard"
                ],
                "value": "ORD-88291",
                "name": "order_id"
            },
            {
                "type": "boolean",
                "visibility": [
                    "api"
                ],
                "value": true,
                "name": "age_verified"
            },
            {
                "type": "number",
                "visibility": [
                    "api",
                    "dashboard"
                ],
                "value": 4,
                "name": "item_count"
            },
            {
                "type": "object",
                "visibility": [
                    "api"
                ],
                "value": {
                    "contact_on_arrival": false,
                    "leave_at_door": true
                },
                "name": "delivery_preferences"
            }
        ],
        "overrides": {},
        "quantity": 0,
        "additionalQuantities": {
            "quantityA": 0,
            "quantityB": 0,
            "quantityC": 0
        },
        "serviceTime": 0,
        "identity": {
            "failedScanCount": 0,
            "checksum": null
        },
        "appearance": {
            "triangleColor": null
        },
        "scanOnlyRequiredBarcodes": false,
        "customFieldGroup": null,
        "customRequirements": [],
        "customFields": [],
        "bulkTasks": [],
        "requirements": {
            "signature": false,
            "notes": false,
            "photo": false,
            "minimumAge": 0
        },
        "container": {
            "type": "ORGANIZATION",
            "organization": "gz6~YVrx7HVI34ecvWOG1LfB"
        },
        "trackingViewed": false,
        "recipients": [],
        "estimatedCompletionTime": null,
        "estimatedArrivalTime": null,
        "delayTime": null,
        "destination": {
            "id": "3cB7g1Toyfq2texJV3WMLTDO",
            "timeCreated": 1774188813000,
            "timeLastModified": 1774188813972,
            "location": [
                -122.396792,
                37.787697
            ],
            "address": {
                "number": "543",
                "street": "Howard Street",
                "city": "San Francisco",
                "state": "California",
                "postalCode": "94105",
                "country": "United States",
                "apartment": ""
            },
            "notes": "",
            "metadata": [],
            "googlePlaceId": "ChIJAQAwpGSAhYARgcRpLx2wzE8",
            "warnings": [],
            "useGPS": false
        }
    }
]

The response will return every task that matches the name, type and value of the metadata in the request.

Complex types like object must match exactly to the fields in the entity, for an entity to be included in the query result set. The order of the members in the metadata query array is not taken into account, and the API will apply the AND logical operator to these.

While key order does not matter in metadata entries of type object, it does matter with those of type array provided.