Managing Tenants Using the REST API
This article describes how to add users to tenants, remove users from tenants, or edit the tenant configuration using the REST API.
Note: Tenants can also be managed via the Video Feeds tab of the Web Console.
Get Current Tenants Information
To get a list of all the users of a tenant, run the following command:
curl -X GET ""http://safr_server_address:8080/covi-ws/config/tenants"" -H ""accept: application/json;charset=UTF-8"" -H ""Authorization: main"" -H ""X-RPC-AUTHORIZATION: userid:pwd""
Add A User to a Tenant
To add a new user to a tenant, run the following command:
curl -X PUT ""http://safr_server_address:8080/covi-ws/admin/users"" -H ""accept: */*"" -H ""Authorization: main"" -H ""X-RPC-AUTHORIZATION: userid:pwd"" -H ""Content-Type: application/json;charset=UTF-8"" -d ""{\""users\"":[{\""userId\"":\""username\"",\""tenantId\"":\""tenantname\"",\""password\"":\""userpassword\"",\""roles\"":[\""roles assigned to user\""]}]}""
Get Current User Roles
To get a list of the current user roles, run the following command:
curl -X GET ""http://safr_server_address:8080/covi-ws/admin/roles"" -H ""accept: application/json;charset=UTF-8"" -H ""Authorization: main"" -H ""X-RPC-AUTHORIZATION: userid:pwd""
Remove A User From a Tenant
To remove a user from a tenant, run the following command:
curl -X DELETE ""http://safr_server_address/covi-ws/admin/user/username"" -H ""accept: */*"" -H ""Authorization: main"" -H ""X-RPC-AUTHORIZATION: userid:pwd""
Add or Edit A Tenant Configuration
To create a tenant configuration or edit an existing tenant configuration, run the following command:
curl -X PUT ""http://safr_server_address:8080/covi-ws/config/tenants"" -H ""accept: */*"" -H ""Authorization: main"" -H ""X-RPC-AUTHORIZATION: userid:pwd"" -H ""Content-Type: application/json;charset=UTF-8"" -d ""{\""tenants\"":[{\""tenantId\"":\""tenantname\"",\""eventArchiveTimeLimit\"":30,\""personRetentionLimits\"":[{\""retentionDuration\"":0,\""directories\"":[\""main\""],\""personTypes\"":[\""employee\""],\""hasName\"":true,\""hasExternalId\"":true}]}]}""
Note: The following configuration settings are optional and can be omitted from the curl command:
- eventArchiveTimeLimit
- directories
- personTypes
- hasName
- hasExternalId
Delete A Tenant Configuration
To delete a tenant configuration, run the following command:
curl -X DELETE ""http://safr_server_address/covi-ws/config/tenant/test"" -H ""accept: application/json;charset=UTF-8"" -H ""Authorization: main"" -H ""X-RPC-AUTHORIZATION: userid:pwd""