REST API: Add Custom Field Items

Last Updated: May 12, 2015

Description

Add one or more customfielditems to a customfield. We will handle batches of up to 50 customfielditems at a time. More than 50 customfielditems will result in a 413 - Request entity too large error.

Resource Information

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

Required Custom Field Item Properties

name:
String. Name of the customfielditem.
customfield_id:
Integer. The id of the customfield you want this item to belong to.

Optional Custom Field Item Properties

For a full list of the properties that may be set on a custom field item, see the Custom Field Items object.

Status Codes

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

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

Examples

Create two new customfielditems. One succeeds. The other fails because of a duplicate short_code on an existing customfielditem.

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

## contents of the customfielditems_create.json file are:
{
 "data":
  [
    {
     "name":"ServiceItem1",
     "customfield_id":"19142",
     "short_code":"c1"
    },
    {
     "name":"ServiceItem2",
     "customfield_id":"19142",
     "short_code":"c1"
    }
  ]
}



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

{
 "results": {
  "customfielditems": {
   "1": {
    "_status_code": 200,
    "_status_message": "Created",
    "id": 3085864,
    "customfield_id": 19142,
    "active": true,
    "short_code": "c1",
    "name": "ServiceItem1"
   },
   "2": {
    "_status_code": 417,
    "_status_message": "Expectation Failed",
    "_status_extra": "Oops! The name or alias conflicts with another item named \"ServiceItem1\". Try choosing another name\/alias or deleting the other conflicting item first",
    "name": "ServiceItem2"
   }
  }
 },
 "supplemental_data": {
  "customfields": {
   "19142": {
    "id": 19142,
    "required": true,
    "type": "timesheet",
    "ui_preference": "managed-list",
    "short_code": "cf1",
    "regex_filter": "",
    "name": "Custom Field 1",
    "last_modified": "2013-07-23T23:09:14+00:00",
    "created": "2013-07-23T23:09:14+00:00"
   }
  }
 }
}