Job for driver REST API
This API service allows you to create a job from scratch with either an existing contact or customer or a new contact and customer. It will also assign the job to a drivers current shift. If the driver does not have a shift Crittah will also create a shift for that driver and assign the job to that driver. Use this API service for automating you back end POS (Point Of Sales) other LOB (Line of Business) application to automate job dispatch from completely outside of Crittah.
To assign a job to a driver using this interface the driver needs to be already setup in Crittah. You can use either the drivers ID or their username.
If there is no current active shift for the driver then Crittah will create a new shift for that driver starting from the beginning of the hour that the job was created and ending 8 hours after the start time of the shift.
Working with a single job
Method | Result |
---|---|
URI | https://[CompanyID].crittah.com/ws/apiv2/[json or xml]/jobs/driver/[DriverIDOrUsername] |
POST | Create a job for an existing driver in Crittah. |
Data fields
Field | Value type | Mandatory | Description | Example |
---|---|---|---|---|
DriverIDOrUsername | string | YES | This is either the name or the id of the driver that the job will be assigned to. | jsmith or be402eac-1871-4432-ad5a-dfb5404d61f7 |
IDJobType | string | YES | ID of the job type being created. Job type information can be retrieved from here. | 7090fad1-c4da-4488-9ceb-55ee9847edcc |
IDStatus | string | ID of the job status. Job statuses can be retries from here . If omitted the status will default to New. | 926a4185-6cb3-4a2a-a8ec-1fadc1cf4caa | |
IDSite | string | YES | ID of the site the job belongs to. | 20058233-7388-418b-9193-6b57e28604f9 |
Customer | Customer Object | Either a custom or a contact must be provided. | An object defining the customer. If the customer already exists you only need to provide the CustomerID. Complete details of the customer object can be found here. | See Customer Object |
Contact | Contact Object | Either a custom or a contact must be provided. | An object defining the contact. If the contact already exists you only need to provide the ContactID. Complete details of the contact object can be found here. | See Contact Object |
DueDate | string | UTC date in ISO 8601 format. If omitted the job due time will be the current time. | 2010-08-20T15:00:00Z | |
ChargeAmount | decimal | Amount to charge for the job. If omitted the default charge amount will be used as configured in the job type. | 20.52 | |
StartDate | string | UTC date in ISO 8601 format. Omit this values if the job has not started. | 2010-08-20T15:00:00Z | |
FinishDate | string | UTC date in ISO 8601 format. Omit this values if the job has not finished. | 2010-08-20T15:00:00Z | |
Duration | int | Duration of job in minutes | 20 | |
Address | Address Object | Address of the job. | ||
AddressDelivery | Address Object | Delivery address if the job has a start and a destination. This address will be displayed if the job type has been configured to use a delivery address. | See Address Object | |
CustFields | Array of custom fields objects | An array of all custom field data for the job. Custom field attributes are described below. | ||
Notes | Array of Notes Object | Notes for the job. | See Notes Object | |
Items | Array of Items objects | Inventory items used on the job. These items can be items from the inventory information in Crittah or free text line items. |
Custom field, fields
Please refer to the Custom Field API to provide list of available custom fields configured in Crittah.
Field | Value type | Mandatory | Description | Example |
---|---|---|---|---|
IDCF | string | ID of the job type being created. Job type information can be retrieved from here. | 7090fad1-c4da-4488-9ceb-55ee9847edcc | |
VDate | string | UTC date in ISO 8601 format | 2010-08-20T15:00:00Z | |
VDec | decimal | Number value for Numeric and Measurement fields. With measure values, measures are stored as kg or cubic meters depending on the measure type. These measure are then converted based on the users personal preferences. | 23.45 | |
VStr | string | String value for String fields | Hello this is a string | |
VID | string | Value selected if field is a selector field. | 7090fad1-c4da-4488-9ceb-55ee9847edcc |
Examples
Add Job
This add job example will create a new job with a new customer and contact into Crittah. The job will then be assigned to the drivers current shift. If a shift does not exist the shift will also be created.
Add the following contents to a file called "add_job_complicated.data"
{ "IDJobType": "72318033-b541-4b07-baf2-158ff8a2e246", "IDSite": "20058233-7388-418b-9193-6b57e28604f9", "IDStatus": "a610305a-1a34-4c3d-b271-d710ba6b3be3", "Customer": { "CompanyName": "Test Incorperated", "CompanyNo": "987 654 3210", "Phone": "555 3293 2001", "Mobile": "0416 234 568", "Fax": "555 323 574", "Council": "LA", "IDSite": "20058233-7388-418b-9193-6b57e28604f9", "IDTypes": [ "4d819963-731c-41fd-9378-fd7a10199b78", "21a952eb-089e-467a-98bf-f8cb9a0ebd88" ], "IDStatus": "926a4185-6cb3-4a2a-a8ec-1fadc1cf4caa", "WebSite": "http:\/\/www.testcorp.com", "Address": { "AddressLine1": "Suite 8032", "AddressLine2": "21 King Street", "City": "SYDNEY", "State": "NSW", "Country": "Australia", "PostCode": "2021", "LocRef": { "LatLng": { "Lat": -33.869738, "Lng": 151.209448 } } }, "AddressBilling": { "AddressLine1": "Suite 8032", "AddressLine2": "22 King Street", "City": "SYDNEY", "State": "NSW", "Country": "Australia", "PostCode": "2022" }, "Notes": [ { "IDNoteType": "77d5d244-eb29-4b5b-8b14-87d92b4215ea", "NoteInfo": "Take lift to level 8 turn right. Reception in front of you." }, { "IDNoteType": "77d5d244-eb29-4b5b-8b14-87d92b4215ea", "NoteInfo": "If receptionist not there ring bell on wall." } ] }, "Contact": { "Salutation": "Mr", "FirstName": "John", "LastName": "Peterson", "Email": "j.peterson@gmal.com", "Phone": "(02) 9506 3560", "Mobile": "0412 544 654", "Fax": "9567 680", "IDSite": "20058233-7388-418b-9193-6b57e28604f9", "IDStatus": "926a4185-6cb3-4a2a-a8ec-1fadc1cf4caa", "Types": [ "c0fd94f3-2ddd-4eea-bc24-40189480d10f", "eb6bef8f-6f03-49dd-80a4-83a220f6ddc3" ], "Address": { "AddressLine1": "26 Wolongong ROad", "AddressLine2": null, "City": "ARNCLIFFE", "State": "NSW", "IDCountry": 1013, "Country": "Australia", "PostCode": "2205", "LocRef": { "IDLocation": "328e934c-930f-4610-af3c-edf83c2b9d1a", "LatLng": { "Lat": -33.934813, "Lng": 151.146104 } } }, "Notes": [ { "IDNoteType": "2b11efc3-2a43-4c03-92ac-923e77f821a2", "NoteInfo": "Maincontact for organisation", } ] }, "DueDate": "2014-10-06T10:55:00Z", "Address": { "AddressLine1": "91 Castlereagh Street", "AddressLine2": null, "City": "NORTH SYDNEY", "State": "NSW", "Country": "Australia", "PostCode": "2000", "LocRef": { "IDLocation": "3ac45077-b768-4264-b085-506892b46691", "LatLng": { "Lat": -33.869738, "Lng": 151.209448 } } }, "AddressDelivery": { "AddressLine1": "200 George St", "AddressLine2": null, "City": "SYDNEY", "State": "NSW", "Country": "Australia", "PostCode": "2000", "LocRef": { "IDLocation": "4e878177-7de5-431e-b843-3ecdc4b6e8f0", "LatLng": { "Lat": -33.869738, "Lng": 151.209448 } } }, "CustFields": { "CF": [ { "IDCF": "b1bf411e-5de9-4068-95c7-1c073eed0080", "VDec": 33 }, { "IDCF": "26ffa3ee-7cc6-4d2a-bc5f-6aa314c1a2bd", "VDec": 34 } ] }, "Notes": [ { "IDNoteType": "77d5d244-eb29-4b5b-8b14-87d92b4215ea", "NoteInfo": "This just came in from the web" } ], "Items": [ ] }
Run the follow cURL command
curl -X POST -d add_job_to_driver.data \ -H "Content-Type: application/json" \ -H "API-AppID: 7090fad1-c4da-4488-9ceb-55ee9847edcc" \ -H "Api-Username: jsmith" \ -H "API-Password: abc123" \ https://[COmpanyID].crittah.com/ws/apiv2/json/jobs/driver/jsmith