API Tokens
In the API Tokens page you can list, create, edit, delete and revoke API Tokens.
The table lists all the API Tokens for selected Scopes that are available for the current User. The table shows the name, GUID, Active from date, Expiration date, and Token status information (Is active column). You can filter the content in the table by name, Token, Asset(s) and Token status filters.
In the Name search filter you can search by one or more keywords and filter your Tokens by name. In the Token search filter you can search tokens by Token. You can easily copy Token’s token GUID by clicking the button, right next to the Token value in the Token column. In the Assets filter, the user can filter the Tokens by the asset scopes that are assigned to the current User. In the Token status filter the user can filter the Tokens by their status (Active or Inactive). You can sort the table content by Name and by Is active columns.
Create token
If you click the button a popup form appears
Name and Assets fields are required. Token field is automatically populated and disabled, it cannot be edited. In order to copy the Token GUID value click on the button. If you want to regenerate a new Token GUID value, click on the button. Description, Valid from and Valid to fields are optional. If you create a token without Valid from and Valid to values, the token is active from the moment of creation and will be active forever. Past dates in the calendar menu are disabled.
button will be disabled if you haven’t populated the required fields, or you have entered invalid dates in the Valid from and Valid to fields. After you are done configuring the token save the token by clicking the button or to discard the configuration.
Edit token
To edit a token, click the button after which a filled form will appear in which you can make the changes.
Delete token
To remove a token, click the button after which a confirmation popup window will appear. If confirmed, the Token will be deleted.
Revoke token
To revoke a token, click the button after which a confirmation pop-up window will appear. If confirmed, the Token will be revoked. When you revoke a token, it goes to inactive state and sets the Valid to value to current date and time. When token is inactive, Revoke button is disabled ().
Usage of API Tokens
Latest Values of Tags
You can use API Tokens in API requests by tool for API requests. In order to get the latest values for selected tags in the token,
a GET request should be made to URL https://api.qlarm.com/api/apiTokenAccess/getTagsByToken with two request headers:
header name: “Tenant”, header value: (e.g.)“Tenant_name” and
header name: “ApiToken”, header value: (e.g. see Fig 1)“7c9fc2bf-f94a-b554-6b75-9d4ff6b5025d”.
ApiToken header value can be copied from Qlarm API Tokens page. Using this getTagsByToken API request, the user will be able to get the latest values for token’s selected tags, in the response.
Historical Values of Tags
You can use API Tokens in API requests by tool for API requests. There are two steps to getting historical values for a tag in the token.
First, a GET request should be made to the URL https://api.qlarm.com/odata/tags with two request headers:
header name: “Tenant”, header value: (e.g.)“Tenant_name” and
header name: “ApiToken”, header value: (e.g.) “e137764a-585c-4614-a34d-2d3cac0f062b”.
Second, get the id from the tag you would like to see historical values. Then convert your startTime and endTime to UTC time. You can use this converter for the time. Finally, a GET request should be made to the URL https://api.qlarm.com/odata/data(TagId='tagId',TimeFrom='startTime',TimeTo='endTime') with the following parameters:
parameter tagId: should be the id from the tag, (e.g.) 0d302e53-c505-4792-a89e-46b5138d9dd3
parameter startTime: should be the starting date in UTC time, formatted 2023-06-30 00:00:00
parameter endTime: should be the ending date in UTC time, formatted 2023-07-31 00:00:00
Historical value is limited to show results from the last year. Ensure the dates that are entered are within the past 365 days.