API Overview
General Purpose of the Safe API
Tracker clients will generally use the API for the following tasks.
- Creating, Updating or Reading system User Accounts (User Admin)
- Creating, Updating or Reading Case information
- Creating, Updating or Reading Person information
- Reading new Items information
- Reading updated items information
Note: We do not support injecting item information via the API. Items must always be created via the Item entry or Data Import areas.
Note: While there are many other systems API's, the ones we are listing here are those that are generally used..
Setting a Static Token for use with Tracker API
Each request made to the SAFE webAPI will require the following
- Valid URL (https://securelb.trackerproducts.com/api/items/seqOrgID/1) [The 1 in this line is the sequentialOrgID you are referencing)
- Valid user token (See instructions below for getting this)
- Valid OrgID # (See instructions below for getting this)
- Valid Office ID # (See instructions below for getting this)
Getting a valid User Token
- Go to Settings -> Users
- Select a user in which to create a static token for, and select ‘Edit’ (Or you may want to create a new user for this process)
- At the bottom of the edit screen will be the token create section:
- Press ‘Generate’ to create the token.
Setting a Static License
In most cases, you are going to want to peg a license to the user that was created in the previous step. This will ensure that a license is available when the interface makes a call to the SAFE webAPI. If not license is available, then the API will respond with a message that no licenses are available.- Go to Settings > License Allocation
- In the column ‘Reserved for Individual Users’ find the user you created for the API and then select the ‘No’ value to set a license.
Warning Making an API call to the database more than once a minute will most likely cause your account to be disabled. It is highly recommended that you make (or schedule) your call every 10 minutes or so.
Testing the Tracker API
- The user can test communicating to the Tracker API using Postman in Chrome, or any similar tool. The following example is using Postman:
- Header Fields
- Accept application/json – required field
- Content-Type application/x-www-form-urlencoded – required field
- Authorization – This field requires the word ‘Bearer’ followed by a single space and then the static token that was created.
- OrganizationId – the organization ID to use
- OfficeId – the office ID to use
- StaticToken – tells the API that the bearer token is static
- Once these fields are in place, select ‘Send’ and verify that an item was returned (if one exists).
Note: make sure you have a valid item in the system before you try to select one from the webAPI.
RetrievingPOST or GET Data from API
Retrieving Custom Data – Formdata Controller
Where XXXXX = the "id" value that is provided in the seqOrgID controller listed above
This Formdata controller will come back with every custom data form and field that is attached to this item. { "id": "5750570d1b5c6008e8e4fcec", "active": true, "entityId": 994601, "formId": 1, "formName": "Drug Form Sys Template", "dateFields": null, "data": "{ \"field2849\" : \"1\", \"field7312\" : \"1\", \"field5100\" : true, \"field7289\" : true, \"field6199\" : 1, \"field5088\" : 2, \"field5091\" : 3, \"field5094\" : 4, \"field5097\" : 5, \"field5970\" : 6 }", "organizationId": 1, "officeId": 1, "visibilityId": 1 } ]
The data you are looking for is in the “Data” section.
Retrieving Case Data
Where XXXXX = the "PrimaryCaseID" value that is provided in the seqOrgID controller listed above
Retrieving People in a Case
Where XXXXX = the "PrimaryCaseID" value that is provided in the seqOrgID controller listed above
Retrieving Chain of Custody
Where XXXXX = the "id" value that is provided in the seqOrgID controller listed above
Writing Data to API (Posting)
Case Data Post
Required fields:
- CaseOfficerId [long]
- OffenseTypeId [long]
- CaseNumber [string]
- FormData [List]
- FormId [long]
- Data [string]
- Tags [List]
- tagModelId [long]
- Name [string]
Optional:
- OffenseDescription [string]
- OffenseLocation [string]
- OffenseDate
Required fields:
Optional:
Required fields:
Returns:
Person Data Post
API URL - https://securelb.trackerproducts.com/api/people
This is a test of the Item Update
Retrieving an Updated Item
API URL - https://securelb.trackerproducts.com/api/items/seqUpdateOrgId/XXXXX
The seqUpdateOrgId here is the ID of the Item update history entry. It starts from 1 and is incremented. Please note, that the return value is the current state of the Item!