Create Custom Task Templates

This is a POST request

This is to create Task Templates that may only include the configured Custom Fields.

NameTypeDescription
namestringRequired. The Name of the Task Template, unique identifier.
contextSaveConditionsobjectRequired. Please see below for further explanation.
fieldsarray of stringsRequired. An array of Custom Fields keys. They have to match exactly to the conditions in contextSaveConditions
📘

contexSaveConditions

This field is to set up what type tasks the template can be applied to. The choices are pickup, dropoff, or both.

  • [] for both types
  • [{ "fieldName": "pickupTask", "comparison": "equal_to", "targetValue": true }] for Only pickup tasks
  • [{ "fieldName": "pickupTask", "comparison": "equal_to", "targetValue": true }] for Only drop-off tasks

Those are the only acceptable values for contextSaveConditionsfield

❗️

fields

If a template is set to apply only to Pickup tasks, the included Custom Fields must have the same designation; the CF cannot be for only Dropoff tasks. In addition, if a Task template is set up for both types of Tasks, it cannot include CFs that are only for pickup or only for dropoff.

curl -i -X POST "https://onfleet.com/api/v2/cfGroups/task" \
     -u '<your_api_key>:' \
     -d '{"name": "test templates 2","contextSaveConditions": [{"fieldName": "pickupTask","comparison": "equal_to","targetValue": true}],"fields": ["test"]}	'
{
    "id": "GpKsCxloxkvsdT16tcxRnwZ0",
    "name": "test templates 2",
    "deletedAt": null,
    "contextSaveConditions": [
        {
            "fieldName": "pickupTask",
            "comparison": "equal_to",
            "targetValue": true
        }
    ],
    "fields": [
        "test"
    ],
    "isDefault": false
}
📘

Create Tasks with Custom Templates

Once a Custom Template is created, in order to create a Task using that template, the template ID and the fields values will need to be included. For more information, please see [WIP] Creating Tasks with Custom Task Templates