Set worker's schedule

Set worker's schedule

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.

Name

Type

Description

date

string

A YYYY-MM-DD formatted date.

timezone

string

A valid timezone.

shifts

array of unix time

each element is a two element array which contains the start and end times of the shift as timestamps in Unix time.

📘

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. For more information please see Data Types and Response Formats or free conversion tool online here.

curl -X POST "https://onfleet.com/api/v2/workers/GPOQQjU84QPN~fP*pbunT2CW/schedule" -u "cd3b3de84cc1ee040bf06512d233719c:" \-d '
{
    "entries":[
    {
        "date":"2017-07-16",
        "shifts":[[1500213600000,1500249600000]],
        "timezone":"America/Los_Angeles"
    },
    {
        "date":"2017-07-20",
      "shifts":[[1500591600000,1500613200000]],
      "timezone":"America/Los_Angeles"
     },
     {
            "date":"2017-07-17",
        "shifts":[[1500307200000,1500314400000], [1500323100000,1500336000000]],
        "timezone":"America/Los_Angeles"
      },
      {
            "date":"2016-07-17",
            "shifts": [[1500307200000,1500314400000],[1500323100000,1500336000000]],
            "timezone":"America/Los_Angeles"
      }
    ]
 }'
onfleet.workers.setSchedule(id="GPOQQjU84QPN~fP*pbunT2CW", body={
    "entries":[
    {
        "date":"2017-07-16",
        "shifts":[[1500213600000,1500249600000]],
        "timezone":"America/Los_Angeles"
    },
    {
        "date":"2017-07-20",
      "shifts":[[1500591600000,1500613200000]],
      "timezone":"America/Los_Angeles"
     },
     {
            "date":"2017-07-17",
        "shifts":[[1500307200000,1500314400000], [1500323100000,1500336000000]],
        "timezone":"America/Los_Angeles"
      },
      {
            "date":"2016-07-17",
            "shifts": [[1500307200000,1500314400000],[1500323100000,1500336000000]],
            "timezone":"America/Los_Angeles"
      }
    ]
 })
onfleet.workers.setSchedule("GPOQQjU84QPN~fP*pbunT2CW", {
    "entries":[
    {
        "date":"2017-07-16",
        "shifts":[[1500213600000,1500249600000]],
        "timezone":"America/Los_Angeles"
    },
    {
        "date":"2017-07-20",
      "shifts":[[1500591600000,1500613200000]],
      "timezone":"America/Los_Angeles"
     },
     {
            "date":"2017-07-17",
        "shifts":[[1500307200000,1500314400000], [1500323100000,1500336000000]],
        "timezone":"America/Los_Angeles"
      },
      {
            "date":"2016-07-17",
            "shifts": [[1500307200000,1500314400000],[1500323100000,1500336000000]],
            "timezone":"America/Los_Angeles"
      }
    ]
 });
$onfleet->workers->setSchedule("GPOQQjU84QPN~fP*pbunT2CW", [
    "entries" =>[
    [
        "date" =>"2017-07-16",
        "shifts" =>[[1500213600000,1500249600000]],
        "timezone" =>"America/Los_Angeles"
    ],
    [
        "date" =>"2017-07-20",
      "shifts" =>[[1500591600000,1500613200000]],
      "timezone" =>"America/Los_Angeles"
     ],
     [
            "date" =>"2017-07-17",
        "shifts" =>[[1500307200000,1500314400000], [1500323100000,1500336000000]],
        "timezone" =>"America/Los_Angeles"
      ],
      [
            "date" =>"2016-07-17",
            "shifts" => [[1500307200000,1500314400000],[1500323100000,1500336000000]],
            "timezone" =>"America/Los_Angeles"
      ]
    ]
 ])

Notice that some entries were removed:

{
  "entries":[
    {
      "date": "2017-07-20",
      "shifts": [[1500591600000,1500613200000]],
      "timezone": "America/Los_Angeles"
    },
      {
        "date": "2017-07-17",
        "shifts": [[1500307200000,1500314400000], [1500323100000,1500336000000]],
        "timezone": "America/Los_Angeles"
      }
  ]
}