NAV Navbar
cURL C# VB.NET Java AJAX NodeJS PHP Ruby Python Perl Go Swift

Welcome

Thank you for visiting the TSheets API Documentation Portal! We hope you'll easily find everything you need. If not, please let us know and we'll make it right. Whether you're running into a problem, have feedback or a great suggestion, or would just like to talk through integration scenarios, we'd love to hear from you.

Introduction

The TSheets API provides programmatic access to the same time tracking, managing, scheduling and reporting features as our top-rated web-based and mobile apps. With it you can quickly build integrations, for example to automatically sync employee time tracking data for payroll and invoicing. Or, create new scheduling or project management solutions. The options are unlimited. For inspiration, check out the amazing integrations our partners have built on our App Marketplace. They're solving real business needs and saving customers time and money.

Based on REST principles, it's very easy to write and test applications. You can use your browser to access URLs, and practically any TLS-capable HTTP client in any programming language to interact with the API. The API allows you to query metadata about your account, users, jobcodes, timesheets, GPS points, and custom fields. You can also create timesheets, users, jobcodes, etc. All access to the API occurs over a TLS-encrypted secure channel, so your API client must support TLS. To ensure data privacy, unencrypted HTTP is not supported.

Getting Started

getting_started-1getting_started-1getting_started-1

1) Signup for a Free Trial
Visit https://www.tsheets.com/signup today and get started within minutes.

2) Obtain an Access Token
See the guided walkthrough to complete the simple steps. (See also Authentication)

3) Build your Integration
For the quickest start, try our Postman Collection along with the API Reference documentation.

4) Partner with Us!
We'd love to have a conversation with you and explore integration ideas for the mutual benefit of your business and TSheets. See our Partnership Page for details.

Postman Collection

The quickest way to get started is to use our Postman request collection. The following steps will help you get up and running. If you prefer, our API can also easily be explored with other tools, like cURL.

1) Open the TSheets Postman Collection

2) Configure the Postman Environment

3) Explore the API

Base URL

All URLs referenced in the documentation have the following base:

https://rest.tsheets.com/api/v1

Request Throttling

To prevent abuse of the TSheets API, we limit requests to a maximum of 300 calls within any 10 minute time window (subject to change). Rate limiting is primarily considered on a per-connection basis (per access token). If you exceed the current rate limit, you will receive a 429 'Too many requests' response from our API. You will continue to receive a 429 response until you're out of the current time window. The threshold and time window may adjust dynamically downward if you are found to be abusing the system.

Helper Libraries

ms.net-logophp

This documentation explains the format for calls to the TSheets API with code snippets in cURL and several other languages. Helper libraries are also available upon request to make it even easier for you to get started with TSheets.

While a helper library can make it easier to consume the API, it is certainly not necessary and the API is still very straight-forward to use even without one. Simply use a built-in http class or library for your language of choice.

Partnership Requests and Information

By default we allow you to connect to 3 additional client accounts (besides your own) via your API application keys. If you are building an integration and are interested in enabling your application for use by any TSheets customer, please fill out the form at the bottom of our partnerships page and we can help guide you through our simple integration process.

Here are a few of the things we'll be looking for before allowing your application access to our other TSheets customers:

Getting Help

If you encounter any problems consuming the API or have suggestions please feel free to contact us at help@tsheets.com

Authentication

OAuth2.0

TSheets uses OAuth2 for authentication and authorization of our API. OAuth2 is a protocol designed to let third-party applications authenticate to perform actions as a user, without getting the user's password. There are several libraries available that implement the protocol, and a good list can be found at the OAuth2 home page. Through the use of OAuth2, you'll go through the process of obtaining a token and then you'll use that token in every request made to the API to verify your identity.

Obtaining a Token

Before you can make any request of the API, you must first authenticate. Once you've authenticated, you will be given an access token that may be used for all subsequent requests.

Performing the OAuth2 token request flow requires an OAuth client ID and an OAuth client secret. To obtain these application credentials, you will need to install the API Add-On in your TSheets account and follow the instructions found there. The OAuth client secret should never be shared.

There are 2 steps required in order to obtain an access token, as follows:

Step 1. Authorization Request

This first step consists of a user authorizing your application to access their information on TSheets. To do this, you'll create a link somewhere on your site that they can use to initiate the process. The link will contain several parameters that are necessary for TSheets to consider it valid. The user should use a web browser to follow the link and perform the authorization request.

Once the user is directed to access the authorization endpoint at TSheets ('authorization server' in OAuth2-speak), two things will happen:

The link that a user will follow to perform an authorization request is made to the /authorize end-point:

Example: Authorization Request.

Request

curl "https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE" </span>
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder() .url("https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE") .get() .addHeader("Authorization", "Bearer <TOKEN>") .build();

Response response = client.newCall(request).execute();

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) { console.log(response); });

var request = require("request");

var options = { method: 'GET', url: 'https://rest.tsheets.com/api/v1/authorize', qs: { response_type: 'code', client_id: 'MYAPPCLIENTID', redirect_uri: 'https://somedomain.com/callback', state: 'MYSTATE', }, headers: { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) { if (error) throw new Error(error);

console.log(body); });

<?php

$request = new HttpRequest(); $request->setUrl('https://rest.tsheets.com/api/v1/authorize'); $request->setMethod(HTTP_METH_GET);

$request->setQueryData(array( 'response_type' => 'code', 'client_id' => 'MYAPPCLIENTID', 'redirect_uri' => 'https://somedomain.com/callback', 'state' => 'MYSTATE', ));

$request->setHeaders(array( 'Authorization' => 'Bearer <TOKEN>' ));

try { $response = $request->send();

echo $response->getBody(); } catch (HttpException $ex) { echo $ex; }

require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request) puts response.read_body

import requests

url = "https://rest.tsheets.com/api/v1/authorize"

querystring = { "response_type":"code", "client_id":"MYAPPCLIENTID", "redirect_uri":"https://somedomain.com/callback", "state":"MYSTATE", }

payload = "" headers = { 'Authorization': "Bearer <TOKEN>" }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)

package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <TOKEN>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body)) }

import Foundation

let headers = [ "Authorization": "Bearer <TOKEN>", "cache-control": "no-cache" ]

let request = NSMutableURLRequest( url: NSURL(string: "https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)

request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask( with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } } )

dataTask.resume()

use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>'); $client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE";

$client->GET($url); print $client->responseContent(); print $client->responseHeader('ResponseHeader');

HTTP Request

gethttps://rest.tsheets.com/api/v1/authorize

Parameters

response_type
required
String This parameter MUST always be set to the string 'code'.
client_id
required
String This parameter MUST always be set to the value of the OAuth client ID that you obtained when you registered your app in the TSheets API Add-On in your TSheets account.
redirect_uri
required
String The HTTPS url that you submitted as the 'OAuth Redirect URI' when you set up your app in the TSheets API Add-On. If the user grants access to your application, we'll redirect them back to this url with a temporary code in a code parameter. They'll use this code to obtain an access token.
state
required
String A random value used by the client to maintain state between the request and callback. The authorization server includes this value when redirecting the user-agent back to the client. It is used to protect against cross-site request forgery attacks. If the states don't match, the request has been created by a third party and the process should be aborted.
display_mode
optional
String Optional. Can be 'create' or 'login'. Default is 'login'. If 'login', the form for logging into an existing TSheets account is displayed first. If 'create', the form for creating a new TSheets account is shown first.

Upon successful authorization and if the user grants access for their data to the app, TSheets will redirect the connected user to the redirect_uri (https://somedomain.com/callback in this example) found in the original request, and two parameters will be appended to it:

1) code - the unique code generated for this request - to be used in the token call later in the flow.
2) state - the value passed in 'state' in the original authorization request.

For example:

https://somedomain.com/callback?code=bbcaef03191517dfb60d0305bfea38ea995af1az&state=MYSTATE

The server that handles the request to https://somedomain.com/callback should extract and save the code parameter value, as it is required as part of the next step in the flow. The state value should be compared to what was originally sent and verified to be the same.

If the call to the /authorize end-point is malformed, or if the user denies access to the requesting app, then TSheets will still redirect the user back to the redirect_uri, but instead it will append error and error_description parameters. For example:

https://somedomain.com/callback?error=SOME_ERROR&error_description=SOME_DESCRIPTION

Step 2. Access Token Request

At this point you have an authorization 'code' for the user of your app. To exchange the code for an access token, your application needs to do a POST to our /grant API end-point. In this step, TSheets will check that the authorization code was issued to the same application that is making the token request.

The access_token should be included with every call to the API. Failure to include the access token or using an expired token will result in a 401 response. Note that when you receive your access token, you also receive the user_id and client_id properties that are associated with the user that the access token is for. These properties are provided for convenience, to potentially save you the need for making a request to the current user endpoint.

If the client has IP Authorization security enabled with the block all access option turned on, the request could fail with a 499 status code if it comes from an unauthorized IP address. All subsequent requests will also fail until the device switches to an authorized IP address.

grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback

Example: Access Token Request.

Request

curl -X POST \
  https://rest.tsheets.com/api/v1/grant \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback'
var client = new RestClient("https://rest.tsheets.com/api/v1/grant");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <TOKEN>");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/grant")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/x-www-form-urlencoded")
request.AddParameter("application/x-www-form-urlencoded", "grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/grant")
  .post(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/authorize?response_type=code&client_id=MYAPPCLIENTID&redirect_uri=https://somedomain.com/callback&state=MYSTATE",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "Content-Type": "application/x-www-form-urlencoded",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": {
    "grant_type": "authorization_code",
    "client_id": "MYAPPCLIENTID",
    "client_secret": "MYAPPSECRET",
    "code": "bbcaef03191517dfb60d0305bfea38ea995af1az",
    "redirect_uri": "https%3A%2F%2Fsomedomain.com%2Fcallback"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'POST',
  url: 'https://rest.tsheets.com/api/v1/grant',
  headers: 
   { 'Content-Type': 'application/x-www-form-urlencoded',
     'Authorization': 'Bearer <TOKEN>' },
  form:
   {
      grant_type: 'authorization_code',
      client_id: 'MYAPPCLIENTID',
      client_secret: 'MYAPPSECRET',
      code: 'bbcaef03191517dfb60d0305bfea38ea995af1az',
      redirect_uri: 'https%3A%2F%2Fsomedomain.com%2Fcallback' }
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/grant');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Content-Type' => 'application/x-www-form-urlencoded',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields(array(
  'grant_type' => 'authorization_code',
  'client_id' => 'MYAPPCLIENTID',
  'client_secret' => 'MYAPPSECRET',
  'code' => 'bbcaef03191517dfb60d0305bfea38ea995af1az',
  'redirect_uri' => 'https%3A%2F%2Fsomedomain.com%2Fcallback'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/grant")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/grant"

payload = "grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/x-www-form-urlencoded"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/grant"

  payload := strings.NewReader("grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/x-www-form-urlencoded",
  "cache-control": "no-cache"
]

let postData = NSMutableData(data: "grant_type=authorization_code".data(using: STring.Encoding.utf8)!)
postData.append("&client_id=MYAPPCLIENTID".data(using: String.Encoding.utf8)!)  
postData.append("&client_secret=MYAPPSECRET".data(using: String.Encoding.utf8)!)  
postData.append("&code=bbcaef03191517dfb60d0305bfea38ea995af1az".data(using: String.Encoding.utf8)!)  
postData.append("&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback".data(using: String.Encoding.utf8)!)  

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/grant")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/x-www-form-urlencoded');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = 'grant_type=authorization_code&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&code=bbcaef03191517dfb60d0305bfea38ea995af1az&redirect_uri=https%3A%2F%2Fsomedomain.com%2Fcallback';

$url="http://rest.tsheets.com/api/v1/grant"; 

$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "access_token":"84ec7a2f2b1379990caea347d67e713f34f2d5dz",
  "expires_in":5184000,
  "token_type":"bearer",
  "scope":"",
  "refresh_token":"0ed645dbcfaca681e37df26df6f39d273330e7a0",
  "user_id":"12345",
  "company_id":"12345",
  "client_url":"blakemoving"
}

HTTP Request

posthttps://rest.tsheets.com/api/v1/grant

Parameters

grant_type
required
String This parameter MUST always be set to the string 'authorization_code'. This tells us what type of code is included.
client_id
required
String This parameter MUST always be set to the value of the OAuth client ID that you obtained when you set up your app in the API Add-On in your TSheets account.
client_secret
required
String This parameter MUST always be set to the value of the OAuth client secret that you obtained when you set up your app in the API Add-On in your TSheets account.
code
required
String The 'code' being exchanged for an access token. This should be the authorization code received above.
redirect_uri
required
String The HTTPS url that was included in Step 1 of the authorization request. The value must be identical.

Make Requests With the Access Token

Example: Making a request with an access token.

Request

curl "https://rest.tsheets.com/api/v1/users?per_page=1" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/users?per_page=1");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/users?per_page=1")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/users?per_page=1")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/users?per_page=1",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/users',
  qs: {
    per_page: '1',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/users');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'per_page' => '1',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/users?per_page=1")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/users"

querystring = {
  "per_page":"1",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/users?per_page=1"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/users?per_page=1")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/users?per_page=1"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Once you have an OAuth access token, you can use it to make API requests. Use the HTTP Authorization header when making a request.

Storing a Token

When appropriate, applications should store the token locally, rather than requesting a new token for the same user each time the user uses the application. If the token is deleted or expires, the application will get a 401 Unauthorized error from the API, in which case the application should perform the OAuth flow again to receive a new token. Storing a token is in many ways equivalent to storing the user's password, so tokens should be stored and used in a secure manner.

Refreshing an Access Token

Access tokens expire after expires_in seconds (see example response). In order to avoid sending the user through the OAuth2 process described above every time they want to access resources, API consumers can exchange a refresh_token for a new access_token before the current one expires. To do so, you make a request similar to the original request described above.

grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0

Example: Refresh Token Request.

Request

curl -X POST \
  https://rest.tsheets.com/api/v1/grant \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0'
var client = new RestClient("https://rest.tsheets.com/api/v1/grant");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <TOKEN>");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/grant")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/x-www-form-urlencoded")
request.AddParameter("application/x-www-form-urlencoded", "grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/grant")
  .post(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/users?per_page=1",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "Content-Type": "application/x-www-form-urlencoded",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": {
    "grant_type": "refresh_token",
    "client_id": "MYAPPCLIENTID",
    "client_secret": "MYAPPSECRET",
    "refresh_token": "0ed645dbcfaca681e37df26df6f39d273330e7a0"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'POST',
  url: 'https://rest.tsheets.com/api/v1/grant',
  headers: 
   { 'Content-Type': 'application/x-www-form-urlencoded',
     'Authorization': 'Bearer <TOKEN>' },
  form:
   {
      grant_type: 'refresh_token',
      client_id: 'MYAPPCLIENTID',
      client_secret: 'MYAPPSECRET',
      refresh_token: '0ed645dbcfaca681e37df26df6f39d273330e7a0' }
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/grant');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Content-Type' => 'application/x-www-form-urlencoded',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields(array(
  'grant_type' => 'refresh_token',
  'client_id' => 'MYAPPCLIENTID',
  'client_secret' => 'MYAPPSECRET',
  'refresh_token' => '0ed645dbcfaca681e37df26df6f39d273330e7a0'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/grant")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/grant"

payload = "grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/x-www-form-urlencoded"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/grant"

  payload := strings.NewReader("grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/x-www-form-urlencoded",
  "cache-control": "no-cache"
]

let postData = NSMutableData(data: "grant_type=refresh_token".data(using: STring.Encoding.utf8)!)
postData.append("&client_id=MYAPPCLIENTID".data(using: String.Encoding.utf8)!)  
postData.append("&client_secret=MYAPPSECRET".data(using: String.Encoding.utf8)!)  
postData.append("&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0".data(using: String.Encoding.utf8)!)  

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/grant")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/x-www-form-urlencoded');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = 'grant_type=refresh_token&client_id=MYAPPCLIENTID&client_secret=MYAPPSECRET&refresh_token=0ed645dbcfaca681e37df26df6f39d273330e7a0';

$url="http://rest.tsheets.com/api/v1/grant"; 

$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "access_token":"c65931f72f0a905bea92fb2dce8e4c25151c02e9",
  "expires_in":5184000,
  "token_type":"bearer",
  "scope":"",
  "refresh_token":"9eaec192df27b22e6575e438a4159639937605c7",
  "user_id":"12345",
  "company_id":"12345",
  "client_url":"blakemoving"
}

HTTP Request

posthttps://rest.tsheets.com/api/v1/grant

Parameters

grant_type
required
String This parameter MUST be set to the string 'refresh_token'.
client_id
required
String This parameter MUST always be set to the value of the OAuth client ID that you obtained when you set up your app in the API Add-On in your TSheets account.
client_secret
required
String This parameter MUST always be set to the value of the OAuth client secret that you obtained when you set up your app in the API Add-On in your TSheets account.
refresh_token
required
String This parameter is the refresh_token that you're exchanging for a new access_token.

Request Formats

Retrieve resources with the HTTP GET Method

Example: Retrieving a resource.

Request

curl "https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/users',
  qs: {
    per_page: '5',
    usernames: 'frank,fred',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/users');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'per_page' => '5',
  'usernames' => 'frank,fred',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/users"

querystring = {
  "per_page":"5",
  "usernames":"frank,fred",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

You retrieve a representation of an object by sending an HTTP GET action to the resource's endpoint url. Filters can be specified for the request using a query string following the endpoint url. For example, you could GET a list of users, showing 5 per page and having the username 'frank' or 'fred' with the following:

Create new resources with the HTTP POST Method

Example: Creating a new resource.

Request

curl -X POST \
  https://rest.tsheets.com/api/v1/users \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '<REQUEST BODY>'
var client = new RestClient("https://rest.tsheets.com/api/v1/users");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <TOKEN>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/users")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/users")
  .post(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "<REQUEST BODY>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'POST',
  url: 'https://rest.tsheets.com/api/v1/users',
  headers: 
   { 'Content-Type': 'application/json',
     'Authorization': 'Bearer <TOKEN>' },
  body: '<REQUEST BODY>',
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/users');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setBody('<REQUEST BODY>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/users")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/json'
request.body = "<REQUEST BODY>"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/users"

payload = "<REQUEST BODY>"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/users"

  payload := strings.NewReader("<REQUEST BODY>")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/json",
  "cache-control": "no-cache"
]
let parameters = <REQUEST BODY> as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/users")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = '<REQUEST BODY>';

$url="http://rest.tsheets.com/api/v1/users"; 

$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

You can add a new object by sending an HTTP POST action to the resource's endpoint url. You must include a JSON representation of the object in your POST body, and the Content-Type: application/json header must be set in your request.

Update existing resources with the HTTP PUT Method

Example: Updating a resource.

Request

curl -X PUT \
  https://rest.tsheets.com/api/v1/users \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '<REQUEST BODY>'
var client = new RestClient("https://rest.tsheets.com/api/v1/users");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/users")
Dim request = New RestRequest(Method.PUT)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/json")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/users")
  .put(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/users?per_page=5&usernames=frank,fred",
  "method": "PUT",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "<REQUEST BODY>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'PUT',
  url: 'https://rest.tsheets.com/api/v1/users',
  headers: 
   { 'Content-Type': 'application/json',
     Authorization: 'Bearer <TOKEN>' },
  body: '<REQUEST BODY>',
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/users');
$request->setMethod(HTTP_METH_PUT);

$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setBody('<REQUEST BODY>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/users")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/json'
request.body = "<REQUEST BODY>"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/users"

payload = "<REQUEST BODY>"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/json"
    }

response = requests.request("PUT", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/users"

  payload := strings.NewReader("<REQUEST BODY>")

  req, _ := http.NewRequest("PUT", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/json",
  "cache-control": "no-cache"
]
let parameters = <REQUEST BODY> as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/users")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = '<REQUEST BODY>';

$url="http://rest.tsheets.com/api/v1/users"; 

$client->PUT($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

You can edit an existing object by sending an HTTP PUT action to the resource's endpoint url. You must include a JSON representation of the object's modified properties in your PUT body, and the Content-Type: application/json header must be set in your request. For example, you could PUT changes using the user's unique id and the properties and values that you would like changed:

Delete resources with the HTTP DELETE Method

Example: Deleting resources.

Request

curl -X DELETE "https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078"
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078")
Dim request = New RestRequest(Method.[DELETE])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078")
  .delete()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078",
  "method": "DELETE",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'DELETE',
  url: 'https://rest.tsheets.com/api/v1/jobcode_assignments',
  qs: {
    ids: '56788,58078',
  },
  headers: 
   { Authorization: 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/jobcode_assignments');
$request->setMethod(HTTP_METH_DELETE);

$request->setQueryData(array(
  'ids' => '56788,58078',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/jobcode_assignments"

querystring = {
  "ids":"56788,58078",
}

payload = ""
headers = {
    'Authorization': "Bearer <TOKEN>"
    }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078"

  req, _ := http.NewRequest("DELETE", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/jobcode_assignments?ids=56788,58078"; 

$client->DELETE($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

You can delete an existing object by sending an HTTP DELETE action to the resource's endpoint url. An HTTP DELETE is similar to a GET, where all relevant parameters are passed as part of a query string. You must include an identifying id of some sort for the object you would like to delete as part of your parameters.

Note: Some endpoints which do not support DELETE instead allow items to be "archived" (aka soft deleted). For example, you can make a PUT call with active=false to the Users endpoint to remove a user.

Possible Response Status Codes

2xx response codes

All 2xx response codes indicate success for the action requested. Following are the most common 2xx response codes:

200 OK The request was successful and the response body contains the response for the action requested. Usually comes in response to a GET request.
201 Created The request was successful and the response body contains the response for the action requested. A 201 indicates that changes may have been made on the server side to the object when the request was handled (e.g. a timesheet was split due to break settings). The caller should check the supplemental_data of the response to process any related changes. Usually comes in response to a POST (create) or PUT (update) request.
202 Accepted The request was successful and the response body contains the response for the action requested. A 202 indicates that the details of the create request match an already existing, active object. Rather than create a duplicate object, a 202 is returned along with the id of the original object. Usually comes in response to a POST (create) request.

3xx response codes

All 3xx response codes indicate that you need to look elsewhere for your result. The response body will contain directions on where you should be redirected to.

4xx response codes

All 4xx response codes indicate failure for the action requested. Following are the most common 4xx response codes:

400 Bad Request There was something wrong with your request.
401 Unauthorized You don't have sufficient permission to perform the action you requested.
402 Billing not current Your account billing is not current, so access was denied.
405 Method Not Allowed The action you are trying to perform is not allowed.
406 Not Acceptable The data you have tried to create conflicts with existing data.
409 Conflict The data you have tried to modify conflicts with existing data.
413 Max Items Exceeded The number of objects you are listing or editing or adding is too large.
417 Expectation Failed Your request was missing required parameters or your request was somehow otherwise malformed.
429 Too Many Requests You have sent too many requests to the API in too short a time. You'll have to try your requests again later.

5xx response codes

All 5xx response codes indicate a server error or exceptional condition on the TSheets side. Following are the most common 5xx response codes:

500 Internal Server Error There was an unspecified error on the TSheets side. Try your request again in a moment; if you receive the same error then wait a few minutes before repeating it, as we are probably working to correct it. If you continue to receive the error after several hours, contact us to report a bug.
501 Method not implemented This method is not implemented for this object. It may be in the future.
503 (Various messages) A 503 response code indicates that the service is temporarily unavailable. Wait a few minutes for the condition to clear, and try again.

Response Formats

Example

{
 "results": {
  "users": {
   "1283037": {
    "id": 1283037,
    "first_name": "Joni",
    "last_name": "Smith",
    "group_id": 0,
    "active": true,
    "employee_number": 0,
    "salaried": false,
    "exempt": false,
    "username": "joni",
    "email": "",
    "payroll_id": "",
    "hire_date": "0000-00-00",
    "term_date": "0000-00-00",
    "job_title": "",
    "gender": "",
    "last_modified": "2018-07-12T17:24:33+00:00",
    "last_active": "",
    "created": "2018-07-12T17:24:33+00:00",
    "mobile_number": "",
    "permissions": {
     "admin": false,
     "mobile": false,
     "status_box": false,
     "reports": false,
     "manage_timesheets": false,
     "manage_authorization": false,
     "manage_users": false,
     "manage_my_timesheets": false,
     "manage_jobcodes": false,
     "approve_timesheets": false,
     "manage_no_schedules": false,
     "manage_my_schedule": false,
     "manage_schedules": false,
     "manage_company_schedules": false,
     "view_my_schedules": false,
     "view_group_schedules": false,
     "view_company_schedules": false
    }
   }
  }
 },
 "more": false,
 "supplemental_data": {
  "groups": {
   "144959": {
    "id": 144959,
    "name": "test3",
    "last_modified": "2018-07-12T15:32:25+00:00",
    "created": "2018-07-12T15:32:25+00:00"
   },
  }
 }
}

TSheets returns resource representations as JSON, unless an exception occurs. Each JSON response object will contain the response data underneath an object property labeled 'results'.

For GET requests, in the response body there will also be a boolean with the name, "more". If true, it means that there is another page of objects that can be retrieved. Otherwise false will be the value.

If the resource object references any other objects via an id (i.e. group_id), a corresponding JSON representation of that object will be contained in another top level property labeled supplemental_data.

Exceptions

TSheets returns exceptions in the HTTP response body when something goes wrong. An exception has the following properties:

Property Description
code The HTTP status code for the exception.
message A descriptive message regarding the exception.

Tips & Suggestions

Requesting items that have changed since you last made a request to the API

When you are looking to see whether any items have changed since your last request, it is best to query the last_modified_timestamps API endpoint. This will allow you to easily make a single API query and see the most recent time any object from an endpoint was modified.

When you determine that you need to query an endpoint, use the modified_since parameter to get only those items that have been modified since the last time you made a request.

Working with Jobcodes & Jobcode Assignments

When working with Jobcodes it is highly recommended to use the Jobcode Assignments endpoint whenever possible in order to limit the number of jobcodes returned from a request. This becomes very important when dealing with TSheets accounts connected with external services such as Quickbooks since it is likely that the account will have a large number of Jobcodes.

Archiving objects no longer in use

To keep your account running as efficiently as possible, it is a good idea to archive certain objects once you are done with them. You can archive Users, Jobcodes, and Customfielditems when they're no longer actively being used. You do this by setting their active field to false. All of these items are still represented in reports, even though they're archived.

You cannot archive timesheets. If you delete a timesheet, it is permanently removed. To retain the ability to perform historical reporting on time, we recommend that you do not delete timesheets, unless it's for the purpose of correcting an inaccuracy.

Handling Supplemental Timesheet Data

Example: Suppemental Data.

Request

curl "https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/timesheets',
  qs: {
    start_date: '12-05-2017',
    modified_since: '12-05-2018',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/timesheets');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'start_date' => '12-05-2017',
  'modified_since' => '12-05-2018',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/timesheets"

querystring = {
  "start_date":"12-05-2017",
  "modified_since":"12-05-2018",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/timesheets?start_date=12-05-2017&modified_since=12-05-2018"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "timesheets": {
      "142835829": {
        "id": 142835829,
        "user_id": 1396641,
        "jobcode_id": 20355120,
        "start": "2018-07-23T10:00:00-07:00",
        "end": "2018-07-23T13:10:23-07:00",
        "duration": 11423,
        "date": "2018-07-23",
        "tz": -7,
        "tz_str": "",
        "type": "regular",
        "location": "TSheets API Tester",
        "active": "0",
        "locked": 0,
        "notes": "This is a test of the emergency broadcast system",
        "customfields": {
          "24068": "",
          "24066": ""
        },
        "last_modified": "2018-12-13T22:52:08+00:00"
      },
      "142835831": {
        "id": 142835831,
        "user_id": 1396641,
        "jobcode_id": 20347779,
        "start": "2018-07-25T09:30:00-07:00",
        "end": "2018-07-25T13:10:23-07:00",
        "duration": 13223,
        "date": "2018-07-25",
        "tz": -7,
        "tz_str": "",
        "type": "regular",
        "location": "TSheets API Tester",
        "active": "0",
        "locked": 0,
        "notes": "This is a test",
        "customfields": {
          "24068": "",
          "24066": ""
        },
        "last_modified": "2018-12-13T20:30:42+00:00"
      }
    }
  },
  "more": false,
  "supplemental_data": {
    "jobcodes": {
      "20355120": {
        "id": 20355120,
        "parent_id": 0,
        "assigned_to_all": true,
        "billable": false,
        "active": true,
        "type": "regular",
        "has_children": false,
        "billable_rate": 0,
        "short_code": "",
        "name": "Another Jobcode",
        "last_modified": "2018-12-13T22:16:18+00:00",
        "created": "2018-12-13T22:16:18+00:00",
        "required_customfields": [ ],
        "filtered_customfielditems": ""
      },
      "20347779": {
        "id": 20347779,
        "parent_id": 0,
        "assigned_to_all": true,
        "billable": false,
        "active": true,
        "type": "regular",
        "has_children": false,
        "billable_rate": 0,
        "short_code": "",
        "name": "Global Jobcode",
        "last_modified": "2018-12-12T23:53:31+00:00",
        "created": "2018-12-12T23:53:31+00:00",
        "required_customfields": [ ],
        "filtered_customfielditems": ""
      }
    },
    "users": {
      "1396641": {
        "id": 1396641,
        "first_name": "API",
        "last_name": "Employee",
        "group_id": 0,
        "active": true,
        "employee_number": 0,
        "salaried": false,
        "exempt": false,
        "username": "apiemployee",
        "email": "",
        "payroll_id": "",
        "hire_date": "0000-00-00",
        "term_date": "0000-00-00",
        "last_modified": "2018-12-12T18:58:13+00:00",
        "last_active": "2018-12-13T22:52:08+00:00",
        "created": "2018-12-12T18:58:13+00:00",
        "client_url": "tsheetsapitester",
        "mobile_number": "",
        "approved_to": "",
        "submitted_to": ""
      }
    },
    "customfields": {
      "24068": {
        "id": 24068,
        "required": false,
        "applies_to": "timesheet",
        "type": "free-form",
        "short_code": "ffcf1",
        "regex_filter": "",
        "name": "Free-form Custom Field 1",
        "last_modified": "2018-12-13T18:18:57+00:00",
        "created": "2018-12-13T18:18:57+00:00",
        "ui_preference": "text_box_with_suggest",
        "required_customfields": [ ]
      },
      "24066": {
        "id": 24066,
        "required": false,
        "applies_to": "timesheet",
        "type": "managed-list",
        "short_code": "mlcf1",
        "regex_filter": "",
        "name": "Managed List Custom Field 1",
        "last_modified": "2018-12-13T18:18:36+00:00",
        "created": "2018-12-13T18:18:36+00:00",
        "ui_preference": "drop_down",
        "required_customfields": [ ]
      }
    }
  }
}

When fetching timesheets via TSheets, supplemental data that is pertinent to the timesheets returned will be sent back in a supplemental_data JSON object unless you exclude it with an API filter. Within this object you will find additional objects related to the timesheets that were returned in the result set. In the example, Jobcode, User, and Custom Field objects are returned if they are referenced in the timesheet results. This is done specifically to esure that API consumers have all the necessary data to display any timesheets that are returned. Knowing this, it is a best practice for API consumers to always parse and store any supplemental data should they wish to persist and display these timesheets later (for offline viewing, etc).

You can exclude supplemental data from GET requests for the timesheets and other endpoints by including the parameter supplemental_data with a value of "no". If your application will not be using the supplemental data from a given request, you can include this parameter to reduce payload size and improve the response time.

Recipes for Some Common Workflows

Getting current status of a single user (whether on or off the clock)

Query the timesheets endpoint for the given user with active status = true over the last 7 days.

/timesheets?user_ids=[USER_ID]&on_the_clock=yes&start_date=[7_DAYS_AGO]

This works because:

Getting current status and totals of all users (or one) in compact format

Query the /reports endpoint for the 'current_totals' report (this is what fuels our "who's working" window in the web dashboard). This will get you a tally of time for the day and the current task and whether or not each user is on the clock at the moment.

Approving time

A user may submit their time (if configured to allow it), while managers and admins may approve time. PUT to the Users endpoint, modifying the submitted_to and/or approved_to properties.

Running Payroll

If you have the Approvals Add-On installed, then each user will have a submitted_to and approved_to property. When you query the /reports endpoint for a payroll report - entries will reference a user_id which will correspond to an entry in the supplemental_data portion of the response. You can check the approved_to property of each user via the supplemental_data in the response.

We recommend that you do one of two things:

1) Only use payroll entries where the user's time has been approved.

OR

2) Use all payroll entries, but somehow distinguish (in the UI) between those who are approved versus those who are not.

Walkthroughs

Obtaining an API Access Token

This walkthrough will guide you through the process of creating an API App in TSheets and obtaining an API Access Token for use as the OAuth2 Bearer Token value in the Authentication header that is required when making a call to any of the API methods.

1) Install the API App Feature Add-On

Log into your TSheets Account and select the Feature Add-ons...Manage Add-ons... menu from the left navigation pane (actual menu layout may differ.)


2) Select the API Add-On and click Install

Afterwards, the API Add-On will be available from the Feature Add-ons section of the left navigation pane.


3) Add a New Application

Select Add a new application at bottom left. If the following window is not displayed, you can select API from Feature Add-ons on the left navigation pane.


4) Enter API Application Details

Add a short name and a meaningful description. For now, just use a dummy value for the Redirect URI. It can be edited later.


5) Create a New Token

Almost there! Click Add Token at bottom left. This step will generate a token for immediate use.


6) Capture the New Token Value for Use with the API

Copy the token value for use with API method calls, and be sure to Save before exiting. Congratulations! You may now explore the API with ease, fully authenticated.

End of Walkthrough.

Current User

The Current User Object

An instance of the User Object, but for the user associated with the current access token.

Retrieve the Current User

Example: Retrieve current user.

Request

curl "https://rest.tsheets.com/api/v1/current_user" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/current_user");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/current_user")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/current_user")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/current_user",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/current_user',
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/current_user');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/current_user")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/current_user"

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/current_user"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/current_user")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/current_user"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "users": {
      "933849": {
        "id": 933849,
        "first_name": "Mary",
        "last_name": "Samsonite",
        "group_id": 0,
        "active": true,
        "employee_number": 0,
        "salaried": false,
        "exempt": false,
        "username": "admin",
        "email": "admin@example.com",
        "email_verified": false,
        "payroll_id": "",
        "mobile_number": "2087231456",
        "hire_date": "0000-00-00",
        "term_date": "0000-00-00",
        "last_modified": "2018-03-28T17:24:20+00:00",
        "last_active": "",
        "created": "2018-03-27T16:13:34+00:00",
        "client_url": "api_sample_output",
        "company_name": "API Sample Output Company",
        "profile_image_url": "https:\/\/www.gravatar.com\/avatar\/e64c7d89f26bd1972efa854d13d7dd61",
        "pto_balances": {
          "2624351": 0,
          "2624353": 0,
          "2624355": 0
        },
        "submitted_to": "2000-01-01",
        "approved_to": "2000-01-01",
        "manager_of_group_ids": [ ],
        "require_password_change": false,
        "pay_rate": 0,
        "pay_interval": "hour",
        "permissions": {
          "admin": true,
          "mobile": true,
          "status_box": false,
          "reports": false,
          "manage_timesheets": false,
          "manage_authorization": false,
          "manage_users": false,
          "manage_my_timesheets": false,
          "manage_jobcodes": false,
          "pin_login": false,
          "approve_timesheets": false,
          "manage_schedules": false,
          "external_access": false,
          "manage_my_schedule": false,
          "manage_company_schedules": false,
          "view_company_schedules": false,
          "view_group_schedules": false,
          "manage_no_schedules": false,
          "view_my_schedules": false
        },
        "customfields": ""
      }
    }
  },
  "more": false,
  "supplemental_data": {
    "jobcodes": {
      "2624351": {
        "id": 2624351,
        "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": "2018-03-27T16:13:28+00:00",
        "created": "2018-03-27T16:13:28+00:00",
        "filtered_customfielditems": "",
        "required_customfields": [ ],
        "locations": [ ]
      },
      "2624353": {
        "id": 2624353,
        "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": "2018-03-27T16:13:28+00:00",
        "created": "2018-03-27T16:13:28+00:00",
        "filtered_customfielditems": "",
        "required_customfields": [ ],
        "locations": [ ]
      },
      "2624355": {
        "id": 2624355,
        "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": "2018-03-27T16:13:28+00:00",
        "created": "2018-03-27T16:13:28+00:00",
        "filtered_customfielditems": "",
        "required_customfields": [ ],
        "locations": [ ]
      }
    }
  }
}

Retrieves the user object for the currently authenticated user. This is the user that authenticated to TSheets during the OAuth2 authentication process.

HTTP Request

gethttps://rest.tsheets.com/api/v1/current_user

Parameters

None

Custom Fields

Custom Fields (aka "Advanced Tracking") provides a means to extend the data that is tracked on employee time cards to capture custom activities beyond time tracking, e.g. mileage, equipment, expenses, etc. The API provides a Read method. Use the web UI to Create or Update custom fields.

The Custom Field Object

Example

{
  "id": 134913,
  "active": true,
  "required": true,
  "applies_to": "timesheet",
  "type": "managed-list",
  "short_code": "Exp",
  "regex_filter": "",
  "name": "Experience",
  "last_modified": "2019-02-10T20:40:41+00:00",
  "created": "2019-02-03T18:36:16+00:00",
  "ui_preference": "drop_down",
  "required_customfields": []
}

Following is a list of the properties that belong to a customfield object, and a description of each.

id
read-only
Int Id of customfield.
active
read-only
Boolean true or false. If true, this custom field is active. If false, this custom field is archived.
name
read-only
String Name of the customfield.
short_code
read-only
String This is a shortened code or alias that is associated with the customfield. It may only consist of letters and numbers.
required
read-only
Boolean true or false. Indicates whether a value for this customfield is required on a timesheet
applies_to
read-only
String 'timesheet' or 'user' or 'jobcode'. Indicates what type of object this customfield applies to.
type
read-only
String 'managed-list' or 'free-form'. If 'free-form', then it should be displayed in a UI as a text box, where users can enter values for this customfield and they'll get added automatically to the customfield if they don't already exist. If 'managed-list', then it should be displayed as a select-box and users can only choose an existing value.
ui_preference
read-only
String 'drop_down' or 'text_box_with_suggest'. Indicates the suggested user interface depending on the specified type.
regex_filter
read-only
String Regular expression that will be applied to any new items as they're added to the customfield. If they do not match the regex_filter, they may not be added.
last_modified
read-only
String Date/time when this customfield was last modified, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
created
read-only
String Date/time when this customfield was created, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
required_customfields
read-only
Array Ids of customfields that should be displayed when this customfield is visible on a timecard

Retrieve Custom Fields

Example: Retrieve a list of all customfields.

Request

curl "https://rest.tsheets.com/api/v1/customfields" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/customfields");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfields")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfields")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfields",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/customfields',
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfields');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfields")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfields"

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfields"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/customfields")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/customfields"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Example: Retrieve a list of customfields with a given id.

Request

curl "https://rest.tsheets.com/api/v1/customfields?ids=195923" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/customfields?ids=195923");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfields?ids=195923")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfields?ids=195923")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfields?ids=195923",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/customfields',
  qs: {
    ids: '195923',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfields');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'ids' => '195923',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfields?ids=195923")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfields"

querystring = {
  "ids":"195923",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfields?ids=195923"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/customfields?ids=195923")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/customfields?ids=195923"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Example: Retrieve a list of customfields that have been modified since a given date.

Request

curl "https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/customfields',
  qs: {
    modified_since: '2018-01-01T00:00:00%2B00:00',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfields');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'modified_since' => '2018-01-01T00:00:00%2B00:00',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfields"

querystring = {
  "modified_since":"2018-01-01T00:00:00%2B00:00",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/customfields?modified_since=2018-01-01T00:00:00%2B00:00"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "customfields": {
      "195923": {
        "id": 195923,
        "active": true,
        "required": true,
        "applies_to": "timesheet",
        "type": "managed-list",
        "short_code": "e",
        "regex_filter": "",
        "name": "Equipment",
        "last_modified": "2018-04-04T15:37:30+00:00",
        "created": "2018-03-27T16:13:35+00:00",
        "ui_preference": "drop_down",
        "required_customfields": [

        ]
      },
      "195921": {
        "id": 195921,
        "active": true,
        "required": false,
        "applies_to": "timesheet",
        "type": "free-form",
        "short_code": "m",
        "regex_filter": "",
        "name": "Mood",
        "last_modified": "2018-03-27T16:13:35+00:00",
        "created": "2018-03-27T16:13:35+00:00",
        "ui_preference": "text_box_with_suggest",
        "required_customfields": [

        ]
      },
      "195919": {
        "id": 195919,
        "active": true,
        "required": false,
        "applies_to": "timesheet",
        "type": "managed-list",
        "short_code": "w",
        "regex_filter": "",
        "name": "Work Type",
        "last_modified": "2018-03-27T16:13:35+00:00",
        "created": "2018-03-27T16:13:35+00:00",
        "ui_preference": "drop_down",
        "required_customfields": [

        ]
      }
    }
  },
  "more": false
}

Retrieves a list of all customfields associated with your company, with optional filters to narrow down the results.

HTTP Request

gethttps://rest.tsheets.com/api/v1/customfields

Filter Parameters

ids
optional
Int Comma separated list of one or more customfield ids you'd like to filter on. Only customfields with an id set to one of these values will be returned. If omitted, all customfields matching other specified filters are returned.
active
optional
String 'yes', 'no', or 'both'. Default is 'yes'.
applies_to
optional
String 'timesheet', 'user', 'jobcode', or 'all'. Default is 'timesheet'.
value_type
optional
String 'managed-list', 'free-form', or 'both'. Default is 'both'.
modified_before
optional
String Only customfields modified before this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
modified_since
optional
String Only customfields modified since this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
supplemental_data
optional
String 'yes' or 'no'. Default is 'yes'. Indicates whether supplemental data should be returned.
per_page
optional
Int Represents how many results you'd like to retrieve per request (page). Default is 50. Max is 50.
page
optional
Int Represents the page of results you'd like to retrieve. Default is 1.

Custom Field Items

A Custom Field Item represents an allowable value for a Custom Field Object of managed-list type. Each item represents a single drop-down choice displayed to the user in the web UI. The API provides methods to Create, Read, and Update custom field items. Set the active property false to archive (i.e. soft delete) a custom field item.

The Custom Field Item Object

Example

{
  "id": 3875655,
  "customfield_id": 143369,
  "active": true,
  "short_code": "JS",
  "name": "Jungle Safari",
  "last_modified": "2019-02-11T17:42:45+00:00",
  "required_customfields": []
}

Following is a list of the properties that belong to a customfield object, and a description of each.

id
read-only
Int Id of customfielditem.
customfield_id
read-only
Int Id for the customfield that this item belongs to.
name
read-write
String Name of the customfielditem.
short_code
read-write
String This is a short alias that is associated with the customfielditem. It may only consist of letters and numbers. Note: Custom Field Item short_code values must be unique for each TSheets account.
active
read-write
Boolean true or false. If false, the customfielditem is considered archived.
last_modified
read-only
String Date/time when this customfielditem was last modified, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
created
read-only
String Date/time when this customfielditem was created, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
required_customfields
read-only
Int[] Ids of customfields that should be displayed when this customfielditem is selected on a timecard.

Retrieve Custom Field Items

Example: Retrieve a list of all active customfielditems belonging to the given customfield.

Request

curl "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/customfielditems',
  qs: {
    customfield_id: '195923',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfielditems');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'customfield_id' => '195923',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfielditems"

querystring = {
  "customfield_id":"195923",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Example: Retrieve a list of all customfielditems (active or deleted) belonging to the given customfield, and set pagination to 10 results/page.

Request

curl "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/customfielditems',
  qs: {
    customfield_id: '195923',
    per_page: '10',
    active: 'both',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfielditems');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'customfield_id' => '195923',
  'per_page' => '10',
  'active' => 'both',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfielditems"

querystring = {
  "customfield_id":"195923",
  "per_page":"10",
  "active":"both",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&per_page=10&active=both"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Example: Retrieve a list of customfielditems belonging to the given customfield and having given ids.

Request

curl "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/customfielditems',
  qs: {
    customfield_id: '195923',
    ids: '3875655,3875657',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfielditems');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'customfield_id' => '195923',
  'ids' => '3875655,3875657',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfielditems"

querystring = {
  "customfield_id":"195923",
  "ids":"3875655,3875657",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&ids=3875655,3875657"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Example: Retrieve a list of customfielditems belonging to a given customfield that have been modified since a particular date.

Request

curl "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/customfielditems',
  qs: {
    customfield_id: '195923',
    modified_since: '2018-01-01T00:00:00-06:00',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfielditems');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'customfield_id' => '195923',
  'modified_since' => '2018-01-01T00:00:00-06:00',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfielditems"

querystring = {
  "customfield_id":"195923",
  "modified_since":"2018-01-01T00:00:00-06:00",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "customfielditems": {
      "1080235": {
        "id": 1080235,
        "customfield_id": 195923,
        "active": true,
        "short_code": "",
        "name": "Bazooka",
        "last_modified": "2018-03-27T16:13:35+00:00",
        "required_customfields": [ ]
      },
      "1080237": {
        "id": 1080237,
        "customfield_id": 195923,
        "active": true,
        "short_code": "",
        "name": "Shovel",
        "last_modified": "2018-03-27T16:13:35+00:00",
        "required_customfields": [ ]
      },
      "1080233": {
        "id": 1080233,
        "customfield_id": 195923,
        "active": true,
        "short_code": "",
        "name": "Tractor",
        "last_modified": "2018-03-27T16:13:35+00:00",
        "required_customfields": [ ]
      }
    }
  },
  "more": false,
  "supplemental_data": {
    "customfields": {
      "195923": {
        "id": 195923,
        "active": true,
        "required": true,
        "applies_to": "timesheet",
        "type": "managed-list",
        "short_code": "e",
        "regex_filter": "",
        "name": "Equipment",
        "last_modified": "2018-04-04T16:04:00+00:00",
        "created": "2018-03-27T16:13:35+00:00",
        "ui_preference": "drop_down",
        "required_customfields": [ ]
      }
    }
  }
}

Retrieves a list of all customfielditems associated with a customfield, with optional filters to narrow down the results.

HTTP Request

gethttps://rest.tsheets.com/api/v1/customfielditems

Filter Parameters

customfield_id
required
Int Id of the custom field whose items you'd like to list.
ids
optional
Int Comma separated list of one or more customfielditem ids you'd like to filter on. Only customfielditems with an id set to one of these values will be returned. If omitted, all customfielditems matching other specified filters are returned.
active
optional
String 'yes', 'no', or 'both'. Default is 'yes'. If a customfielditem is active, it is available for selection during time entry.
modified_before
optional
String Only customfielditems modified before this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
modified_since
optional
String Only customfielditems modified since this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
supplemental_data
optional
String 'yes' or 'no'. Default is 'yes'. Indicates whether supplemental data should be returned.
per_page
optional
Int Represents how many results you'd like to retrieve per request (page). Default is 50. Max is 50.
page
optional
Int Represents the page of results you'd like to retrieve. Default is 1.

Create Custom Field Items

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

Request Body

{
 "data":
  [
    {
      "name":"ServiceItem1",
      "customfield_id":"19142",
      "short_code":"c1"
    },
    {
      "name":"ServiceItem2",
      "customfield_id":"19142",
      "short_code":"c1"
    }
  ]
}

Request

curl -X POST \
  https://rest.tsheets.com/api/v1/customfielditems \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '<REQUEST BODY>'
var client = new RestClient("https://rest.tsheets.com/api/v1/customfielditems");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <TOKEN>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfielditems")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfielditems")
  .post(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "<REQUEST BODY>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'POST',
  url: 'https://rest.tsheets.com/api/v1/customfielditems',
  headers: 
   { 'Content-Type': 'application/json',
     'Authorization': 'Bearer <TOKEN>' },
  body: '<REQUEST BODY>',
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfielditems');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setBody('<REQUEST BODY>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfielditems")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/json'
request.body = "<REQUEST BODY>"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfielditems"

payload = "<REQUEST BODY>"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfielditems"

  payload := strings.NewReader("<REQUEST BODY>")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/json",
  "cache-control": "no-cache"
]
let parameters = <REQUEST BODY> as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/customfielditems")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = '<REQUEST BODY>';

$url="http://rest.tsheets.com/api/v1/customfielditems"; 

$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "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": "2018-07-23T23:09:14+00:00",
        "created": "2018-07-23T23:09:14+00:00"
      }
    }
  }
}

Add one or more customfielditems to a customfield.

HTTP Request

posthttps://rest.tsheets.com/api/v1/customfielditems

Properties

Pass an array of customfielditem objects as the value to a 'data' property (see example).

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

For a full list of the properties that may be set on a customfielditem, see The Custom Field Item 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.

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.

Update Custom Field Items

Example: Change some information for each of these customfielditems.

Request Body

{
 "data":
  [
    {
      "id":3085064,
      "customfield_id":19142,
      "active":true,
      "short_code":"por",
      "name":"Porsche"
    },
    {
      "id":3085066,
      "customfield_id":19142,
      "active":false,
      "short_code":"merc",
      "name":"Mercruiser"
    }
  ]
}

Request

curl -X PUT \
  https://rest.tsheets.com/api/v1/customfielditems \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '<REQUEST BODY>'
var client = new RestClient("https://rest.tsheets.com/api/v1/customfielditems");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/customfielditems")
Dim request = New RestRequest(Method.PUT)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/json")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/customfielditems")
  .put(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/customfielditems?customfield_id=195923&modified_since=2018-01-01T00:00:00-06:00",
  "method": "PUT",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "<REQUEST BODY>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'PUT',
  url: 'https://rest.tsheets.com/api/v1/customfielditems',
  headers: 
   { 'Content-Type': 'application/json',
     Authorization: 'Bearer <TOKEN>' },
  body: '<REQUEST BODY>',
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/customfielditems');
$request->setMethod(HTTP_METH_PUT);

$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setBody('<REQUEST BODY>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/customfielditems")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/json'
request.body = "<REQUEST BODY>"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/customfielditems"

payload = "<REQUEST BODY>"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/json"
    }

response = requests.request("PUT", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/customfielditems"

  payload := strings.NewReader("<REQUEST BODY>")

  req, _ := http.NewRequest("PUT", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/json",
  "cache-control": "no-cache"
]
let parameters = <REQUEST BODY> as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/customfielditems")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = '<REQUEST BODY>';

$url="http://rest.tsheets.com/api/v1/customfielditems"; 

$client->PUT($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "customfielditems": {
      "1": {
        "_status_code": 200,
        "_status_message": "Updated",
        "id": 3085064,
        "customfield_id": 19142,
        "active": true,
        "short_code": "por",
        "name": "Porsche"
      },
      "2": {
        "_status_code": 200,
        "_status_message": "Updated",
        "id": 3085066,
        "customfield_id": 19142,
        "active": false,
        "short_code": "merc",
        "name": "Mercruiser"
      }
    }
  },
  "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": "2018-07-23T23:09:14+00:00",
        "created": "2018-07-23T23:09:14+00:00"
      }
    }
  }
}

Edit one or more customfielditems for a customfield.

HTTP Request

puthttps://rest.tsheets.com/api/v1/customfielditems

Properties

Pass an array of customfielditem objects as the value to a 'data' property (see example).

id
required
Int Id of the customfielditem.

All other properties defined on a Custom Field Item 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.

Status Codes

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

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

Effective Settings

The Effective Settings Object

Example

{
  "general": {
    "settings": {
      "calculate_overtime": "1",
      "clockout_override": 1,
      "clockout_override_hours": 10,
      "clockout_override_notify_admin": 1,
      "clockout_override_notify_mgrs": 0,
      "daily_doubletime": "0",
      "daily_overtime": "0",
      "daily_regular_hours": 8,
      "date_locale": "us",
      "emp_panel": 1,
      "emp_panel_email": "0",
      "emp_panel_passwd": "0",
      "emp_panel_tz": "0",
      "employee_pto_entry": 0,
      "enable_timesheet_notes": "1",
      "hide_working_time": "0",
      "jc_label": "Job",
      "lunch_deduct": 0,
      "lunch_length": 1,
      "lunch_threshold": 9,
      "max_customfielditems": "-1",
      "max_jobcodes": "-1",
      "parent_clockin_display": 0,
      "payroll_end_date": "2018-09-28",
      "payroll_first_end_day": "1",
      "payroll_last_end_day": "16",
      "payroll_month_end_day": "1",
      "payroll_type": "biweekly",
      "pto_entry": 1,
      "pto_overtime": 0,
      "simple_clockin": 0,
      "time_format": 12,
      "timecard_fields": "JOBCODE,134913,143369,143377",
      "timeclock_label": "Time Clock",
      "timesheet_edit_notes_for_all_users": 0,
      "timesheet_notes_notify_admin": 0,
      "timesheet_notes_notify_mgrs": 0,
      "timesheet_notes_required": 0,
      "tz": "America/Denver",
      "week_start": 0,
      "weekly_regular_hours": "40"
    },
    "last_modified": "2019-02-11T17:45:18+00:00"
  },
  "alerts": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "approvals": {
    "settings": {
      "installed": "1"
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "breaks": {
    "settings": {
      "hide_pre_clockout_option": 0
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "dcaa": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "dialin": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "files": {
    "settings": {
      "installed": "1",
      "files_addon_app_discovery_notification": "1"
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "invoicing": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "location_aware": {
    "settings": {
      "installed": 1,
      "show_location": "1"
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "mobile_app_integrations": {
    "settings": {
      "installed": 1,
      "apps": {
        "expensify": {
          "triggers": {
            "TSMTriggerButton": {
              "id": 553,
              "active": true,
              "jobcode_ids": [
                0
              ],
              "android_playstore_uri": "org.me.mobiexpensifyg",
              "android_call_scheme": "http://mobile.expensify.com/SmartScan",
              "iphone_appstore_url": "https://itunes.apple.com/us/app/expensify-expense-reports/id471713959",
              "iphone_call_scheme": "http://mobile.expensify.com",
              "call_url_host": "SmartScan",
              "call_uri_format": "tag=%JOBCODE_NAME%&billable=%JOBCODE_BILLABLE%&email=%EMAIL%&callbackURL=%TSHEETS_RETURN_URL%",
              "callback_uri_format": ""
            }
          }
        }
      }
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "mobile_app_settings": {
    "settings": {
      "installed": "1",
      "location_tracking": "off",
      "mandatory_location_services": "0"
    },
    "last_modified": "2019-02-09T18:39:20+00:00"
  },
  "reminders": {
    "settings": {
      "installed": 1
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "projects": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "quickbooks": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "restapi": {
    "settings": {
      "installed": "1"
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "rounding": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "schedule": {
    "settings": {
      "installed": "1",
      "business_hours_end": "17:00:00",
      "business_hours_start": "08:00:00",
      "drafted_first_schedule_event_occurred": "1",
      "manage_schedule_permission": "company",
      "published_first_schedule_event_occurred": "1",
      "trial_expiration_date": "2018-10-17",
      "view_schedule_permission": "company",
      "learning_step": "7",
      "employee_view": "company",
      "manager_view": "company"
    },
    "last_modified": "2019-02-09T18:03:55+00:00"
  },
  "sms": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "sounds": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "customfields": {
    "settings": {
      "maximum_allowed_timesheet_custom_fields": 6,
      "installed": "1"
    },
    "last_modified": "2019-02-10T20:34:10+00:00"
  },
  "time_entry": {
    "settings": {
      "installed": 1,
      "time_entry_method": "timecard",
      "mtc_format_time_display": "hhmm",
      "time_entry": 0,
      "timecard": 1,
      "weekly_timecard": 1,
      "timecard_daily": 0,
      "timesheet_edit": 0,
      "timesheet_map": 1,
      "pto_entry": 1,
      "timesheet_list_date_range_selection": "month",
      "timesheet_list_show_days_with_no_time": 0,
      "timesheet_list_wrap_text": 0,
      "timesheet_list_column_selection": "time,job,location,kiosk,attachments,notes",
      "timesheet_list_bottomless_scroll": 1,
      "mtc_combine_regular_timesheets": "0"
    },
    "last_modified": "2019-01-25T20:53:52+00:00"
  },
  "toodledo": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "twitter": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "xero": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  },
  "zenpayroll": {
    "settings": {
      "installed": 0
    },
    "last_modified": "2001-01-01T12:00:00+00:00"
  }
}

All combined, cascaded settings that apply to a given user are contained in the effective settings object.

The effective settings object consists of a series of sections. Each section contains a settings and a last_modified property. The settings property is a list of key/value pairs. The last_modified property is an ISO 8601-formatted timestamp. It gets updated any time a key/value pair within a section has changed.

Below is a list of the possible section headings.

general General application settings
alerts Settings for the Alerts Add-On
approvals Settings for the Approvals Add-On
breaks Settings for the Breaks Add-On
dcaa Settings for the DCAA Compliance Add-On
dialin Settings for the Dial-in Add-On
files Settings for the Files Add-On
invoicing Settings for the Invoicing Add-On
location_aware Settings for the Location Aware Add-On
mobile_app_integrations Settings for the Mobile App Integrations Add-On
mobile_app_settings Settings for the Mobile App Settings Add-On
reminders Settings for the Reminders Add-On
projects Settings for the Projects Add-On
quickbooks Settings for the Quickbooks Integration Add-On
restapi Settings for the TSheets Rest API Add-On
rounding Settings for the Timesheet Rounding Add-On
schedule Settings for the Schedule Add-On
sms Settings for the Text Messaging Add-On
sounds Settings for the Sounds Add-On
customfields Settings for the Advanced Tracking Add-On
time_entry Settings for the Time Card Selector Add-On
toodledo Settings for the Toodledo Add-On
twitter Settings for the Twitter Add-On
xero Settings for the Xero Integration Add-On
zenpayroll Settings for the Zen Payroll Integration Add-On

Retrieve Effective Settings

Example: Retrieve a list of all effective settings for a specific user.

Request

curl "https://rest.tsheets.com/api/v1/effective_settings?user_id=1234" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/effective_settings?user_id=1234");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/effective_settings?user_id=1234")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/effective_settings?user_id=1234")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/effective_settings?user_id=1234",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/effective_settings',
  qs: {
    user_id: '1234',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/effective_settings');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'user_id' => '1234',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/effective_settings?user_id=1234")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/effective_settings"

querystring = {
  "user_id":"1234",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/effective_settings?user_id=1234"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/effective_settings?user_id=1234")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/effective_settings?user_id=1234"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Example: Retrieve a list of all effective settings modified since a specified date. Currently logged in user's id will be used since none is specified in the request.

Request

curl "https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/effective_settings',
  qs: {
    modified_since: '2018-03-01T00:00:00-0600',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/effective_settings');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'modified_since' => '2018-03-01T00:00:00-0600',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/effective_settings"

querystring = {
  "modified_since":"2018-03-01T00:00:00-0600",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/effective_settings?modified_since=2018-03-01T00:00:00-0600"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "effective_settings": {
      "general": {
        "settings": {
          "calculate_overtime": "1",
          "clockout_override": 1,
          "clockout_override_hours": 10,
          "clockout_override_notify_admin": 1,
          "clockout_override_notify_mgrs": 0,
          "daily_doubletime": "0",
          "daily_overtime": "0",
          "daily_regular_hours": 8,
          "date_locale": "us",
          "emp_panel": 1,
          "emp_panel_email": "0",
          "emp_panel_passwd": "0",
          "emp_panel_tz": "0",
          "employee_pto_entry": 0,
          "enable_timesheet_notes": "1",
          "hide_working_time": "0",
          "jc_label": "Job",
          "lunch_deduct": 0,
          "lunch_length": 1,
          "lunch_threshold": 9,
          "max_customfielditems": "-1",
          "max_jobcodes": "-1",
          "parent_clockin_display": 0,
          "payroll_end_date": "2018-09-28",
          "payroll_first_end_day": "1",
          "payroll_last_end_day": "16",
          "payroll_month_end_day": "1",
          "payroll_type": "biweekly",
          "pto_entry": 1,
          "pto_overtime": 0,
          "simple_clockin": 0,
          "time_format": 12,
          "timecard_fields": "JOBCODE,134913,143369,143377",
          "timeclock_label": "Time Clock",
          "timesheet_edit_notes_for_all_users": 0,
          "timesheet_notes_notify_admin": 0,
          "timesheet_notes_notify_mgrs": 0,
          "timesheet_notes_required": 0,
          "tz": "America/Denver",
          "week_start": 0,
          "weekly_regular_hours": "40"
        }
        "last_modified": "2018-04-05T19:19:45+00:00"
      },
      "alerts": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "approvals": {
        "settings": {
          "installed": "1"
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "breaks": {
        "settings": {
          "hide_pre_clockout_option": 0
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "dcaa": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "dialin": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "files": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "invoicing": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "mobile_app_integrations": {
        "settings": {
          "installed": 0,
          "apps": ""
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "mobile_app_settings": {
        "settings": {
          "installed": 1,
          "location_tracking": "optional",
          "mandatory_location_services": 0
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "reminders": {
        "settings": {
          "installed": 1
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "quickbooks": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "restapi": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "rounding": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "schedule": {
        "settings": {
          "installed": "1",
          "business_hours_end": "17:00:00",
          "business_hours_start": "08:00:00",
          "manage_schedule_permission": "company",
          "trial_expiration_date": "2018-04-11",
          "view_schedule_permission": "company",
          "employee_view": "company",
          "manager_view": "company"
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "sms": {
        "settings": {
          "installed": 0,
          "email_notify": "1",
          "mobile_number": "2087231456",
          "sms_notify": "1"
        },
        "last_modified": "2018-03-27T16:13:35+00:00"
      },
      "sounds": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "customfields": {
        "settings": {
          "maximum_allowed_timesheet_custom_fields": 6,
          "installed": "1"
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "time_entry": {
        "settings": {
          "installed": 1,
          "time_entry_method": "timecard",
          "mtc_format_time_display": "hhmm",
          "time_entry": 0,
          "timecard": 1,
          "weekly_timecard": 1,
          "timecard_daily": 0,
          "timesheet_edit": 0,
          "timesheet_map": 1,
          "pto_entry": 1,
          "timesheet_list_date_range_selection": "week",
          "timesheet_list_show_days_with_no_time": 1,
          "timesheet_list_wrap_text": 0,
          "timesheet_list_column_selection": "time,job,location,kiosk,attachments,notes",
          "timesheet_list_bottomless_scroll": 0
        },
        "last_modified": "2018-04-04T19:42:03+00:00"
      },
      "toodledo": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "twitter": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "xero": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      },
      "zenpayroll": {
        "settings": {
          "installed": 0
        },
        "last_modified": "2001-01-01T12:00:00+00:00"
      }
    }
  }
}

Retrieves a list of all effective settings associated with a single user, with optional filters to narrow down the results.

HTTP Request

gethttps://rest.tsheets.com/api/v1/effective_settings

Filter Parameters

user_id
optional
Int User id for whom you'd like to retrieve effective settings. If none is specified, the currently logged in user's id will be used. Only effective settings that apply to this user_id will be returned. An admin will see more settings than a regular user will.
modified_before
optional
String Only sections with settings modified before this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
modified_since
optional
String Only sections with settings modified since this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).

Files

The TSheets API provides methods for uploading, downloading, and managing image files that can be attached to Timesheets. This is especially useful for workers in the field, for example, who may need to provide visual proof of completion of a job, or to document exceptional conditions which may arise while on the clock.

The File Object

Example

{
  "id": 47765,
  "uploaded_by_user_id": 317046,
  "file_name": "IMG_20181004_214839.png",
  "active": true,
  "size": 369302,
  "last_modified": "2018-10-05T03:57:49+00:00",
  "created": "2018-10-05T03:57:49+00:00",
  "linked_objects": {
    "timesheets": [
      "730045"
    ]
  },
  "meta_data": {
    "file_description": "on-site selfie",
    "image_rotation": "0"
  }
}

Following is a list of the properties that belong to a file object, and a description of each.

id
read-only
Int Id of this file.
file_name
read-write
String Name of this file.
file_data
write-only
String Base64 encoded string of this file. May only be set when adding a file. Not displayed in response to a request to list files or in supplemental_data.
uploaded_by_user_id
read-only
Int Id of the user that uploaded this file.
active
read-only
Boolean If false, this file is considered deleted.
size
read-only
Int Size of the file in bytes
created
read-only
String Date/time when this customfield was created, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
last_modified
read-only
String Date/time when this customfield was last modified, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
linked_objects
read-only
Object This is a key/value map of all the objects linked to this file and the corresponding object ids.
meta_data
read-write
JSON Object This is a key/value map of any additional data associated with this file. List of allowed keys:
  • file_description: String Description of this file.
  • image_rotation: Int Original image orientation in degrees. Accepted values are: 0 (top), 90 (right), 180 (bottom), 270 (left).

Retrieve Files

Example: Retrieve a list of all files.

Request

curl "https://rest.tsheets.com/api/v1/files" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/files");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/files")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/files")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/files",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/files',
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/files');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/files")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/files"

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/files"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/files")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/files"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Example: Retrieve a list of all files (active or deleted) linked to timesheet with given id.

Request

curl "https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/files',
  qs: {
    linked_object_type: 'timesheet',
    object_ids: '21718670',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/files');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'linked_object_type' => 'timesheet',
  'object_ids' => '21718670',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/files"

querystring = {
  "linked_object_type":"timesheet",
  "object_ids":"21718670",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "files": {
      "44878": {
        "id": 44878,
        "uploaded_by_user_id": 19128,
        "file_name": "tsheets.jpeg",
        "active": true,
        "size": 7890,
        "last_modified": "2018-07-03T17:46:58+00:00",
        "created": "2018-07-03T17:46:58+00:00",
        "linked_objects": {
          "timesheets": [
            "135288482",
            "135288514",
            "135288460"
          ]
        },
        "meta_data": {
          "file_description": "Excellent app to track time"
        }
      },
      "44174": {
        "id": 44174,
        "uploaded_by_user_id": 19128,
        "file_name": "relentless.jpeg",
        "active": true,
        "size": 34900,
        "last_modified": "2018-07-03T17:47:53+00:00",
        "created": "2018-07-03T17:47:53+00:00",
        "linked_objects": [],
        "meta_data": {
          "file_description": "Passionate about our clients success!"
        }
      },
      "50692": {
        "id": 50692,
        "uploaded_by_user_id": 19128,
        "file_name": "healthy.jpg",
        "active": true,
        "size": 4560,
        "last_modified": "2018-08-24T00:09:32+00:00",
        "created": "2018-08-24T00:09:32+00:00",
        "linked_objects": {
          "timesheets": [
            "135288482",
            "135288514",
            "135288460"
          ]
        },
        "meta_data": {
          "file_description": "Work hard period play hard period!"
        }
      }
    }
  },
  "supplemental_data": {
    "users": {
      "19128": {
        "id": 19128,
        "first_name": "Shree",
        "last_name": "Yalamanchili",
        "group_id": 0,
        "active": true,
        "employee_number": 0,
        "salaried": false,
        "exempt": false,
        "username": "shree",
        "email": "shree_dev@tsheets.com",
        "email_verified": true,
        "payroll_id": "",
        "hire_date": "0000-00-00",
        "term_date": "0000-00-00",
        "last_modified": "2018-08-16T18:32:46+00:00",
        "last_active": "2018-08-16T15:16:22+00:00",
        "created": "2017-04-05T15:41:30+00:00",
        "client_url": "devrocks",
        "company_name": "DevRocks",
        "profile_image_url": "",
        "mobile_number": "",
        "pto_balances": "",
        "submitted_to": "2018-01-22",
        "approved_to": "2018-01-15",
        "manager_of_group_ids": [
          27520
        ],
        "require_password_change": false,
        "pay_rate": 0,
        "pay_interval": "hour",
        "permissions": {
          "admin": true,
          "mobile": true,
          "status_box": true,
          "reports": true,
          "manage_timesheets": true,
          "manage_authorization": true,
          "manage_users": true,
          "manage_my_timesheets": true,
          "manage_jobcodes": true,
          "pin_login": true,
          "approve_timesheets": true,
          "manage_schedules": true,
          "external_access": false,
          "manage_my_schedule": false,
          "manage_company_schedules": true,
          "view_company_schedules": false,
          "view_group_schedules": false,
          "manage_no_schedules": false,
          "view_my_schedules": false
        },
        "customfields": ""
      }
    },
    "timesheets": {
      "135288482": {
        "id": 135288482,
        "user_id": 1242515,
        "jobcode_id": 17288283,
        "start": "2018-07-16T09:04:00-06:00",
        "end": "2018-07-16T15:57:00-06:00",
        "duration": 24780,
        "date": "2018-07-16",
        "tz": -6,
        "tz_str": "tsMT",
        "type": "regular",
        "location": "(Eagle, ID?)",
        "on_the_clock": false,
        "locked": 0,
        "notes": "",
        "customfields": {
          "19142": "Item 1",
          "19144": "Item 2"
        },
        "attached_files": [
          50692,
          44878
        ],
        "last_modified": "1970-01-01T00:00:00+00:00",
        "created": "1970-01-01T00:00:00+00:00"
      },
      "135288514": {
        "id": 135288514,
        "user_id": 1242509,
        "jobcode_id": 18080900,
        "start": "2018-07-16T13:07:00-06:00",
        "end": "2018-07-16T17:29:00-06:00",
        "duration": 15720,
        "date": "2018-07-16",
        "tz": -6,
        "tz_str": "tsMT",
        "type": "regular",
        "location": "(Eagle, ID?)",
        "on_the_clock": false,
        "locked": 0,
        "notes": "",
        "customfields": {
          "19142": "Item 1",
          "19144": "Item 2"
        },
        "attached_files": [
          50692,
          44878
        ],
        "last_modified": "1970-01-01T00:00:00+00:00",
        "created": "1970-01-01T00:00:00+00:00"
      },
      "135288460": {
        "id": 135288460,
        "user_id": 1242509,
        "jobcode_id": 18080900,
        "start": "2018-07-18T08:09:00-06:00",
        "end": "2018-07-18T14:58:00-06:00",
        "duration": 24540,
        "date": "2018-07-18",
        "tz": -6,
        "tz_str": "tsMT",
        "type": "regular",
        "location": "(Eagle, ID?)",
        "on_the_clock": false,
        "locked": 0,
        "notes": "",
        "customfields": {
          "19142": "Item 1",
          "19144": "Item 2"
        },
        "attached_files": [
          50692,
          44878
        ],
        "last_modified": "1970-01-01T00:00:00+00:00",
        "created": "1970-01-01T00:00:00+00:00"
      }
    }
  }
}

Retrieves a list of all uploaded files, with optional filters to narrow down the results.

HTTP Request

gethttps://rest.tsheets.com/api/v1/files

Filter Parameters

ids
optional
Int Comma separated list of one or more file ids you'd like to filter on.
uploaded_by_user_ids
optional
Int Comma separated list of one or more user ids you'd like to filter on. Only files uploaded by these users will be returned. If uploaded_by_user_ids is not set, it will default to return files uploaded by the current user making the api request.
linked_object_type
optional
String Only files linked to this object type are returned. Allowed values: 'timesheet'.
object_ids
optional
Int Comma separated list of one or more linked object ids you'd like to filter on.
active
optional
String 'yes', 'no', or 'both'. Default is 'yes'.
modified_before
optional
String Only files modified before this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
modified_since
optional
String Only files modified since this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
supplemental_data
optional
String 'yes' or 'no'. Default is 'yes'. Indicates whether supplemental data should be returned.
per_page
optional
Int Represents how many results you'd like to retrieve per request (page). Default is 50. Max is 50.
page
optional
Int Represents the page of results you'd like to retrieve. Default is 1.

Upload Files

Example: Upload a file.

Request Body

{
 "data":
  [
    {
     "file_data":"data:image/png;base64,iVBORw0KGgoAAA...< actual data here >...ANI=",
     "file_name":"invisible_minion.png",   
     "meta_data": {
           "file_description":"Ba-ba-ba-ba-ba-nana",
           "image_rotation": 0
     }
    }
  ]
}

Request

curl -X POST \
  https://rest.tsheets.com/api/v1/files \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Length: <LENGTH>' \
  -H 'Content-Type: application/json' \
  -d '<REQUEST BODY>'
var client = new RestClient("https://rest.tsheets.com/api/v1/files");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <TOKEN>");
request.AddHeader("Content-Length", "<LENGTH>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/files")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Length", "<LENGTH>")
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/files")
  .post(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Length", "<LENGTH>")
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "Content-Length", "<LENGTH>",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "<REQUEST BODY>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'POST',
  url: 'https://rest.tsheets.com/api/v1/files',
  headers: 
   { 'Content-Type': 'application/json',
     'Content-Length': '<LENGTH>',
     'Authorization': 'Bearer <TOKEN>' },
  body: '<REQUEST BODY>',
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/files');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Content-Length' => '<LENGTH>',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setBody('<REQUEST BODY>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/files")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Length"] = '<LENGTH>',
request["Content-Type"] = 'application/json'
request.body = "<REQUEST BODY>"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/files"

payload = "<REQUEST BODY>"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Length': '<LENGTH>',
    'Content-Type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/files"

  payload := strings.NewReader("<REQUEST BODY>")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Length", "<LENGTH>")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/json",
   "Content-Length": "<LENGTH>",
  "cache-control": "no-cache"
]
let parameters = <REQUEST BODY> as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/files")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');
$client->addHeader('Content-Length', '<LENGTH>');

$req = '<REQUEST BODY>';

$url="http://rest.tsheets.com/api/v1/files"; 

$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "files": {
      "1": {
        "_status_code": 200,
        "_status_message": "Uploaded",
        "id": 123828,
        "uploaded_by_user_id": 19128,
        "file_name": "invisible_minion.png",
        "active": true,
        "size": 95,
        "last_modified": "2018-08-24T00:09:32+00:00",
        "created": "2018-08-24T00:09:32+00:00",
        "linked_objects": [],
        "meta_data": {
          "file_description": "Ba-ba-ba-ba-ba-nana",
          "image_rotation": 0
        }
      }
    }
  },
  "supplemental_data": {
    "users": {
      "19128": {
        "id": 19128,
        "first_name": "Shree",
        "last_name": "Yalamanchili",
        "group_id": 0,
        "active": true,
        "employee_number": 0,
        "salaried": false,
        "exempt": false,
        "username": "shree",
        "email": "shree_dev@tsheets.com",
        "email_verified": true,
        "payroll_id": "",
        "hire_date": "0000-00-00",
        "term_date": "0000-00-00",
        "last_modified": "2018-08-16T18:32:46+00:00",
        "last_active": "2018-08-16T15:16:22+00:00",
        "created": "2017-04-05T15:41:30+00:00",
        "client_url": "devrocks",
        "company_name": "DevRocks",
        "profile_image_url": "",
        "mobile_number": "",
        "pto_balances": "",
        "submitted_to": "2018-01-22",
        "approved_to": "2017-04-06",
        "manager_of_group_ids": [
          27520
        ],
        "require_password_change": false,
        "pay_rate": 0,
        "pay_interval": "hour",
        "permissions": {
          "admin": true,
          "mobile": true,
          "status_box": true,
          "reports": true,
          "manage_timesheets": true,
          "manage_authorization": true,
          "manage_users": true,
          "manage_my_timesheets": true,
          "manage_jobcodes": true,
          "pin_login": true,
          "approve_timesheets": true,
          "manage_schedules": true,
          "external_access": false,
          "manage_my_schedule": false,
          "manage_company_schedules": true,
          "view_company_schedules": false,
          "view_group_schedules": false,
          "manage_no_schedules": false,
          "view_my_schedules": false
        },
        "customfields": ""
      }
    }
  }
} 

Add one or more files that can be attached to objects. Currently we only allow .png, .jpeg, .jpg file formats.

HTTP Request

posthttps://rest.tsheets.com/api/v1/files

Properties

Pass an array of file objects as the value to a 'data' property (see example).

file_name
required
String Name of the file.
file_data
required
String Base64 encoded string of the file.

For a full list of the properties that may be set on a file, see the File object.

Status Codes

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

200 OK. File was uploaded successfully.
417 Expectation Failed. Something was wrong or missing with the properties supplied for this file. See the _status_extra value for more detail.

Update Files

Example: Update a file.

Request Body

{
 "data":
  [
    {
     "id":"123455",   
     "meta_data": {
           "file_description":"Testing PUT request",
           "image_rotation": 180
     }
    }
  ]
}

Request

curl -X PUT \
  https://rest.tsheets.com/api/v1/files \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '<REQUEST BODY>'
var client = new RestClient("https://rest.tsheets.com/api/v1/files");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/files")
Dim request = New RestRequest(Method.PUT)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/json")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/files")
  .put(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/files?linked_object_type=timesheet&object_ids=21718670",
  "method": "PUT",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "<REQUEST BODY>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'PUT',
  url: 'https://rest.tsheets.com/api/v1/files',
  headers: 
   { 'Content-Type': 'application/json',
     Authorization: 'Bearer <TOKEN>' },
  body: '<REQUEST BODY>',
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/files');
$request->setMethod(HTTP_METH_PUT);

$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setBody('<REQUEST BODY>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/files")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/json'
request.body = "<REQUEST BODY>"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/files"

payload = "<REQUEST BODY>"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/json"
    }

response = requests.request("PUT", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/files"

  payload := strings.NewReader("<REQUEST BODY>")

  req, _ := http.NewRequest("PUT", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/json",
  "cache-control": "no-cache"
]
let parameters = <REQUEST BODY> as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/files")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = '<REQUEST BODY>';

$url="http://rest.tsheets.com/api/v1/files"; 

$client->PUT($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "files": {
      "123455": {
        "_status_code": 200,
        "_status_message": "Updated",
        "id": 123455,
        "uploaded_by_user_id": 19128,
        "file_name": "invisible_minion.png",
        "active": true,
        "size": 95,
        "last_modified": "2018-09-19T00:09:32+00:00",
        "created": "2018-08-24T00:09:32+00:00",
        "linked_objects": [],
        "meta_data": {
          "file_description": "Testing PUT request",
          "image_rotation": 180
        }
      }
    }
  },
  "supplemental_data": {
    "users": {
      "19128": {
        "id": 19128,
        "first_name": "Shree",
        "last_name": "Yalamanchili",
        "group_id": 0,
        "active": true,
        "employee_number": 0,
        "salaried": false,
        "exempt": false,
        "username": "shree",
        "email": "shree_dev@tsheets.com",
        "email_verified": true,
        "payroll_id": "",
        "hire_date": "0000-00-00",
        "term_date": "0000-00-00",
        "last_modified": "2018-08-16T18:32:46+00:00",
        "last_active": "2018-08-16T15:16:22+00:00",
        "created": "2017-04-05T15:41:30+00:00",
        "client_url": "devrocks",
        "company_name": "DevRocks",
        "profile_image_url": "",
        "mobile_number": "",
        "pto_balances": "",
        "submitted_to": "2018-01-22",
        "approved_to": "2017-04-06",
        "manager_of_group_ids": [
          27520
        ],
        "require_password_change": false,
        "pay_rate": 0,
        "pay_interval": "hour",
        "permissions": {
          "admin": true,
          "mobile": true,
          "status_box": true,
          "reports": true,
          "manage_timesheets": true,
          "manage_authorization": true,
          "manage_users": true,
          "manage_my_timesheets": true,
          "manage_jobcodes": true,
          "pin_login": true,
          "approve_timesheets": true,
          "manage_schedules": true,
          "external_access": false,
          "manage_my_schedule": false,
          "manage_company_schedules": true,
          "view_company_schedules": false,
          "view_group_schedules": false,
          "manage_no_schedules": false,
          "view_my_schedules": false
        },
        "customfields": ""
      }
    }
  }
}

Edit one or more files that are attached to objects.

HTTP Request

puthttps://rest.tsheets.com/api/v1/files

Properties

Pass an array of file objects as the value to a 'data' property (see example).

When editing a file, you must uniquely identify the file by passing in its id. All other properties defined below 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.

id
required
Int Id of the file to edit.
file_name
optional
String Name of this file the file to edit.
meta_data
read-write
JSON Object This is a key/value map of any additional data associated with this file. List of allowed keys:
  • file_description: String Description of this file.
  • image_rotation: Int Original image orientation in degrees. Accepted values are: 0 (top), 90 (right), 180 (bottom), 270 (left).

Status Codes

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

200 OK. File was updated successfully.
404 Not Found. File either has never existed or has been deleted.
417 Expectation Failed. Something was wrong or missing with the properties supplied for this file. See the _status_extra value for more detail.

Download a File

Example: The following request returns a .jpg object.

Request

curl "https://rest.tsheets.com/api/v1/files/raw?id=123828" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/files/raw?id=123828");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/files/raw?id=123828")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/files/raw?id=123828")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/files/raw?id=123828",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/files/raw',
  qs: {
    id: '123828',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/files/raw');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'id' => '123828',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/files/raw?id=123828")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/files/raw"

querystring = {
  "id":"123828",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/files/raw?id=123828"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/files/raw?id=123828")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/files/raw?id=123828"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

Content-Type: application/octet-stream
Content-Length: 95
Content-Disposition: attachment; filename="invisible_minion.jpg"
Cache-Control: max-age=86400

[95 bytes of object data]

Download a file in raw binary format.

HTTP Request

gethttps://rest.tsheets.com/api/v1/files/raw

Parameters

id
required
Int Id of the file to download.

Response

The raw bytes of the file are returned, and the Content-Type header is set to a binary media type of 'application/octet-stream'.

Delete Files

Example: Request to delete four files. Two succeed and two fail.

Request

curl -X DELETE "https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999"
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999")
Dim request = New RestRequest(Method.[DELETE])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999")
  .delete()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999",
  "method": "DELETE",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'DELETE',
  url: 'https://rest.tsheets.com/api/v1/files',
  qs: {
    ids: '129526,129524,13455,89999',
  },
  headers: 
   { Authorization: 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/files');
$request->setMethod(HTTP_METH_DELETE);

$request->setQueryData(array(
  'ids' => '129526,129524,13455,89999',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/files"

querystring = {
  "ids":"129526,129524,13455,89999",
}

payload = ""
headers = {
    'Authorization': "Bearer <TOKEN>"
    }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999"

  req, _ := http.NewRequest("DELETE", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/files?ids=129526,129524,13455,89999"; 

$client->DELETE($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
 "results": {
  "files": {
   "129526": {
    "_status_code": 200,
    "_status_message": "OK, deleted",
    "id": "129526"
   },
   "129524": {
    "_status_code": 200,
    "_status_message": "OK, deleted",
    "id": "129524"
   },
   "13455": {
    "_status_code": 404,
    "_status_message": "File not found!",
    "id": "13455"
   },
   "89999": {
    "_status_code": 404,
    "_status_message": "File not found!",
    "id": "89999"
   }
  }
 }
}

Delete one or more files.

HTTP Request

deletehttps://rest.tsheets.com/api/v1/files

Parameters

If no filters are specified at all, no files are deleted.

ids
optional
Int Comma separated list of file ids you'd like to delete.

Status Codes

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

200 OK. File was deleted successfully.
417 Expectation Failed. Something went wrong for this file. See the _status_extra value for more detail.

Geofence Configs

The Geofence Config Object

Example

{
  "id": 151,
  "type": "location",
  "type_id": 282316,
  "active": true,
  "enabled": true,
  "radius": 150,
  "last_modified": "2017-09-07T19:09:26+00:00",
  "created": "2017-09-07T19:09:26+00:00"
}

Following is a list of the properties that belong to a geofence config object, and a description of each.

id
read-only
Int Id of geofence config.
type
read-write
String 'location'. The type of entity the geofence config is related to.
type_id
read-write
Int The id of the entity the geofence config is related to.
active
read-write
Boolean If true, this geofence config is active. If false, this geofence config is archived.
enabled
read-write
Boolean true or false. Indicates whether a geofence for the associated entity should be enabled.
radius
read-write
Int Configures the size of the geofence.
last_modified
read-only
String Date/time when this geofence config was last modified, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
created
read-only
String Date/time when this geofence config was created, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).

Retrieve Geofence Configs

Example: Retrieve a list of all geofence configs for the current client.

Request

curl "https://rest.tsheets.com/api/v1/geofence_configs" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/geofence_configs");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/geofence_configs")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/geofence_configs")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/geofence_configs",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/geofence_configs',
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/geofence_configs');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/geofence_configs")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/geofence_configs"

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/geofence_configs"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/geofence_configs")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/geofence_configs"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "geofence_configs": {
      "151": {
        "id": 151,
        "type": "locations",
        "type_id": 282316,
        "active": true,
        "enabled": true,
        "radius": 150,
        "last_modified": "2017-09-07T19:09:26+00:00",
        "created": "2017-09-07T19:09:26+00:00"
      },
      "297": {
        "id": 297,
        "type": "locations",
        "type_id": 323445,
        "active": true,
        "enabled": false,
        "radius": 125,
        "last_modified": "2017-09-11T13:11:14+00:00",
        "created": "2017-09-11T13:11:14+00:00"
      }
    }
  },
  "more": false,
  "supplemental_data": {
    "locations": {
      "282316": {
        "id": 282316,
        "addr1": "1234 W Way St",
        "addr2": "",
        "city": "Eagle",
        "state": "Idaho",
        "zip": "83714",
        "country": "US",
        "active": true,
        "latitude": 43.62122110,
        "longitude": -116.34932150,
        "place_id": "",
        "place_id_hash": "8c43103323bb0b1ce7c4094029029914",
        "label": "1234 W Way St Eagle, Idaho 83714 US",
        "notes": "",
        "geocoding_status": "complete",
        "created": "2018-07-12T21:13:14+00:00",
        "last_modified": "2018-07-12T21:13:14+00:00",
        "linked_objects": {},
        "geofence_config_id": 151
      },
      "323445": {
        "id": 323445,
        "addr1": "5678 E End St",
        "addr2": "",
        "city": "Eagle",
        "state": "Idaho",
        "zip": "83714",
        "country": "US",
        "active": true,
        "latitude": -33.87904780,
        "longitude": 151.21133580,
        "place_id": "",
        "place_id_hash": "f6933fee56d6cd9e02d1dbff1a551cfa",
        "label": "5678 E End St Eagle, Idaho 83714 US",
        "notes": "",
        "geocoding_status": "complete",
        "created": "2018-07-12T21:13:14+00:00",
        "last_modified": "2018-07-12T21:13:14+00:00",
        "linked_objects": {
          "jobcodes": [
            2589531
          ]
        },
        "geofence_config_id": 297
      }
    }
  }
}

Retrieves a list of all geofence configs, with optional filters to narrow down the results.

HTTP Request

gethttps://rest.tsheets.com/api/v1/geofence_configs

Filter Parameters

ids
optional
Int Comma separated list of one or more geofence config ids you'd like to filter on. Only geofence configs with an id set to one of these values will be returned. If omitted, all geofence configs matching other specified filters are returned.
type
optional
String Comma separated list of one or more types. If specified only geofence configs of that type will be returned.
type_ids
optional
Int Comma separated list of one or more type ids you'd like to filter on. Only geofence configs with a type_id set to one of these values will be returned.
enabled
optional
Boolean true or false. If specified only geofence configs with matching enabled values will be returned.
active
optional
String 'yes', 'no', or 'both'. Default is 'yes'.
modified_before
optional
String Only geofence configs modified before this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
modified_since
optional
String Only geofence configs modified since this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm).
supplemental_data
optional
String 'yes' or 'no'. Default is 'yes'. Indicates whether supplemental data should be returned.
per_page
optional
Int Represents how many results you'd like to retrieve per request (page). Default is 50. Max is 50.
page
optional
Int Represents the page of results you'd like to retrieve. Default is 1.
by_jobcode_assignment
optional
Boolean true or false. If specified, only geofence configs related to a location that is mapped to a jobcode the user is assigned to will be returned.

Geolocations

The Geolocation Object

Example

{
  "id": 185648268,
  "user_id": 29474,
  "accuracy": 21,
  "altitude": 0,
  "latitude": 43.6866258,
  "longitude": -116.3516646,
  "device_identifier": "",
  "source": "gps",
  "heading": 0,
  "speed": 0,  
  "created": "2018-08-16T17:56:57+00:00"
}

Following is a list of the properties that belong to a geolocation, and a description of each.

id
read-only
Int Id of geolocation.
user_id
read-write
Int User id for the user that this geolocation belongs to.
accuracy
read-write
Int Indicates the radius of accuracy around the geolocation in meters.
altitude
read-write
Float Indicates the altitude of the geolocation in meters.
latitude
read-write
Float Indicates the latitude of the geolocation in degrees.
longitude
read-write
Float Indicates the longitude of the geolocation in degrees.
speed
read-write
Float Indicates the speed of travel (meters per second) when the geolocation was recorded.
heading
read-write
Int Indicates the heading of the geolocation in degrees.
source
read-write
String Indicates how the GPS point was obtained. One of 'gps', 'wifi', or 'cell'.
device_identifier
read-write
String Unique identifier (for the given client) for the device associated with this geolocation.
created
read-only
String Date/time when this geolocation was created, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm)

Retrieve Geolocations

Example: Retrieve a list of all geolocations modified since a given date.

Request

curl "https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00" \
  -H "Authorization: Bearer <TOKEN>"
var client = new RestClient("https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <TOKEN>");
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00")
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Authorization", "Bearer <TOKEN>")
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00")
  .get()
  .addHeader("Authorization", "Bearer <TOKEN>")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00",
  "method": "GET",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'GET',
  url: 'https://rest.tsheets.com/api/v1/geolocations',
  qs: {
    modified_since: '2018-08-01T12:00:00-06:00',
  },
  headers: 
   { 'Authorization': 'Bearer <TOKEN>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/geolocations');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'modified_since' => '2018-08-01T12:00:00-06:00',
));

$request->setHeaders(array(
  'Authorization' => 'Bearer <TOKEN>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <TOKEN>'

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/geolocations"

querystring = {
  "modified_since":"2018-08-01T12:00:00-06:00",
}

payload = ""
headers = {
   'Authorization': "Bearer <TOKEN>"
  }

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Bearer <TOKEN>")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "cache-control": "no-cache"
]

let request = NSMutableURLRequest(
  url: NSURL(string: "https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest, completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Accept', 'application/json');

$url="https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00"; 

$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "geolocations": {
      "185648268": {
      "id": 185648268,
      "user_id": 29474,
      "accuracy": 21,
      "altitude": 0,
      "latitude": 43.6866258,
      "longitude": -116.3516646,
      "device_identifier": "",
      "source": "gps",
      "heading": 0,
      "speed": 0,        
      "created": "2018-08-16T17:56:57+00:00"
    },
    "185648270": {
      "id": 185648270,
      "user_id": 29474,
      "accuracy": 20,
      "altitude": 0,
      "latitude": 43.6866377,
      "longitude": -116.3516499,
      "device_identifier": "",
      "source": "gps",
      "heading": 0,
      "speed": 0,        
      "created": "2018-08-16T17:57:24+00:00"
    },
    "185648320": {
      "id": 185648320,
      "user_id": 29474,
      "accuracy": 20,
      "altitude": 0,
      "latitude": 43.6866377,
      "longitude": -116.3516499,
      "device_identifier": "",
      "source": "gps",
      "heading": 0,
      "speed": 0,        
      "created": "2018-08-16T17:57:27+00:00"
    },
    ...
  }
}

Retrieves a list of geolocations associated with your company, with filters to narrow down the results.

HTTP Request

gethttps://rest.tsheets.com/api/v1/geolocations

Filter Parameters

ids
required (unless modified_before or modified_since is set)
Int Comma separated list of one or more geolocation ids you'd like to filter on. Only geolocations with an id set to one of these values will be returned.
modified_before
required (unless ids or modified_since is set)
String Only geolocations modified before this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm)
modified_since
required unless ids or modified_before is set)
String Only geolocations modified since this date/time will be returned, in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm)
user_ids
optional
Int A comma-separated list of user ids. Only geolocations linked to these users will be returned.
group_ids
optional
Int A comma-separated list of group ids. Only geolocations linked to users from these groups will be returned.
supplemental_data
optional
String 'yes' or 'no'. Default is 'yes'. Indicates whether supplemental data should be returned.
per_page
optional
Int Represents how many results you'd like to retrieve per request (page). Default is 50. Max is 50.
page
optional
Int Represents the page of results you'd like to retrieve. Default is 1.

Create Geolocations

Example: Create two new geolocations.

Request Body

{
  "data":
  [
    {
      "created": "2018-08-19T11:30:09-06:00",
      "user_id": 1242515,
      "accuracy": 20,
      "altitude": 0,
      "latitude": 43.68662580,
      "longitude": -116.35166460
    },
    {
      "created": "2018-08-19T12:38:56-06:00",
      "user_id": 1242515,
      "accuracy": 20,
      "altitude": 0,
      "latitude": 43.68692580,
      "longitude": -116.35169460
    }
  ]
}

Request

curl -X POST \
  https://rest.tsheets.com/api/v1/geolocations \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '<REQUEST BODY>'
var client = new RestClient("https://rest.tsheets.com/api/v1/geolocations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <TOKEN>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://rest.tsheets.com/api/v1/geolocations")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Authorization", "Bearer <TOKEN>")
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
  .url("https://rest.tsheets.com/api/v1/geolocations")
  .post(body)
  .addHeader("Authorization", "Bearer <TOKEN>")
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://rest.tsheets.com/api/v1/geolocations?modified_since=2018-08-01T12:00:00-06:00",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer <TOKEN>",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "<REQUEST BODY>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require("request");

var options = { method: 'POST',
  url: 'https://rest.tsheets.com/api/v1/geolocations',
  headers: 
   { 'Content-Type': 'application/json',
     'Authorization': 'Bearer <TOKEN>' },
  body: '<REQUEST BODY>',
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://rest.tsheets.com/api/v1/geolocations');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer <TOKEN>'
));

$request->setBody('<REQUEST BODY>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
require 'uri'
require 'net/http'

url = URI("https://rest.tsheets.com/api/v1/geolocations")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <TOKEN>'
request["Content-Type"] = 'application/json'
request.body = "<REQUEST BODY>"

response = http.request(request)
puts response.read_body
import requests

url = "https://rest.tsheets.com/api/v1/geolocations"

payload = "<REQUEST BODY>"
headers = {
    'Authorization': "Bearer <TOKEN>",
    'Content-Type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://rest.tsheets.com/api/v1/geolocations"

  payload := strings.NewReader("<REQUEST BODY>")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
import Foundation

let headers = [
  "Authorization": "Bearer <TOKEN>",
  "Content-Type": "application/json",
  "cache-control": "no-cache"
]
let parameters = <REQUEST BODY> as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(
  url: NSURL(string: "http://rest.tsheets.com/api/v1/geolocations")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0)

request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(
  with: request as URLRequest,
  completionHandler: {
    (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  }
)

dataTask.resume()
use REST::Client;

my $client = REST::Client->new();

$client->addHeader('Authorization', 'Bearer <TOKEN>');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = '<REQUEST BODY>';

$url="http://rest.tsheets.com/api/v1/geolocations"; 

$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');

Response Format

200 OK

{
  "results": {
    "geolocations": {
      "1": {
        "_status_code": 200,
        "_status_message": "Created",
        "id": 185899164,
        "user_id": 1242515,
        "accuracy": 20,
        "altitude": 0,
        "latitude": 43.6866258,
        "longitude": -116.3516646,
        "created": "2018-08-19T17:30:09+00:00"
    },
      "2": {
        "_status_code": 200,
        "_status_message": "Created",
        "id": 185899166,
        "user_id": 1242515,
        "accuracy": 20,
        "altitude": 0,
        "latitude": 43.6869258,
        "longitude": -116.3516946,
        "created": "2018-08-19T18:38:56+00:00"
      }
    }
  },
  "supplemental_data": {
    "": {
      "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": "",
        "hire_date": "2018-07-01",
        "term_date": "0000-00-00",
        "last_modified": "2018-07-12T15:52:00+00:00",
        "last_active": "2018-08-22T22:09:37+00:00",
        "created": "2018-05-28T20:23:44+00:00",
        "mobile_number": ""
      }
    }
  }
}

HTTP Request

posthttps://rest.tsheets.com/api/v1/geolocations

Properties

Pass an array of geolocation objects as the value to a 'data' property (see example).

user_id
required
Int User id for the user that this timesheet belongs to.
accuracy
required
Int Indicates the radius of accuracy around the geolocation in meters.
altitude
required
Float Indicates the altitude of the geolocation in meters. Enter 0 if altitude is unknown.
latitude
required
Float Indicates the latitude of the geolocation in degrees.
longitude
required
Float Indicates