REST API: Edit Jobcodes

Last Updated: June 04, 2015

Description

Edit one or more jobcodes in your company. We will handle batches of up to 50 jobcodes at a time. More than 50 jobcodes will result in a 413 - Request entity too large error.

Resource Information

HTTP Method PUT
Endpoint https://rest.tsheets.com/api/v1/jobcodes
Authentication Token header required. See authentication section
Request format json object. Pass an array of jobcode objects as the value to a 'data' property (see example below).
Response format json
Response object Jobcode

Jobcode properties

When editing a jobcode, you must uniquely identify the jobcode by passing in its id property. Other properties defined on a jobcode object may be passed in to the request with a new value in order to change it. If the value passed in is the same as it was previously, or if a particular property is not passed in at all, it will be ignored. Certain properties (has_children, created, last_modified, etc.) are set automatically by the system and may not be modified.

NOTE: You cannot edit a jobcode that is archived. You must restore the jobcode first. It is permissible to make an edit to a jobcode and restore it in one edit request (i.e. change active to 1 and rename the jobcode in one step).

Status Codes

Each jobcode that is edited will come back with a _status_code and _status_message that will indicate whether the jobcode was edited successfully. If there was a problem editing a jobcode, there may also be an additional field, _status_extra, which will contain more details about the failure.

_status_code Meaning
200 OK. Jobcode was edited successfully.
417 Expectation Failed. Something was wrong or missing with the properties supplied for this jobcode. See the _status_extra value for more detail.

Examples

Change some information for each of these jobcodes.
Note: When attempting to run the example code below you will need to substitute the name and id listed and instead use jobcodes associated with your TSheets account.

## REQUEST
curl -H "Authorization: Bearer <Access-Token>" -H "Content-Type: application/json" -X PUT -i "https://rest.tsheets.com/api/v1/jobcodes" -d @tsjobcode_edit.json 

## contents of the tsjobcode_edit.json file are:
{
 "data":
  [
    {
     "id":10606354,
     "short_code":"cc3",
     "billable":"false",
     "name":"Customer30",
     "billable_rate":"57.50"
    },
    {
     "id":10608414,
     "short_code":"cc4",
     "billable":"false",
     "name":"Customer40",
     "billable_rate":"57.50"
    },
    {
     "id":10608424,
     "short_code":"cc1",
     "billable":"false",
     "name":"Customer10",
     "billable_rate":"57.50"
    }
  ]
}



## RESPONSE
HTTP/1.1 200 OK
Content-Type: application/json

{
 "results": {
  "jobcodes": {
   "1": {
    "_status_code": 200,
    "_status_message": "Updated",
    "id": 18059008,
    "parent_id": 17288279,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": false,
    "billable_rate": 57.5,
    "short_code": "cc3",
    "name": "Customer30",
    "last_modified": "2013-07-22T22:12:04+00:00",
    "created": "2013-07-22T19:19:28+00:00"
   },
   "2": {
    "_status_code": 200,
    "_status_message": "Updated",
    "id": 18064850,
    "parent_id": 17288279,
    "assigned_to_all": false,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": false,
    "billable_rate": 57.5,
    "short_code": "cc4",
    "name": "Customer40",
    "last_modified": "2013-07-22T22:12:05+00:00",
    "created": "2013-07-22T21:20:43+00:00"
   },
   "3": {
    "_status_code": 200,
    "_status_message": "Updated",
    "id": 18064852,
    "parent_id": 17288279,
    "assigned_to_all": false,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": false,
    "billable_rate": 57.5,
    "short_code": "cc1",
    "name": "Customer10",
    "last_modified": "2013-07-22T22:12:06+00:00",
    "created": "2013-07-22T21:20:51+00:00"
   }
  }
 },
 "supplemental_data": {
  "jobcodes": {
   "17288279": {
    "id": 17288279,
    "parent_id": 0,
    "assigned_to_all": false,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": true,
    "billable_rate": 0,
    "short_code": "asm",
    "name": "Assembly Line",
    "last_modified": "2013-07-12T21:13:14+00:00",
    "created": "2013-05-28T20:18:17+00:00"
   }
  }
 }
}