Adds task to jobs and create them if they don't exist

/v2/jobs/tasks

Adds task to jobs, creating the jobs if they don't exist.
If any of the tasks specifies JobId with value 0, then a new job will be created and all the tasks that specify JobId with value 0 will be associated with it. This job will be returned and any other tasks, if any was specified, are ignored.

If multiple tasks are being added to an existing job, they all should specify an existing JobId.

The structures Who, Where, When and What of each task are not mandatory ; they may be defined only when necessary. When any of these structures is defined, some validations are performed on their field's values.
Check section Response HTTP Codes > 400 below where the error condictions are enumerated.

Regarding sturcture Who, this structure may be used by the Frontend to include one reference to a CRM client and/or one reference to an address. The front end uses specificaly and only the fields ClientId and ContactId for this matter ; any other fields of the structure Who are, at the moment of this writing, ignored by the Frontend.

Forms structure may also be included when necessary. When it is included a form is attached to the task as a set of fields and their specified values, concerning the following:

  • The attached information is the one specified in the fields name and value
  • Each field is only included in the form attachment if one of the following condition applies:
    • The defaultValue is specified and the value is not -1, or
    • The defaultValue is not specified but value is (not null nor empty string)

Parameters

tasks

The parameter of this endpoint is an array of objects. Each object defines the data of a task to add as well as the ID of the job.

[{ 
  "JobId": 0,
  "TypeId" : int: Task type 
  "Who": { 
      "ClientId": 0,
      "ContactId": 0,
      "ContactName": "string",
      "ClientName": "string",
      "OfficePhone": "string",
      "MobilePhone": "string"
  } 
  "Where": {
      "ClientAddressId": 0, 
      "AddressLine1": "string",
      "AddressLine2": "string", 
      "ZipCode": "string",
      "City": "string",
      "CountryIso": "string",
      "PlaceId": 0,
      "Latitude": 0.0,
      "Longitude": 0.0,
      "instructions": "string",
      "notes": "string"
  } 
  "What":{
      "Reference": "string",
      "Content": "string",
      "Quantity": 0,
      "UnitId": 0,
      "Notes": "string",
      "Duration": 0
  },
  "When": {
      "When": "noTimeRestriction",
      "Start": "2023-08-23T14:36:13.182Z",
      "End": "2023-08-23T14:36:13.182Z",
      "Tolerance": true,
      "ToleranceBefore": 0,
      "ToleranceAfter": 0,
      "Exclusion": true,
      "ExclusionStart": "2023-08-23T14:36:13.182Z", 
      "ExclusionEnd": "2023-08-23T14:36:13.182Z"
  },
  "Forms":[
      {
       "id": 0,
       "version": 0,
       "name": "string",
       "fields":[{
             "name": "string"
             "defaultValue": "string",
             "value": "string"
           }
        ]
      }
  ]
}]

FieldDescription
JobId Job Id to associate the Task. If 0 is specified a new Job is created. int
TypeId The Id if the type of the task int
Who The structure in which is is possible to provate data about a client that is related to the task. object no
Who.ClientId Client Id (CRM Client) int no
Who.ContactId Contact Id (CRM Client) int no
Who.ContactName Contact name (CRM Client) string no
Who.ClientName Client name (CRM Client) string no
Who.OfficePhone Office phone (CRM Client) string no
Who.MobilePhone Mobile phone (CRM Client) string no
Where Structure that allows to include custom information about a place that is related to the task. object no
Where.ClientAddressId Client Address Id (CRM client) int no
Where.AddressLine1 Address line 1 string no 300 characters
Where.AddressLine2 Address line 2
Note:this field is deprecated.
Frotcom applications (Frontend, Driver app, etc.) are currently using only the field Where.AddressLine1 string no 150 characters
Where.ZipCode The zip Code
Note:this field is deprecated.
Frotcom applications (Frontend, Driver app, etc.) are currently using only the field Where.AddressLine1 string no 10 characters
Where.City The city. Note:this field is deprecated.
Frotcom applications (Frontend, Driver app, etc.) are currently using only the field Where.AddressLine1 string no 50 characters
Where.CountryIso The ISO code that identifies the country.
Note:this field is deprecated.
Frotcom applications (Frontend, Driver app, etc.) are currently using only the field Where.AddressLine1 string no 2 characters
Where.PlaceId The Id of a place in the account int no
Where.Latitude The latitude of a place to reference double no
Where.Longitude The longitude of a place to reference double no
Where.Instructions Allows to include instructions about the location related with the task.
Note: this field is deprecated.
string no
Where.Notes Allows to include notes about the location related with the task.
string no
What.Reference Allows to specify a custom reference for the task Enter a reference for the task string no 400 characters
What.Content Products/Service string no 150 characters
What.Quantity Indicate, if you must, a quantity related to the product or service int no
What.UnitId An ID that identifies the unit. See the table bellow
IDUnit
1Kilogram
2Liter
3Pallet
4EUR-Pallet
5Box
6Container
7m2

int no
What.Notes Annotations field string no 150 characters
What.Duration Duration long no
When Object that can be used to specify data about the date and time of the task object no
When.When
IDOption
1NoTimeRestriction
3TimeAndTolerance
4TimeRange
enum no ????
When.Start If the field when is set to NoTimeRestriction, then this field must be null;
If the field when is set to TimeRange, then this field should be the start date of interval to arrive datetime no
When.End If the field when is set to NoTimeRestriction or TimeAndTolerance, then this field must be null;
If the field when is set to TimeRange, then this field should be the end date of interval to arrive datetime no
When.Tolerance When set to true, allows to specify tolerances to the arrival time. bool no
When.ToleranceBefore If the field when is set to TimeAndTolerance, and the field Tolerance is set to true, then this field specifies the tolerance, in seconds, before the arrival time; otherwise it should be null. int no
When.ToleranceBefore If the field when is set to TimeAndTolerance, and the field Tolerance is set to true, then this field specifies the tolerance, in seconds, after the arrival time; otherwise it should be null. int no
When.Exclusion Set to true if you want to exclude arrival in interval of dates bool no
When.ExclusionStart If the field exclusion is set to true, then this should be the exclusion start date interval, otherwise it should be null; datetime no
When.ExclusionEnd If the field exclusion is set to true, then this should be the exclusion end date interval, otherwise it should be null; datetime no
When.Forms Allows to specify an array of forms to associate with the task array no
When.Forms[index].id The ID of a form in the account int yes
When.Forms[index].version The version of the form to use int yes
When.Forms[index].Name The name of the form to present to the user string no
When.Forms[index].fields Array of the fields of the form. object no
When.Forms[task-index].fields[form-index].name The name of the field string no 150 characters
When.Forms[task-index].fields[form-index].defaultValue The default value of the field string no 150 characters
When.Forms[task-index].fields[form-index].value The value of the field string no 150 characters

Response Body

[
    {
        "id": 0,
        "tasks" : [0],
        "isNew": true
    }
]

FieldDescription
id The ID of the vehicle to where the route should be assigned string
tasks The ID of the vehicle to where the route should be assigned string
isNew The ID of the vehicle to where the route should be assigned string

Response HTTP Codes

201 - Created

  • The tasks were created

400 - Bad Request

  • JobTask is null or is an empty array of JobTask
  • TypeId is 0
  • JobTask.What.Reference is not null and Reference.Length is bigger then 400
  • JobTask.What.Content is not null and Content.Length is bigger then 150
  • JobTask.What.UnitId has value and UnitId is lower then 0
  • JobTask.What.Notes is not null and Notes.Lenght bigger then 3000
  • JobTask.Where.PlaceId has value and PlaceId is 0
  • JobTask.Where.AddressLine1 is not null and AddressLine1.Length is bigger then 300
  • JobTask.Where.AddressLine2 is not null and AddressLine2.Length is bigger then 150
  • JobTask.Where.ClientAddressId has value and ClientAddressId is 0
  • JobTask.Where.Latitude has value and JobTask.Where.Longitude is null
  • JobTask.Where.Latitude is null and JobTask.Where.Longitude has value
  • JobTask.Where.Notes is not null and Notes.Length is bigger then 500
  • JobTask.When.SLA is true and one of the following fields is also true: When.ExclusionEnd, When.ExclusionStart, When.End, When.Start, When.ToleranceAfter, When.ToleranceBefore
  • JobTask.When.ExclusionStart value is bigger then JobTask.When.ExclusionEnd value
  • JobTask.When.ExclusionStart has value and JobTask.When.ExclusionEnd is null
  • JobTask.When.ExclusionStart is null andJobTask.When.ExclusionEnd has value
  • JobTask.When.End has value and When.Start is null
  • JobTask.When.End is null, JobTask.When.Start has value and JobTask.When.ToleranceAfter or JobTask.When.ToleranceBefore has value

403 - Forbidden

  • The authenticated user doesn't have permissions to View Jobs