REST API: List Jobcode Assignments

Last Updated: November 07, 2016

Description

Retrieves a list of all jobcode assignments associated with users, with optional filters to narrow down the results. Note that jobcodes with the property assigned_to_all set to true will always be considered assigned to any given user. assigned_to_all jobcode assignments are indicated by a user_id value of 0 in the results. Also note that only active jobcodes will be considered assigned, as once a jobcode is archived, it is no longer available for selection for time entry.

Resource Information

HTTP Method GET
Endpoint https://rest.tsheets.com/api/v1/jobcode_assignments
Authentication Token header required. See authentication section
Request format Everything is handled through the request uri on a GET.
Response format json
Response object Jobcode Assignment

Available Filters

user_ids:
optional
Integer. Comma separated string of one or more user ids for whom you'd like to retrieve jobcode assignments. If none are specified, all jobcode assignments (which you have rights to view) will be returned. Only jobcode assignments belonging to these user_ids or where the jobcode assigned_to_all property is true will be returned. Results where assigned_to_all is true for a jobcode are indicated by a user_id value of 0 for the jobcode_assignment object. To view jobcode assignments for users other than yourself you must be an admin or a group manager or have the manage_users permission or the manage_jobcodes permission.
type:
optional
String. Refers to the jobcode type - regular, pto, unpaid_break, paid_break, or all. Defaults to regular.
jobcode_id:
optional
Integer. If specified, only assignments for jobcodes with the given id are returned.
jobcode_parent_id:
optional
Integer. When omitted, all jobcode assignments are returned regardless of jobcode parent. If specified, only assignments for jobcodes with the given jobcode parent_id are returned. To get a list of only top-level jobcode assignments, pass in a jobcode_parent_id of 0.
active:
optional
String. yes, no, or both. Default is both. Yes means the assignment is active, no means it is deleted/inactive.
modified_before:
optional
String (ISO8601 format). Only jobcode assignments modified before this date/time will be returned (i.e. 2004-02-12T15:19:21+00:00).
modified_since:
optional
String (ISO8601 format). Only jobcode assignments modified since this date/time will be returned (i.e. 2004-02-12T15:19:21+00:00).
supplemental_data:
optional
String. 'yes' or 'no'. Default is 'yes'. Indicates whether supplemental data should be returned.
per_page:
optional
Integer. Represents how many results you'd like to retrieve per request (page). Default is 50. Max is 50.
page:
optional
Integer. Represents the page of results you'd like to retrieve. Default is 1.

Examples

Retrieve a list of all jobcode assignments for user_id 1234.
Note: For the example below you would need to substitute the sample user_id to match a user id associated with your TSheets account.

## REQUEST
curl -H "Authorization: Bearer <Access-Token>" -i "https://rest.tsheets.com/api/v1/jobcode_assignments?user_ids=1234"

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

{
 "results": {
  "jobcode_assignments": {
   "26881275": {
    "id": 26881275,
    "user_id": 1242515,
    "jobcode_id": 17285791,
    "active": true,
    "last_modified": "",
    "created": ""
   },
   "26881277": {
    "id": 26881277,
    "user_id": 1242515,
    "jobcode_id": 17285793,
    "active": true,
    "last_modified": "",
    "created": ""
   },
   "26881273": {
    "id": 26881273,
    "user_id": 1242515,
    "jobcode_id": 17285795,
    "active": true,
    "last_modified": "",
    "created": ""
   },
   "26881271": {
    "id": 26881271,
    "user_id": 1242515,
    "jobcode_id": 17288283,
    "active": true,
    "last_modified": "",
    "created": ""
   }
  }
 },
 "more": false,
 "supplemental_data": {
  "users": {
   "1242515": {
    "id": 1242515,
    "first_name": "Alexander",
    "last_name": "Luzzana",
    "group_id": 144959,
    "active": true,
    "employee_number": 4,
    "salaried": true,
    "exempt": false,
    "username": "aluzzana",
    "email": "garrett@tsheets.com",
    "payroll_id": "4",
    "hire_date": "2012-07-01",
    "term_date": "0000-00-00",
    "job_title": "",
    "gender": "",
    "last_modified": "2013-07-12T15:52:00+00:00",
    "last_active": "2013-07-01T22:51:28+00:00",
    "created": "2013-05-28T20:23:44+00:00",
    "mobile_number": ""
   }
  },
  "jobcodes": {
   "17285791": {
    "id": 17285791,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "pto",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "",
    "name": "Sick",
    "last_modified": "2013-05-28T17:49:24+00:00",
    "created": "2013-05-28T17:49:24+00:00"
   },
   "17285793": {
    "id": 17285793,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "pto",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "",
    "name": "Vacation",
    "last_modified": "2013-05-28T17:49:24+00:00",
    "created": "2013-05-28T17:49:24+00:00"
   },
   "17285795": {
    "id": 17285795,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "pto",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "",
    "name": "Holiday",
    "last_modified": "2013-05-28T17:49:24+00:00",
    "created": "2013-05-28T17:49:24+00:00"
   },
   "17288283": {
    "id": 17288283,
    "parent_id": 0,
    "assigned_to_all": false,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "dev",
    "name": "Development Team",
    "last_modified": "2013-05-28T20:19:33+00:00",
    "created": "2013-05-28T20:19:33+00:00"
   }
  }
 }
}
    

Retrieve a list of all jobcode assignments modified since March 1st, 2013. Set pagination to 10 results/page. Currently logged in user's id will be used, because none is specified in the request.

## REQUEST
curl -H "Authorization: Bearer <Access-Token>" -i "https://rest.tsheets.com/api/v1/jobcode_assignments?modified_since=2013-03-01T00:00:00-0600&per_page=10"

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

{
 "results": {
  "jobcode_assignments": {
   "27569720": {
    "id": 27569720,
    "user_id": 0,
    "jobcode_id": 18081060,
    "active": true,
    "last_modified": "2013-07-24T18:18:37+00:00",
    "created": "2013-07-24T18:18:37+00:00"
   }
  }
 },
 "more": false,
 "supplemental_data": {
  "jobcodes": {
   "18081060": {
    "id": 18081060,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "test",
    "name": "Test",
    "last_modified": "2013-07-24T18:18:36+00:00",
    "created": "2013-07-23T22:41:02+00:00"
   }
  } 
 }
}