4SITE API Integrations

 

Machine Authorization Guide

 

Instructions:

 

1. For each machine, a static API key will be assigned which is constant for all the calls.

2. As of now, Machine auth is only enabled for the below endpoint:

GET "/clients/<client_id>/sensors/last_motion_machine"

3. API key can be set to active/inactive.

 

GET last motion API:

Endpoint:

GET "/clients/<client_id>/sensors/last_motion_machine"
Parameters:

a. ‘building_id’ and ‘floor_id’ (floor_id is optional here)

This will return the last motion detection for this building and floor.

Note: If no last motion was detected for a sensor, last_motion_detect will be shown as “null”

 
Example:
API last motion detected screenshot

b. ‘asset_id’

This will return the last motion detection for this asset.

c. ‘tag_name’

This will return the last motion detection for this tag name.

d. Date time ‘to’ and ‘from’

This will return the last motion detection between a selected date range.

 
Example parameter:
API last motion detected between selected dates screenshot

e. No Parameter

This will return the last motion detection for all sensors under this client.

 

Headers (Important):

This Endpoint will only work if you provide machine registered token in x-api-token
For example:

x-api-token : <registered machine token>

How can you create this token? This is described below.

CREATING AND MANAGING THE MACHINE TOKEN:

 

Endpoints:

1.

POST "/clients/<client_id>/machine_authorization":

This will create an API key for a client machine.
Body will be:

{"status" : "active/inactive"}

2.

GET "/clients/<client_id>/machine_authorization/<authorization_id>":

This will give the details of a particular API key.

3.

DELETE "/clients/<client_id>/machine_authorization/<authorization_id>":

This will delete the API key for that machine permanently.

4.

PATCH "/clients/<client_id>/machine_authorization/<authorization_id>":

This will update the status of a machines API key to active/inactive.