Create team

Create team

NameTypeDescription
namestringA unique name for the team.
workersstring arrayAn array of worker IDs.
managersstring arrayAn array of managing administrator IDs.
hubstringOptional. The ID of the team's hub.
enableSelfAssignmentbooleanOptional. Defaults false if not included. This toggles Team Self-Assignment that allows Drivers to Self Assign Tasks that are in the Team unassigned container.
curl -X POST "https://onfleet.com/api/v2/teams" \
       -u "cd3b3de84cc1ee040bf06512d233719c:" \
       -d '{"name":"Sunset","workers":["1LjhGUWdxFbvdsTAAXs0TFos","F8WPCqGmQYWpCkQ2c8zJTCpW"],"managers":["Mrq7aKqzPFKX22pmjdLx*ohM"],"hub":"tKxSfU7psqDQEBVn5e2VQ~*O"}'
onfleet.teams.create(body={
  "name":"Sunset",
  "workers":["1LjhGUWdxFbvdsTAAXs0TFos","F8WPCqGmQYWpCkQ2c8zJTCpW"],
  "managers":["Mrq7aKqzPFKX22pmjdLx*ohM"],
  "hub":"tKxSfU7psqDQEBVn5e2VQ~*O"
})
onfleet.teams.create({"name":"Sunset",
                      "workers":["1LjhGUWdxFbvdsTAAXs0TFos","F8WPCqGmQYWpCkQ2c8zJTCpW"],
                      "managers":["Mrq7aKqzPFKX22pmjdLx*ohM"],
                      "hub":"tKxSfU7psqDQEBVn5e2VQ~*O"
                     });
$onfleet->teams->create(["name" => "Sunset",
                         "workers"=>["1LjhGUWdxFbvdsTAAXs0TFos","F8WPCqGmQYWpCkQ2c8zJTCpW"],
                         "managers"=>["Mrq7aKqzPFKX22pmjdLx*ohM"],
                         "hub" => "tKxSfU7psqDQEBVn5e2VQ~*O"
                        ])
{
  "id": "FFqPs1KHayxorfA~~xIj0us4",
  "timeCreated": 1455156655000,
  "timeLastModified": 1455156655647,
  "name": "Sunset",
  "workers": [
    "1LjhGUWdxFbvdsTAAXs0TFos",
    "F8WPCqGmQYWpCkQ2c8zJTCpW"
  ],
  "managers": [
    "Mrq7aKqzPFKX22pmjdLx*ohM"
  ],
  "hub": "tKxSfU7psqDQEBVn5e2VQ~*O",
  "enableSelfAssignment": false
}
{
  "code": "InvalidArgument",
  "message": {
    "error": 1901,
    "message": "One or more parameters required for this request must be unique but are not unique.",
    "cause": "Name is not unique within org",
    "request": "1adcce4a-e172-4868-a53f-2741a9157caf"
  }
}
{
  "code": "InvalidContent",
  "message": {
    "error": 1000,
    "message": "The values of one or more parameters are invalid.",
    "request": "0283a417-e7c0-47f7-90c7-86036e47afa6"
  }
}

As team names are unique within each organization, errors will be thrown if a duplicate name is used.