{"_id":"5a305118c8392b0032f6ae14","category":{"_id":"5a305118c8392b0032f6ae09","version":"5a305118c8392b0032f6ae07","project":"5425e663ffd4411c319a65b4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-09-29T20:18:57.785Z","from_sync":false,"order":1,"slug":"reference","title":"Reference"},"project":"5425e663ffd4411c319a65b4","user":"5425e31affd4411c319a65b1","version":{"_id":"5a305118c8392b0032f6ae07","project":"5425e663ffd4411c319a65b4","__v":1,"createdAt":"2017-12-12T21:58:48.080Z","releaseDate":"2017-12-12T21:58:48.080Z","categories":["5a305118c8392b0032f6ae08","5a305118c8392b0032f6ae09"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.6.0","version":"2.6"},"githubsync":"","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-09-30T01:47:32.241Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","examples":{"codes":[]},"auth":"never","params":[],"url":""},"isReference":false,"order":2,"body":"Workers (also known as *drivers* in the dashboard) are the members of an organization who perform actions via the Onfleet mobile applications. They may belong to teams managed by any number of administrators in their own organization. Workers have a vehicle with which tasks are completed.\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"Create worker\"\n}\n[/block]\nCreating a new worker generates a temporary password which is sent to the worker’s phone by SMS along with download details for the worker [iOS and Android mobile apps](http://support.onfleet.com/hc/en-us/sections/200863909-Driver-Mobile-App).\n\nThe worker will be able to set a permanent password when first logging in to the application.\n\nBody parameters\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"name\",\n    \"1-0\": \"phone\",\n    \"2-0\": \"teams\",\n    \"3-0\": \"vehicle\",\n    \"0-1\": \"string\",\n    \"1-1\": \"string\",\n    \"2-1\": \"string array\",\n    \"3-1\": \"object\",\n    \"0-2\": \"The worker’s complete name.\",\n    \"1-2\": \"A valid phone number as per the worker’s organization’s country.\",\n    \"2-2\": \"One or more team IDs of which the worker is a member.\",\n    \"3-2\": \"Optional. The worker’s vehicle; providing no vehicle details is equivalent to the worker being on foot.\",\n    \"4-0\": \"capacity\",\n    \"4-1\": \"number\",\n    \"4-2\": \"Optional. The maximum number of units this worker can carry, for route optimization purposes.\",\n    \"5-0\": \"displayName\",\n    \"5-1\": \"string\",\n    \"5-2\": \"Optional. This value is used in place of the worker's actual name within sms notifications, delivery tracking pages, and across organization boundaries (connections).\"\n  },\n  \"cols\": 3,\n  \"rows\": 6\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Note that a worker's image can only be set through the dashboard or by themselves on the mobile app.\",\n  \"title\": \"Worker Image\"\n}\n[/block]\nA `vehicle` has the following properties:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"type\",\n    \"0-1\": \"string\",\n    \"0-2\": \"The vehicle’s type, must be one of `CAR`, `MOTORCYCLE`, `BICYCLE` or `TRUCK`.\",\n    \"1-0\": \"description\",\n    \"1-1\": \"string\",\n    \"1-2\": \"Optional. The vehicle’s make, model, year, or any other relevant identifying details.\",\n    \"2-0\": \"licensePlate\",\n    \"2-1\": \"string\",\n    \"2-2\": \"Optional. The vehicle’s license plate number.\",\n    \"3-0\": \"color\",\n    \"3-1\": \"string\",\n    \"3-2\": \"Optional. The vehicle's color.\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -X POST \\\"https://onfleet.com/api/v2/workers\\\" \\\\\\n       -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\" \\\\\\n       -d '{\\\"name\\\":\\\"A Swartz\\\",\\\"phone\\\":\\\"617-342-8853\\\",\\\"teams\\\":[\\\"nz1nG1Hpx9EHjQCJsT2VAs~o\\\"],\\\"vehicle\\\":{\\\"type\\\":\\\"CAR\\\",\\\"description\\\":\\\"Tesla Model 3\\\",\\\"licensePlate\\\":\\\"FKNS9A\\\",\\\"color\\\":\\\"purple\\\"}}'\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"id\\\": \\\"sFtvhYK2l26zS0imptJJdC2q\\\",\\n  \\\"timeCreated\\\": 1455156653000,\\n  \\\"timeLastModified\\\": 1455156653214,\\n  \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n  \\\"name\\\": \\\"A Swartz\\\",\\n  \\\"displayName\\\": \\\"AS\\\",\\n  \\\"phone\\\": \\\"+16173428853\\\",\\n  \\\"activeTask\\\": null,\\n  \\\"tasks\\\": [],\\n  \\\"onDuty\\\": false,\\n  \\\"timeLastSeen\\\": null,\\n\\t\\\"capacity\\\": 0,\\n  \\\"userData\\\": {\\n  \\t\\\"appVersion\\\": \\\"1.2.0\\\",\\n    \\\"batteryLevel\\\": 0.99,\\n    \\\"deviceDescription\\\": \\\"iPhone XS\\\",\\n    \\\"platform\\\": \\\"IOS\\\"\\n  },\\n  \\\"accountStatus\\\": \\\"ACCEPTED\\\",\\n  \\\"metadata\\\": [],\\n  \\\"imageUrl\\\":  null,\\n  \\\"teams\\\": [\\n    \\\"nz1nG1Hpx9EHjQCJsT2VAs~o\\\"\\n  ],\\n  \\\"delayTime\\\": null,\\n  \\\"vehicle\\\": {\\n    \\\"id\\\": \\\"tN1HjcvygQWvz5FRR1JAxwL8\\\",\\n    \\\"type\\\": \\\"CAR\\\",\\n    \\\"description\\\": \\\"Tesla Model 3\\\",\\n    \\\"licensePlate\\\": \\\"FKNS9A\\\",\\n    \\\"color\\\": \\\"purple\\\",\\n    \\\"timeLastModified\\\": 154086815176\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    },\n    {\n      \"code\": \"{\\n  \\\"code\\\": \\\"InvalidArgument\\\",\\n  \\\"message\\\": {\\n    \\\"error\\\": 1900,\\n    \\\"message\\\": \\\"One or more parameters required for this request are either missing or have an invalid format.\\\",\\n    \\\"cause\\\": \\\"Team IDs array missing\\\",\\n    \\\"request\\\": \\\"bc41a8eb-a604-4a1c-aa5a-e86a975c141b\\\"\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Error - Missing Argument\"\n    },\n    {\n      \"code\": \"{\\n  \\\"code\\\": \\\"InvalidContent\\\",\\n  \\\"message\\\": {\\n    \\\"error\\\": 1000,\\n    \\\"message\\\": \\\"The values of one or more parameters are invalid.\\\",\\n    \\\"cause\\\": \\\"Invalid phone number format\\\",\\n    \\\"request\\\": \\\"fff8ed50-4ca0-4ff9-9230-b73096eb8502\\\"\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Error - Invalid Format\"\n    },\n    {\n      \"code\": \"{\\n  \\\"code\\\": \\\"InvalidContent\\\",\\n  \\\"message\\\": {\\n    \\\"error\\\": 1004,\\n    \\\"message\\\": \\\"The values of one or more parameters break a uniqueness constraint.\\\",\\n    \\\"cause\\\": {\\n      \\\"type\\\": \\\"duplicateKey\\\",\\n      \\\"key\\\": \\\"unknown\\\",\\n      \\\"value\\\": \\\"unknown\\\"\\n    },\\n    \\\"request\\\": \\\"3eafc877-278c-40d1-993b-2acf2575c7d8\\\"\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Error - Duplicate Phone\"\n    }\n  ]\n}\n[/block]\n`delayTime` is a special property providing the amount of time in seconds that a worker is delayed by, based on the maximum `delayTime` of all assigned tasks, or `null` if the worker is not delayed. This is updated every minute if the worker is on-duty, or every 10 minutes if the worker is off-duty. To find out more about delayed statuses, see the `delayTime` part of our [Tasks](doc:tasks) section or check out [this support center entry](http://support.onfleet.com/hc/en-us/articles/204752505-Dashboard-statuses). `imageUrl` will also be provided if a worker image has been configured.\n\nThe required parameters will need to be correctly formatted in order for the request to go through. In cases where duplicated phone numbers are used within your organization, a `duplicateKey` error will be returned.\n[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"List workers\"\n}\n[/block]\nReturns a collection of all workers in your organization.\n\nQuery parameters\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"filter\",\n    \"0-1\": \"string\",\n    \"0-2\": \"Optional. A comma-separated list of fields to return, if all are not desired. For example, `name, location`.\",\n    \"2-0\": \"states\",\n    \"2-1\": \"string\",\n    \"2-2\": \"Optional. A comma-separated list of worker states, where `0` is off-duty, `1` is idle (on-duty, no active task) and `2` is active (on-duty, active task).\",\n    \"1-0\": \"teams\",\n    \"1-1\": \"string\",\n    \"1-2\": \"Optional. A comma-separated list of the team IDs that workers must be part of.\",\n    \"3-0\": \"phones\",\n    \"3-1\": \"string\",\n    \"3-2\": \"Optional. A comma-separated list of workers' phone numbers.\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -X GET \\\"https://onfleet.com/api/v2/workers?states=1\\\" \\\\\\n       -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\"\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[\\n  {\\n    \\\"id\\\": \\\"h*wSb*apKlDkUFnuLTtjPke7\\\",\\n    \\\"timeCreated\\\": 1455049674000,\\n    \\\"timeLastModified\\\": 1455156646529,\\n    \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n    \\\"name\\\": \\\"Andoni\\\",\\n    \\\"displayName\\\": \\\"Andoni\\\",\\n    \\\"phone\\\": \\\"+14155558442\\\",\\n    \\\"activeTask\\\": null,\\n    \\\"tasks\\\": [\\n      \\\"11z1BbsQUZFHD1XAd~emDDeK\\\"\\n    ],\\n    \\\"onDuty\\\": true,\\n    \\\"timeLastSeen\\\": 1455156644323,\\n    \\\"capacity\\\": 0,\\n    \\\"userData\\\": {\\n    \\t\\\"appVersion\\\": \\\"1.2.0\\\",\\n      \\\"batteryLevel\\\": 0.99,\\n      \\\"deviceDescription\\\": \\\"Simulator (iOS 12.1.0)\\\",\\n      \\\"platform\\\": \\\"IOS\\\"\\n    },\\n    \\\"accountStatus\\\": \\\"ACCEPTED\\\",\\n    \\\"metadata\\\": [\\n          {\\n        \\\"name\\\": \\\"nickname\\\",\\n        \\\"type\\\": \\\"string\\\",\\n        \\\"value\\\": \\\"Puffy\\\",\\n        \\\"visibility\\\": [\\n          \\\"api\\\"\\n        ]\\n      },\\n      {\\n        \\\"name\\\": \\\"otherDetails\\\",\\n        \\\"type\\\": \\\"object\\\",\\n        \\\"value\\\": {\\n          \\\"availability\\\": {\\n            \\\"mon\\\": \\\"10:00\\\",\\n            \\\"sat\\\": \\\"16:20\\\",\\n            \\\"wed\\\": \\\"13:30\\\"\\n          },\\n          \\\"premiumInsurance\\\": false,\\n          \\\"trunkSize\\\": 9.5\\n        },\\n        \\\"visibility\\\": [\\n          \\\"api\\\"\\n        ]\\n      }\\n    ],\\n    \\\"imageUrl\\\": null,\\n    \\\"teams\\\": [\\n      \\\"R4P7jhuzaIZ4cHHZE1ghmTtB\\\"\\n    ],\\n    \\\"delayTime\\\": null,\\n    \\\"location\\\": [\\n      -122.4015496466794,\\n      37.77629837661284\\n    ],\\n    \\\"vehicle\\\": null\\n  },\\n  {\\n    \\\"id\\\": \\\"1LjhGUWdxFbvdsTAAXs0TFos\\\",\\n    \\\"timeCreated\\\": 1455049755000,\\n    \\\"timeLastModified\\\": 1455072352267,\\n    \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n    \\\"name\\\": \\\"Yevgeny\\\",\\n    \\\"displayName\\\": \\\"YV\\\",\\n    \\\"phone\\\": \\\"+14155552299\\\",\\n    \\\"activeTask\\\": null,\\n    \\\"tasks\\\": [\\n      \\\"*0tnJcly~vSI~9uHz*ICHXTw\\\",\\n      \\\"PauBfRH8gQCjtMLaPe97G8Jf\\\"\\n    ],\\n    \\\"onDuty\\\": true,\\n    \\\"timeLastSeen\\\": 1455156649007,\\n    \\\"capacity\\\": 0,\\n    \\\"userData\\\": {\\n    \\t\\\"appVersion\\\": \\\"1.2.0\\\",\\n      \\\"batteryLevel\\\": 0.97,\\n      \\\"deviceDescription\\\": \\\"Galaxy S8\\\",\\n      \\\"platform\\\": \\\"Android\\\"\\n    },\\n    \\\"accountStatus\\\": \\\"ACCEPTED\\\",\\n    \\\"metadata\\\": [],\\n    \\\"location\\\": [\\n      -122.4016366,\\n      37.7764098\\n    ],\\n    \\\"imageUrl\\\": null,\\n    \\\"teams\\\": [\\n      \\\"9dyuPqHt6kDK5JKHFhE0xihh\\\",\\n      \\\"yKpCnWprM1Rvp3NGGlVa5TMa\\\",\\n      \\\"fwflFNVvrK~4t0m5hKFIxBUl\\\"\\n    ],\\n    \\\"delayTime\\\": null,\\n    \\\"vehicle\\\": {\\n      \\\"id\\\": \\\"ArBoHNxS4B76AiBKoIawY9OS\\\",\\n      \\\"type\\\": \\\"CAR\\\",\\n      \\\"description\\\": \\\"Lada Niva\\\",\\n      \\\"licensePlate\\\": \\\"23KJ129\\\",\\n      \\\"color\\\": \\\"Red\\\",\\n      \\\"timeLastModified\\\": 1545086815176\\n    }\\n  }\\n]\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ]\n}\n[/block]\nThe index of each id in the `tasks` array indicates the order of assigned tasks for that worker.\n[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"Get workers by location\"\n}\n[/block]\nYou may provide a coordinate pair along with a radius to get a list of workers who are currently within a certain target area.\n\nQuery parameters\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"longitude\",\n    \"0-1\": \"number\",\n    \"0-2\": \"The longitude component of the coordinate pair.\",\n    \"1-0\": \"latitude\",\n    \"1-1\": \"number\",\n    \"1-2\": \"The latitude component of the coordinate pair.\",\n    \"2-0\": \"radius\",\n    \"2-1\": \"number\",\n    \"2-2\": \"Optional. The length in meters of the radius of the spherical area in which to look for workers. Defaults to 1000 if missing. Maximum value is 10000.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -X GET \\\"https://onfleet.com/api/v2/workers/location?longitude=-122.41275787353516&latitude=37.78998061344339&radius=6000\\\" \\\\\\n       -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\"\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"workers\\\": [\\n    {\\n      \\\"id\\\": \\\"h*wSb*apKlDkUFnuLTtjPke7\\\",\\n      \\\"timeCreated\\\": 1458416497000,\\n      \\\"timeLastModified\\\": 1478383350446,\\n      \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n      \\\"name\\\": \\\"Andoni\\\",\\n      \\\"displayName\\\": \\\"Andoni\\\",\\n      \\\"phone\\\": \\\"+14155558442\\\",\\n      \\\"activeTask\\\": \\\"kc8SS1tzuZ~jqjlebKGrUmpe\\\",\\n      \\\"tasks\\\": [\\n        \\\"11z1BbsQUZFHD1XAd~emDDeK\\\",\\n        \\\"kc8SS1tzuZ~jqjlebKGrUmpe\\\"\\n      ],\\n      \\\"onDuty\\\": true,\\n      \\\"isResponding\\\": true,\\n      \\\"timeLastSeen\\\": 1480385504517,\\n      \\\"capacity\\\": 0,\\n      \\\"userData\\\": {\\n         \\\"appVersion\\\": \\\"1.2.0\\\",\\n         \\\"batteryLevel\\\": 0.99,\\n         \\\"deviceDescription\\\": \\\"Simulator (iOS 12.1.0)\\\",\\n         \\\"platform\\\": \\\"IOS\\\"\\n      },\\n      \\\"accountStatus\\\": \\\"ACCEPTED\\\",\\n      \\\"metadata\\\": [],\\n      \\\"imageUrl\\\": null,\\n      \\\"teams\\\": [\\n        \\\"gDTOyY9W33yWxnFQ~Gqo9mAr\\\"\\n      ],\\n      \\\"capacity\\\": 0,\\n      \\\"userData\\\": {},\\n      \\\"location\\\": [\\n        -122.4088934,\\n        37.7593079\\n      ],\\n      \\\"delayTime\\\": 1650,\\n      \\\"vehicle\\\": {\\n        \\\"id\\\": \\\"ArBoHNxS4B76AiBKoIawY9OS\\\",\\n        \\\"type\\\": \\\"CAR\\\",\\n        \\\"description\\\": \\\"Tesla Roadster\\\",\\n        \\\"licensePlate\\\": \\\"ELON4PREZ\\\",\\n        \\\"color\\\": \\\"black\\\",\\n        \\\"timeLastModified\\\": 1478383350431\\n      }\\n    },\\n    {\\n      \\\"id\\\": \\\"sFtvhYK2l26zS0imptJJdC2q\\\",\\n      \\\"timeCreated\\\": 1473361545000,\\n      \\\"timeLastModified\\\": 1480384608044,\\n      \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n      \\\"name\\\": \\\"Hitachino\\\",\\n      \\\"displayName\\\": \\\"HT\\\",\\n      \\\"phone\\\": \\\"+16175552820\\\",\\n      \\\"activeTask\\\": null,\\n      \\\"tasks\\\": [],\\n      \\\"onDuty\\\": true,\\n      \\\"isResponding\\\": true,\\n      \\\"timeLastSeen\\\": 1480385496759,\\n      \\\"capacity\\\": 0,\\n      \\\"userData\\\": {\\n        \\\"deviceDescription\\\": \\\"iPhone 6S (iOS 9.3.2)\\\",\\n        \\\"batteryLevel\\\": 0.43,\\n        \\\"appVersion\\\": \\\"0.9.65\\\",\\n        \\\"platform\\\": \\\"IOS\\\"\\n      },\\n      \\\"accountStatus\\\": \\\"ACCEPTED\\\",\\n      \\\"metadata\\\": [],\\n      \\\"imageUrl\\\": null,\\n      \\\"teams\\\": [\\n            \\\"gDTOyY9W33yWxnFQ~Gqo9mAr\\\"\\n      ],\\n      \\\"location\\\": [\\n        -122.4431349803903,\\n        37.75080475959717\\n      ],\\n      \\\"delayTime\\\": null,\\n      \\\"vehicle\\\": {\\n        \\\"id\\\": \\\"tN1HjcvygQWvz5FRR1JAxwL8\\\",\\n        \\\"type\\\": \\\"CAR\\\",\\n        \\\"description\\\": null,\\n        \\\"licensePlate\\\": null,\\n        \\\"color\\\": null,\\n        \\\"timeLastModified\\\": 1473361545335\\n      }\\n    }\\n  ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"Get single worker\"\n}\n[/block]\nBasic worker duty event, traveled distance (meters) and time analytics are optionally available by specifying the query parameter ```analytics``` as ```true```. \n\nYou may also provide both ```from``` and ```to``` timestamps as query parameters (up to a maximum duration of 24 hours) to target a specific time range. If you omit these parameters, the worker analytics for the last week will be provided.\n\nQuery parameters\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"filter\",\n    \"0-1\": \"string array\",\n    \"0-2\": \"Optional. A comma-separated list of fields to return, if all are not desired. For example, `[ name, location ]`.\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -X GET \\\"https://onfleet.com/api/v2/workers/1LjhGUWdxFbvdsTAAXs0TFos?analytics=true\\\" \\\\\\n       -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\"\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    },\n    {\n      \"code\": \"$ curl -X GET \\\"https://onfleet.com/api/v2/workers/1LjhGUWdxFbvdsTAAXs0TFos\\\" \\\\\\n       -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\"\",\n      \"language\": \"shell\",\n      \"name\": \"Request - No Analytics\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"id\\\": \\\"1LjhGUWdxFbvdsTAAXs0TFos\\\",\\n  \\\"timeCreated\\\": 1455049755000,\\n  \\\"timeLastModified\\\": 1455072352267,\\n  \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n  \\\"name\\\": \\\"Yevgeny\\\",\\n  \\\"phone\\\": \\\"+14155552299\\\",\\n  \\\"activeTask\\\": null,\\n  \\\"tasks\\\": [\\n    \\\"*0tnJcly~vSI~9uHz*ICHXTw\\\",\\n    \\\"PauBfRH8gQCjtMLaPe97G8Jf\\\"\\n  ],\\n  \\\"onDuty\\\": true,\\n  \\\"timeLastSeen\\\": 1455156649007,\\n  \\\"delayTime\\\": null,\\n  \\\"teams\\\": [\\n    \\\"9dyuPqHt6kDK5JKHFhE0xihh\\\",\\n    \\\"yKpCnWprM1Rvp3NGGlVa5TMa\\\",\\n    \\\"fwflFNVvrK~4t0m5hKFIxBUl\\\"\\n  ],\\n  \\\"metadata\\\": [],\\n  \\\"location\\\": [\\n    -122.4016366,\\n    37.7764098\\n  ],\\n  \\\"vehicle\\\": {\\n    \\\"id\\\": \\\"ArBoHNxS4B76AiBKoIawY9OS\\\",\\n    \\\"type\\\": \\\"CAR\\\",\\n    \\\"description\\\": \\\"Lada Niva\\\",\\n    \\\"licensePlate\\\": \\\"23KJ129\\\",\\n    \\\"color\\\": \\\"Red\\\"\\n  },\\n  \\\"analytics\\\": {\\n    \\\"events\\\": [\\n      {\\n        \\\"action\\\": \\\"onduty\\\",\\n        \\\"time\\\": 1455072352164\\n      },\\n      {\\n        \\\"action\\\": \\\"offduty\\\",\\n        \\\"time\\\": 1455072485603\\n      }\\n    ],\\n    \\\"distances\\\": {\\n      \\\"enroute\\\": 0,\\n      \\\"idle\\\": 0\\n    },\\n    \\\"times\\\": {\\n      \\\"enroute\\\": 0,\\n      \\\"idle\\\": 132.18\\n    },\\n    \\\"taskCounts\\\": {\\n      \\\"succeeded\\\": 0,\\n      \\\"failed\\\": 0\\n    }\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    },\n    {\n      \"code\": \"{\\n  \\\"id\\\": \\\"1LjhGUWdxFbvdsTAAXs0TFos\\\",\\n  \\\"timeCreated\\\": 1455049755000,\\n  \\\"timeLastModified\\\": 1455072352267,\\n  \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n  \\\"name\\\": \\\"Yevgeny\\\",\\n  \\\"phone\\\": \\\"+14155552299\\\",\\n  \\\"activeTask\\\": null,\\n  \\\"tasks\\\": [\\n    \\\"*0tnJcly~vSI~9uHz*ICHXTw\\\",\\n    \\\"PauBfRH8gQCjtMLaPe97G8Jf\\\"\\n  ],\\n  \\\"onDuty\\\": true,\\n  \\\"timeLastSeen\\\": 1455156649007,\\n  \\\"delayTime\\\": null,\\n  \\\"teams\\\": [\\n    \\\"9dyuPqHt6kDK5JKHFhE0xihh\\\",\\n    \\\"yKpCnWprM1Rvp3NGGlVa5TMa\\\",\\n    \\\"fwflFNVvrK~4t0m5hKFIxBUl\\\"\\n  ],\\n  \\\"metadata\\\": [],\\n  \\\"location\\\": [\\n    -122.4016366,\\n    37.7764098\\n  ],\\n  \\\"vehicle\\\": {\\n    \\\"id\\\": \\\"ArBoHNxS4B76AiBKoIawY9OS\\\",\\n    \\\"type\\\": \\\"CAR\\\",\\n    \\\"description\\\": \\\"Lada Niva\\\",\\n    \\\"licensePlate\\\": \\\"23KJ129\\\",\\n    \\\"color\\\": \\\"Red\\\"\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response - No analytics\"\n    }\n  ]\n}\n[/block]\nThe ```analytics``` query parameter being set to ```true``` will result in a more detailed response.\n[block:api-header]\n{\n  \"type\": \"put\",\n  \"title\": \"Update worker\"\n}\n[/block]\n**Note that it is not possible to programmatically update a worker's `phone`.** The request to update a worker's phone number will not trigger an error.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -X PUT \\\"https://onfleet.com/api/v2/workers/sFtvhYK2l26zS0imptJJdC2q\\\" \\\\\\n       -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\" \\\\\\n       -d '{\\\"name\\\":\\\"Laura P\\\",\\\"teams\\\":[\\\"lHCUJFvh6v0YDURKjokZbvau\\\"]}'\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"id\\\": \\\"sFtvhYK2l26zS0imptJJdC2q\\\",\\n  \\\"timeCreated\\\": 1455156653000,\\n  \\\"timeLastModified\\\": 1455156654558,\\n  \\\"organization\\\": \\\"yAM*fDkztrT3gUcz9mNDgNOL\\\",\\n  \\\"name\\\": \\\"Laura P\\\",\\n  \\\"phone\\\": \\\"+16173428853\\\",\\n  \\\"activeTask\\\": null,\\n  \\\"tasks\\\": [],\\n  \\\"onDuty\\\": false,\\n  \\\"timeLastSeen\\\": null,\\n  \\\"delayTime\\\": null,\\n  \\\"teams\\\": [\\n    \\\"lHCUJFvh6v0YDURKjokZbvau\\\"\\n  ],\\n  \\\"metadata\\\": [],\\n  \\\"vehicle\\\": {\\n    \\\"id\\\": \\\"tN1HjcvygQWvz5FRR1JAxwL8\\\",\\n    \\\"type\\\": \\\"CAR\\\",\\n    \\\"description\\\": \\\"Tesla Model 3\\\",\\n    \\\"licensePlate\\\": \\\"FKNS9A\\\",\\n    \\\"color\\\": \\\"purple\\\"\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"delete\",\n  \"title\": \"Delete worker\"\n}\n[/block]\nNote that workers with an active task cannot be deleted until the task has been completed.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -X DELETE \\\"https://onfleet.com/api/v2/workers/sFtvhYK2l26zS0imptJJdC2q\\\" \\\\\\n       -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\"\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"HTTP/1.1 200 OK\",\n      \"language\": \"http\",\n      \"name\": \"Response\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"Get worker's schedule\"\n}\n[/block]\nRetrieves all of the schedule entries for a worker.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl \\\"https://onfleet.com/api/v2/workers/GPOQQjU84QPN~fP*pbunT2CW/schedule\\\" -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\"\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"entries\\\":[\\n    {\\n      \\\"date\\\": \\\"2017-07-20\\\",\\n      \\\"shifts\\\": [[1500591600000,1500613200000]],\\n      \\\"timezone\\\": \\\"America/Los_Angeles\\\"\\n    },\\n      {\\n        \\\"date\\\": \\\"2017-07-17\\\",\\n        \\\"shifts\\\": [[1500307200000,1500314400000], [1500323100000,1500336000000]],\\n        \\\"timezone\\\": \\\"America/Los_Angeles\\\"\\n      }\\n  ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"Set worker's schedule\"\n}\n[/block]\nUses the provided list of entry objects to set the worker's schedule. Entries earlier than the start of the current week will not be saved. The structure of an entry list is as follows.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"date\",\n    \"0-1\": \"string\",\n    \"0-2\": \"A YYYY-MM-DD formatted date.\",\n    \"1-0\": \"timezone\",\n    \"1-1\": \"string\",\n    \"1-2\": \"A valid timezone.\",\n    \"2-0\": \"shifts\",\n    \"2-1\": \"array\",\n    \"2-2\": \"each element is a two element array which contains the start and end times of the shift as timestamps.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -X POST \\\"https://onfleet.com/api/v2/workers/GPOQQjU84QPN~fP*pbunT2CW/schedule\\\" -u \\\"cd3b3de84cc1ee040bf06512d233719c:\\\" \\\\-d '\\n{\\n\\t\\\"entries\\\":[\\n  \\t{\\n    \\t\\\"date\\\":\\\"2017-07-16\\\",\\n    \\t\\\"shifts\\\":[[1500213600000,1500249600000]],\\n    \\t\\\"timezone\\\":\\\"America/Los_Angeles\\\"\\n    },\\n    {\\n    \\t\\\"date\\\":\\\"2017-07-20\\\",\\n      \\\"shifts\\\":[[1500591600000,1500613200000]],\\n      \\\"timezone\\\":\\\"America/Los_Angeles\\\"\\n     },\\n     {\\n     \\t\\t\\\"date\\\":\\\"2017-07-17\\\",\\n      \\t\\\"shifts\\\":[[1500307200000,1500314400000], [1500323100000,1500336000000]],\\n      \\t\\\"timezone\\\":\\\"America/Los_Angeles\\\"\\n      },\\n      {\\n      \\t\\t\\\"date\\\":\\\"2016-07-17\\\",\\n        \\t\\\"shifts\\\": [[1500307200000,1500314400000],[1500323100000,1500336000000]],\\n        \\t\\\"timezone\\\":\\\"America/Los_Angeles\\\"\\n      }\\n    ]\\n }'\\n\",\n      \"language\": \"shell\",\n      \"name\": \"Request\"\n    }\n  ]\n}\n[/block]\nNotice that some entries were removed:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"entries\\\":[\\n    {\\n      \\\"date\\\": \\\"2017-07-20\\\",\\n      \\\"shifts\\\": [[1500591600000,1500613200000]],\\n      \\\"timezone\\\": \\\"America/Los_Angeles\\\"\\n    },\\n      {\\n        \\\"date\\\": \\\"2017-07-17\\\",\\n        \\\"shifts\\\": [[1500307200000,1500314400000], [1500323100000,1500336000000]],\\n        \\\"timezone\\\": \\\"America/Los_Angeles\\\"\\n      }\\n  ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"workers","type":"basic","title":"Workers"}
Workers (also known as *drivers* in the dashboard) are the members of an organization who perform actions via the Onfleet mobile applications. They may belong to teams managed by any number of administrators in their own organization. Workers have a vehicle with which tasks are completed. [block:api-header] { "type": "post", "title": "Create worker" } [/block] Creating a new worker generates a temporary password which is sent to the worker’s phone by SMS along with download details for the worker [iOS and Android mobile apps](http://support.onfleet.com/hc/en-us/sections/200863909-Driver-Mobile-App). The worker will be able to set a permanent password when first logging in to the application. Body parameters [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "name", "1-0": "phone", "2-0": "teams", "3-0": "vehicle", "0-1": "string", "1-1": "string", "2-1": "string array", "3-1": "object", "0-2": "The worker’s complete name.", "1-2": "A valid phone number as per the worker’s organization’s country.", "2-2": "One or more team IDs of which the worker is a member.", "3-2": "Optional. The worker’s vehicle; providing no vehicle details is equivalent to the worker being on foot.", "4-0": "capacity", "4-1": "number", "4-2": "Optional. The maximum number of units this worker can carry, for route optimization purposes.", "5-0": "displayName", "5-1": "string", "5-2": "Optional. This value is used in place of the worker's actual name within sms notifications, delivery tracking pages, and across organization boundaries (connections)." }, "cols": 3, "rows": 6 } [/block] [block:callout] { "type": "info", "body": "Note that a worker's image can only be set through the dashboard or by themselves on the mobile app.", "title": "Worker Image" } [/block] A `vehicle` has the following properties: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "type", "0-1": "string", "0-2": "The vehicle’s type, must be one of `CAR`, `MOTORCYCLE`, `BICYCLE` or `TRUCK`.", "1-0": "description", "1-1": "string", "1-2": "Optional. The vehicle’s make, model, year, or any other relevant identifying details.", "2-0": "licensePlate", "2-1": "string", "2-2": "Optional. The vehicle’s license plate number.", "3-0": "color", "3-1": "string", "3-2": "Optional. The vehicle's color." }, "cols": 3, "rows": 4 } [/block] [block:code] { "codes": [ { "code": "$ curl -X POST \"https://onfleet.com/api/v2/workers\" \\\n -u \"cd3b3de84cc1ee040bf06512d233719c:\" \\\n -d '{\"name\":\"A Swartz\",\"phone\":\"617-342-8853\",\"teams\":[\"nz1nG1Hpx9EHjQCJsT2VAs~o\"],\"vehicle\":{\"type\":\"CAR\",\"description\":\"Tesla Model 3\",\"licensePlate\":\"FKNS9A\",\"color\":\"purple\"}}'", "language": "shell", "name": "Request" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"id\": \"sFtvhYK2l26zS0imptJJdC2q\",\n \"timeCreated\": 1455156653000,\n \"timeLastModified\": 1455156653214,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"A Swartz\",\n \"displayName\": \"AS\",\n \"phone\": \"+16173428853\",\n \"activeTask\": null,\n \"tasks\": [],\n \"onDuty\": false,\n \"timeLastSeen\": null,\n\t\"capacity\": 0,\n \"userData\": {\n \t\"appVersion\": \"1.2.0\",\n \"batteryLevel\": 0.99,\n \"deviceDescription\": \"iPhone XS\",\n \"platform\": \"IOS\"\n },\n \"accountStatus\": \"ACCEPTED\",\n \"metadata\": [],\n \"imageUrl\": null,\n \"teams\": [\n \"nz1nG1Hpx9EHjQCJsT2VAs~o\"\n ],\n \"delayTime\": null,\n \"vehicle\": {\n \"id\": \"tN1HjcvygQWvz5FRR1JAxwL8\",\n \"type\": \"CAR\",\n \"description\": \"Tesla Model 3\",\n \"licensePlate\": \"FKNS9A\",\n \"color\": \"purple\",\n \"timeLastModified\": 154086815176\n }\n}", "language": "json", "name": "Response" }, { "code": "{\n \"code\": \"InvalidArgument\",\n \"message\": {\n \"error\": 1900,\n \"message\": \"One or more parameters required for this request are either missing or have an invalid format.\",\n \"cause\": \"Team IDs array missing\",\n \"request\": \"bc41a8eb-a604-4a1c-aa5a-e86a975c141b\"\n }\n}", "language": "json", "name": "Error - Missing Argument" }, { "code": "{\n \"code\": \"InvalidContent\",\n \"message\": {\n \"error\": 1000,\n \"message\": \"The values of one or more parameters are invalid.\",\n \"cause\": \"Invalid phone number format\",\n \"request\": \"fff8ed50-4ca0-4ff9-9230-b73096eb8502\"\n }\n}", "language": "json", "name": "Error - Invalid Format" }, { "code": "{\n \"code\": \"InvalidContent\",\n \"message\": {\n \"error\": 1004,\n \"message\": \"The values of one or more parameters break a uniqueness constraint.\",\n \"cause\": {\n \"type\": \"duplicateKey\",\n \"key\": \"unknown\",\n \"value\": \"unknown\"\n },\n \"request\": \"3eafc877-278c-40d1-993b-2acf2575c7d8\"\n }\n}", "language": "json", "name": "Error - Duplicate Phone" } ] } [/block] `delayTime` is a special property providing the amount of time in seconds that a worker is delayed by, based on the maximum `delayTime` of all assigned tasks, or `null` if the worker is not delayed. This is updated every minute if the worker is on-duty, or every 10 minutes if the worker is off-duty. To find out more about delayed statuses, see the `delayTime` part of our [Tasks](doc:tasks) section or check out [this support center entry](http://support.onfleet.com/hc/en-us/articles/204752505-Dashboard-statuses). `imageUrl` will also be provided if a worker image has been configured. The required parameters will need to be correctly formatted in order for the request to go through. In cases where duplicated phone numbers are used within your organization, a `duplicateKey` error will be returned. [block:api-header] { "type": "get", "title": "List workers" } [/block] Returns a collection of all workers in your organization. Query parameters [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "filter", "0-1": "string", "0-2": "Optional. A comma-separated list of fields to return, if all are not desired. For example, `name, location`.", "2-0": "states", "2-1": "string", "2-2": "Optional. A comma-separated list of worker states, where `0` is off-duty, `1` is idle (on-duty, no active task) and `2` is active (on-duty, active task).", "1-0": "teams", "1-1": "string", "1-2": "Optional. A comma-separated list of the team IDs that workers must be part of.", "3-0": "phones", "3-1": "string", "3-2": "Optional. A comma-separated list of workers' phone numbers." }, "cols": 3, "rows": 4 } [/block] [block:code] { "codes": [ { "code": "$ curl -X GET \"https://onfleet.com/api/v2/workers?states=1\" \\\n -u \"cd3b3de84cc1ee040bf06512d233719c:\"", "language": "shell", "name": "Request" } ] } [/block] [block:code] { "codes": [ { "code": "[\n {\n \"id\": \"h*wSb*apKlDkUFnuLTtjPke7\",\n \"timeCreated\": 1455049674000,\n \"timeLastModified\": 1455156646529,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"Andoni\",\n \"displayName\": \"Andoni\",\n \"phone\": \"+14155558442\",\n \"activeTask\": null,\n \"tasks\": [\n \"11z1BbsQUZFHD1XAd~emDDeK\"\n ],\n \"onDuty\": true,\n \"timeLastSeen\": 1455156644323,\n \"capacity\": 0,\n \"userData\": {\n \t\"appVersion\": \"1.2.0\",\n \"batteryLevel\": 0.99,\n \"deviceDescription\": \"Simulator (iOS 12.1.0)\",\n \"platform\": \"IOS\"\n },\n \"accountStatus\": \"ACCEPTED\",\n \"metadata\": [\n {\n \"name\": \"nickname\",\n \"type\": \"string\",\n \"value\": \"Puffy\",\n \"visibility\": [\n \"api\"\n ]\n },\n {\n \"name\": \"otherDetails\",\n \"type\": \"object\",\n \"value\": {\n \"availability\": {\n \"mon\": \"10:00\",\n \"sat\": \"16:20\",\n \"wed\": \"13:30\"\n },\n \"premiumInsurance\": false,\n \"trunkSize\": 9.5\n },\n \"visibility\": [\n \"api\"\n ]\n }\n ],\n \"imageUrl\": null,\n \"teams\": [\n \"R4P7jhuzaIZ4cHHZE1ghmTtB\"\n ],\n \"delayTime\": null,\n \"location\": [\n -122.4015496466794,\n 37.77629837661284\n ],\n \"vehicle\": null\n },\n {\n \"id\": \"1LjhGUWdxFbvdsTAAXs0TFos\",\n \"timeCreated\": 1455049755000,\n \"timeLastModified\": 1455072352267,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"Yevgeny\",\n \"displayName\": \"YV\",\n \"phone\": \"+14155552299\",\n \"activeTask\": null,\n \"tasks\": [\n \"*0tnJcly~vSI~9uHz*ICHXTw\",\n \"PauBfRH8gQCjtMLaPe97G8Jf\"\n ],\n \"onDuty\": true,\n \"timeLastSeen\": 1455156649007,\n \"capacity\": 0,\n \"userData\": {\n \t\"appVersion\": \"1.2.0\",\n \"batteryLevel\": 0.97,\n \"deviceDescription\": \"Galaxy S8\",\n \"platform\": \"Android\"\n },\n \"accountStatus\": \"ACCEPTED\",\n \"metadata\": [],\n \"location\": [\n -122.4016366,\n 37.7764098\n ],\n \"imageUrl\": null,\n \"teams\": [\n \"9dyuPqHt6kDK5JKHFhE0xihh\",\n \"yKpCnWprM1Rvp3NGGlVa5TMa\",\n \"fwflFNVvrK~4t0m5hKFIxBUl\"\n ],\n \"delayTime\": null,\n \"vehicle\": {\n \"id\": \"ArBoHNxS4B76AiBKoIawY9OS\",\n \"type\": \"CAR\",\n \"description\": \"Lada Niva\",\n \"licensePlate\": \"23KJ129\",\n \"color\": \"Red\",\n \"timeLastModified\": 1545086815176\n }\n }\n]", "language": "json", "name": "Response" } ] } [/block] The index of each id in the `tasks` array indicates the order of assigned tasks for that worker. [block:api-header] { "type": "get", "title": "Get workers by location" } [/block] You may provide a coordinate pair along with a radius to get a list of workers who are currently within a certain target area. Query parameters [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "longitude", "0-1": "number", "0-2": "The longitude component of the coordinate pair.", "1-0": "latitude", "1-1": "number", "1-2": "The latitude component of the coordinate pair.", "2-0": "radius", "2-1": "number", "2-2": "Optional. The length in meters of the radius of the spherical area in which to look for workers. Defaults to 1000 if missing. Maximum value is 10000." }, "cols": 3, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "$ curl -X GET \"https://onfleet.com/api/v2/workers/location?longitude=-122.41275787353516&latitude=37.78998061344339&radius=6000\" \\\n -u \"cd3b3de84cc1ee040bf06512d233719c:\"", "language": "shell", "name": "Request" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"workers\": [\n {\n \"id\": \"h*wSb*apKlDkUFnuLTtjPke7\",\n \"timeCreated\": 1458416497000,\n \"timeLastModified\": 1478383350446,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"Andoni\",\n \"displayName\": \"Andoni\",\n \"phone\": \"+14155558442\",\n \"activeTask\": \"kc8SS1tzuZ~jqjlebKGrUmpe\",\n \"tasks\": [\n \"11z1BbsQUZFHD1XAd~emDDeK\",\n \"kc8SS1tzuZ~jqjlebKGrUmpe\"\n ],\n \"onDuty\": true,\n \"isResponding\": true,\n \"timeLastSeen\": 1480385504517,\n \"capacity\": 0,\n \"userData\": {\n \"appVersion\": \"1.2.0\",\n \"batteryLevel\": 0.99,\n \"deviceDescription\": \"Simulator (iOS 12.1.0)\",\n \"platform\": \"IOS\"\n },\n \"accountStatus\": \"ACCEPTED\",\n \"metadata\": [],\n \"imageUrl\": null,\n \"teams\": [\n \"gDTOyY9W33yWxnFQ~Gqo9mAr\"\n ],\n \"capacity\": 0,\n \"userData\": {},\n \"location\": [\n -122.4088934,\n 37.7593079\n ],\n \"delayTime\": 1650,\n \"vehicle\": {\n \"id\": \"ArBoHNxS4B76AiBKoIawY9OS\",\n \"type\": \"CAR\",\n \"description\": \"Tesla Roadster\",\n \"licensePlate\": \"ELON4PREZ\",\n \"color\": \"black\",\n \"timeLastModified\": 1478383350431\n }\n },\n {\n \"id\": \"sFtvhYK2l26zS0imptJJdC2q\",\n \"timeCreated\": 1473361545000,\n \"timeLastModified\": 1480384608044,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"Hitachino\",\n \"displayName\": \"HT\",\n \"phone\": \"+16175552820\",\n \"activeTask\": null,\n \"tasks\": [],\n \"onDuty\": true,\n \"isResponding\": true,\n \"timeLastSeen\": 1480385496759,\n \"capacity\": 0,\n \"userData\": {\n \"deviceDescription\": \"iPhone 6S (iOS 9.3.2)\",\n \"batteryLevel\": 0.43,\n \"appVersion\": \"0.9.65\",\n \"platform\": \"IOS\"\n },\n \"accountStatus\": \"ACCEPTED\",\n \"metadata\": [],\n \"imageUrl\": null,\n \"teams\": [\n \"gDTOyY9W33yWxnFQ~Gqo9mAr\"\n ],\n \"location\": [\n -122.4431349803903,\n 37.75080475959717\n ],\n \"delayTime\": null,\n \"vehicle\": {\n \"id\": \"tN1HjcvygQWvz5FRR1JAxwL8\",\n \"type\": \"CAR\",\n \"description\": null,\n \"licensePlate\": null,\n \"color\": null,\n \"timeLastModified\": 1473361545335\n }\n }\n ]\n}", "language": "json", "name": "Response" } ] } [/block] [block:api-header] { "type": "get", "title": "Get single worker" } [/block] Basic worker duty event, traveled distance (meters) and time analytics are optionally available by specifying the query parameter ```analytics``` as ```true```. You may also provide both ```from``` and ```to``` timestamps as query parameters (up to a maximum duration of 24 hours) to target a specific time range. If you omit these parameters, the worker analytics for the last week will be provided. Query parameters [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "filter", "0-1": "string array", "0-2": "Optional. A comma-separated list of fields to return, if all are not desired. For example, `[ name, location ]`." }, "cols": 3, "rows": 1 } [/block] [block:code] { "codes": [ { "code": "$ curl -X GET \"https://onfleet.com/api/v2/workers/1LjhGUWdxFbvdsTAAXs0TFos?analytics=true\" \\\n -u \"cd3b3de84cc1ee040bf06512d233719c:\"", "language": "shell", "name": "Request" }, { "code": "$ curl -X GET \"https://onfleet.com/api/v2/workers/1LjhGUWdxFbvdsTAAXs0TFos\" \\\n -u \"cd3b3de84cc1ee040bf06512d233719c:\"", "language": "shell", "name": "Request - No Analytics" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"id\": \"1LjhGUWdxFbvdsTAAXs0TFos\",\n \"timeCreated\": 1455049755000,\n \"timeLastModified\": 1455072352267,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"Yevgeny\",\n \"phone\": \"+14155552299\",\n \"activeTask\": null,\n \"tasks\": [\n \"*0tnJcly~vSI~9uHz*ICHXTw\",\n \"PauBfRH8gQCjtMLaPe97G8Jf\"\n ],\n \"onDuty\": true,\n \"timeLastSeen\": 1455156649007,\n \"delayTime\": null,\n \"teams\": [\n \"9dyuPqHt6kDK5JKHFhE0xihh\",\n \"yKpCnWprM1Rvp3NGGlVa5TMa\",\n \"fwflFNVvrK~4t0m5hKFIxBUl\"\n ],\n \"metadata\": [],\n \"location\": [\n -122.4016366,\n 37.7764098\n ],\n \"vehicle\": {\n \"id\": \"ArBoHNxS4B76AiBKoIawY9OS\",\n \"type\": \"CAR\",\n \"description\": \"Lada Niva\",\n \"licensePlate\": \"23KJ129\",\n \"color\": \"Red\"\n },\n \"analytics\": {\n \"events\": [\n {\n \"action\": \"onduty\",\n \"time\": 1455072352164\n },\n {\n \"action\": \"offduty\",\n \"time\": 1455072485603\n }\n ],\n \"distances\": {\n \"enroute\": 0,\n \"idle\": 0\n },\n \"times\": {\n \"enroute\": 0,\n \"idle\": 132.18\n },\n \"taskCounts\": {\n \"succeeded\": 0,\n \"failed\": 0\n }\n }\n}", "language": "json", "name": "Response" }, { "code": "{\n \"id\": \"1LjhGUWdxFbvdsTAAXs0TFos\",\n \"timeCreated\": 1455049755000,\n \"timeLastModified\": 1455072352267,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"Yevgeny\",\n \"phone\": \"+14155552299\",\n \"activeTask\": null,\n \"tasks\": [\n \"*0tnJcly~vSI~9uHz*ICHXTw\",\n \"PauBfRH8gQCjtMLaPe97G8Jf\"\n ],\n \"onDuty\": true,\n \"timeLastSeen\": 1455156649007,\n \"delayTime\": null,\n \"teams\": [\n \"9dyuPqHt6kDK5JKHFhE0xihh\",\n \"yKpCnWprM1Rvp3NGGlVa5TMa\",\n \"fwflFNVvrK~4t0m5hKFIxBUl\"\n ],\n \"metadata\": [],\n \"location\": [\n -122.4016366,\n 37.7764098\n ],\n \"vehicle\": {\n \"id\": \"ArBoHNxS4B76AiBKoIawY9OS\",\n \"type\": \"CAR\",\n \"description\": \"Lada Niva\",\n \"licensePlate\": \"23KJ129\",\n \"color\": \"Red\"\n }\n}", "language": "json", "name": "Response - No analytics" } ] } [/block] The ```analytics``` query parameter being set to ```true``` will result in a more detailed response. [block:api-header] { "type": "put", "title": "Update worker" } [/block] **Note that it is not possible to programmatically update a worker's `phone`.** The request to update a worker's phone number will not trigger an error. [block:code] { "codes": [ { "code": "$ curl -X PUT \"https://onfleet.com/api/v2/workers/sFtvhYK2l26zS0imptJJdC2q\" \\\n -u \"cd3b3de84cc1ee040bf06512d233719c:\" \\\n -d '{\"name\":\"Laura P\",\"teams\":[\"lHCUJFvh6v0YDURKjokZbvau\"]}'", "language": "shell", "name": "Request" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"id\": \"sFtvhYK2l26zS0imptJJdC2q\",\n \"timeCreated\": 1455156653000,\n \"timeLastModified\": 1455156654558,\n \"organization\": \"yAM*fDkztrT3gUcz9mNDgNOL\",\n \"name\": \"Laura P\",\n \"phone\": \"+16173428853\",\n \"activeTask\": null,\n \"tasks\": [],\n \"onDuty\": false,\n \"timeLastSeen\": null,\n \"delayTime\": null,\n \"teams\": [\n \"lHCUJFvh6v0YDURKjokZbvau\"\n ],\n \"metadata\": [],\n \"vehicle\": {\n \"id\": \"tN1HjcvygQWvz5FRR1JAxwL8\",\n \"type\": \"CAR\",\n \"description\": \"Tesla Model 3\",\n \"licensePlate\": \"FKNS9A\",\n \"color\": \"purple\"\n }\n}", "language": "json", "name": "Response" } ] } [/block] [block:api-header] { "type": "delete", "title": "Delete worker" } [/block] Note that workers with an active task cannot be deleted until the task has been completed. [block:code] { "codes": [ { "code": "$ curl -X DELETE \"https://onfleet.com/api/v2/workers/sFtvhYK2l26zS0imptJJdC2q\" \\\n -u \"cd3b3de84cc1ee040bf06512d233719c:\"", "language": "shell", "name": "Request" } ] } [/block] [block:code] { "codes": [ { "code": "HTTP/1.1 200 OK", "language": "http", "name": "Response" } ] } [/block] [block:api-header] { "type": "get", "title": "Get worker's schedule" } [/block] Retrieves all of the schedule entries for a worker. [block:code] { "codes": [ { "code": "$ curl \"https://onfleet.com/api/v2/workers/GPOQQjU84QPN~fP*pbunT2CW/schedule\" -u \"cd3b3de84cc1ee040bf06512d233719c:\"", "language": "shell", "name": "Request" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"entries\":[\n {\n \"date\": \"2017-07-20\",\n \"shifts\": [[1500591600000,1500613200000]],\n \"timezone\": \"America/Los_Angeles\"\n },\n {\n \"date\": \"2017-07-17\",\n \"shifts\": [[1500307200000,1500314400000], [1500323100000,1500336000000]],\n \"timezone\": \"America/Los_Angeles\"\n }\n ]\n}", "language": "json", "name": "Response" } ] } [/block] [block:api-header] { "type": "post", "title": "Set worker's schedule" } [/block] Uses the provided list of entry objects to set the worker's schedule. Entries earlier than the start of the current week will not be saved. The structure of an entry list is as follows. [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "date", "0-1": "string", "0-2": "A YYYY-MM-DD formatted date.", "1-0": "timezone", "1-1": "string", "1-2": "A valid timezone.", "2-0": "shifts", "2-1": "array", "2-2": "each element is a two element array which contains the start and end times of the shift as timestamps." }, "cols": 3, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "$ curl -X POST \"https://onfleet.com/api/v2/workers/GPOQQjU84QPN~fP*pbunT2CW/schedule\" -u \"cd3b3de84cc1ee040bf06512d233719c:\" \\-d '\n{\n\t\"entries\":[\n \t{\n \t\"date\":\"2017-07-16\",\n \t\"shifts\":[[1500213600000,1500249600000]],\n \t\"timezone\":\"America/Los_Angeles\"\n },\n {\n \t\"date\":\"2017-07-20\",\n \"shifts\":[[1500591600000,1500613200000]],\n \"timezone\":\"America/Los_Angeles\"\n },\n {\n \t\t\"date\":\"2017-07-17\",\n \t\"shifts\":[[1500307200000,1500314400000], [1500323100000,1500336000000]],\n \t\"timezone\":\"America/Los_Angeles\"\n },\n {\n \t\t\"date\":\"2016-07-17\",\n \t\"shifts\": [[1500307200000,1500314400000],[1500323100000,1500336000000]],\n \t\"timezone\":\"America/Los_Angeles\"\n }\n ]\n }'\n", "language": "shell", "name": "Request" } ] } [/block] Notice that some entries were removed: [block:code] { "codes": [ { "code": "{\n \"entries\":[\n {\n \"date\": \"2017-07-20\",\n \"shifts\": [[1500591600000,1500613200000]],\n \"timezone\": \"America/Los_Angeles\"\n },\n {\n \"date\": \"2017-07-17\",\n \"shifts\": [[1500307200000,1500314400000], [1500323100000,1500336000000]],\n \"timezone\": \"America/Los_Angeles\"\n }\n ]\n}", "language": "json", "name": "Response" } ] } [/block]