- WorkTrail API /
- Request Basics
Request Basics
Every request you send to WorkTrail's API backend has a couple of requirements. These are only documented here. All requests are POST requests with URLs below https://worktrail.net/rest/*
Authorization
Every request has to include 1.) Your App Identifier, 2.) Your secret API Key and 3.) an auth token which authorizes your app to access data from a specific company. These can be either passed in as HTTP header (preferred) or as POST parameters.
- HTTP Headers: X-APPKEY, X-SECRETAPIKEY, X-AUTHTOKEN
- POST Parameters: appkey=xxx&secretapikey=xxx&authtoken=xxx
In all successful calls you will receive back a JSON object.
Data Types
- ID: Except otherwise noted, are long integers. These are internal to WorkTrail and can be used to map your local data with WorkTrail's data. They are guaranteed to never change.
- Date/Time: Is always represented as Timestamp - Seconds since 1970-01-01 in GMT.
Lists
URLs which return a list of objects - for example the list of employees, tasks or projects will be paged if there are too many objects. So if you want to synchronize all tasks you have to page through an entire list.
{ "list": [ { ... }, { ... }, ], "num_pages": 1, "page": 1 }
If the list contains more items than are allowed per page, you have to send more requests adding a GET parameter to the URL called "page". So to send a second request ?page=2 than ?page=3 etc.
All objects will contain a "modifydate" property which can be used for synchronizing incremental changes. After the initial sync, always remember the biggest value of "modifydate" from all objects you have read. On your next sync simply include the get parameter "after".
Example
- Initial Sync - Requests to:
- /rest/workentries/?page=1&after=0
- /rest/workentries/?page=2&after=0
- etc.
- Than remember the largest value of 'modifydate' and pass it into the after parameter:
- /rest/workentries/?page=1&after=1328192707
- /rest/workentries/?page=1&after=1328192707
- etc