REST API
The Mobile Gateway provides different APIs to manage the users and their enrollment info.
- Retrieving all security groups and their users
- Adding / Removing a user from a security group
- Generating an enrollment code for a given user
- Disenrolling a user from a single device or from all its devices
Deployment URL
URL of the mobile gateway depends on the deployment, but will typically be:
https://{hostname}/sense/secserverPaths documented will be relative to this deployment base URL.
The APIs' base path correspond to a fixed "/api/rest" prefix, followed by the role that has access to the function (eg. "/provisioner").
The domain is implicitly defined by the user's authorization. Username must not include the domain (it is only provided in the EnrollmentInfo object since it should be encoded in a QRCode and scanned on the client which doesn't know the domain).
Authentication
All API described in this chapter are protected with HTTP Basic authentication. Credentials consist to the username and the password of a valid administrator account on the SENSE server.
References
Get all users
GET /api/rest/provisioner/users?enrollmentCodeExpirationTimeAfter={enrollmentCodeExpirationTimeAfter}&enrollmentCodeExpirationTimeBefore={enrollmentCodeExpirationTimeBefore}
PATH VARIABLES
| enrollmentCodeExpirationTimeAfter | Long (optional): milliseconds since Unix epoch. |
|---|---|
| enrollmentCodeExpirationTimeBefore | Long (optional): milliseconds since Unix epoch. |
RESPONSE
[ { "username" : "username", "enrollmentInfo" : null }, { "username" : "username2", "enrollmentInfo" : { "code" : "XF45-F29Z", ... }, ... ]RESPONSE STATUS CODE
| 200 | OK |
|---|
Get a single user
GET /api/rest/provisioner/users/{username}
PATH VARIABLES
| username | String: user's username. |
|---|
RESPONSE
{ "username" : "username", "enrollmentInfo" : { "code" : "XF45-F29Z", "validUntil": 1521767010211, "serverUrl" : "https://server/sense/appserver/Server", "username" : "username@domain" } }RESPONSE STATUS CODE
| 200 | OK |
|---|---|
| 404 | User does not exist |
Get all groups
GET /api/rest/admin/groups
RESPONSE
[ { "id" : "26088441-82ad-4db0-8a4d-d67fdbc6fc98", "name" : "My users" }, { "id" : ... }, ... ]RESPONSE STATUS CODE
| 200 | OK |
|---|
Add a single user
POST /api/rest/admin/users
BODY
{ "username" : "username", "groupId" : "26088441-82ad-4db0-8a4d-d67fdbc6fc98" }DETAILS
| username | String: username of the user to create. |
|---|---|
| groupId | String: Id of the group in which the user will be created. |
RESPONSE STATUS CODE
| 201 | User created. |
|---|---|
| 409 | User already exists. |
Delete a single user
DELETE /api/rest/admin/users/{username}
PATH VARIABLES
| username | String: user's username. |
|---|
RESPONSE STATUS CODE
| 204 | User deleted. |
|---|---|
| 404 | User does not exist. |
Enable enrollment for a user
PATCH /api/rest/provisioner/users/{username}
API is also reachable with POST method by adding an extra HTTP header X-HTTP-Method-Override: PATCH.
PATH VARIABLES
| username | String: user's username. |
|---|
BODY
{ "enrollmentInProgress" : true }RESPONSE
{ "username" : "username", "enrollmentInfo" : { "code" : "XF45-F29Z", "validUntil": 1521767010211, "serverUrl" : "https://server/sense/appserver/Server", "username" : "username@domain" } }RESPONSE STATUS CODE
| 200 | Enrollment enabled. |
|---|---|
| 404 | User does not exist. |
| 428 | Enrollment is not allowed for the given user. |
Enrollment info as object
GET /api/rest/provisioner/users/{username}/enrollmentInfo
PATH VARIABLES
| username | String: user's name (without the domain). |
|---|
RESPONSE
{ "code" : "XF45-F29Z", "validUntil": 1521767010211, "serverUrl" : "https://server/sense/appserver/Server", "username": "username@domain" }RESPONSE STATUS CODE
| 200 | OK |
|---|---|
| 404 | User does not exist or enrollment info have expired. |
| 428 | Enrollment is not enabled for the given user. |
Enrollment info as QR Code PNG
GET /api/rest/provisioner/users/{username}/enrollmentInfo?format=QRCode&width={width}&height={height}
PATH VARIABLES
| username | String: user's name (without the domain). |
|---|---|
| format | String (optional): "QRCode" when enrollment info must be provided as a QR code. Related parameters: |
| width | Long (optional): QR code's width in pixels (default: 300). |
| height | Long (optional): QR code's height in pixels (default: 300). |
RESPONSE
RESPONSE STATUS CODE
| 200 | OK |
|---|---|
| 404 | User does not exist or enrollment info have expired. |
| 428 | Enrollment is not enabled for the given user. |
Disable enrollment
PATCH /api/rest/provisioner/users/{username}
API is also reachable with POST method by adding an extra HTTP header X-HTTP-Method-Override: PATCH.
PATH VARIABLES
| username | String: user's username. |
|---|
BODY
{ "enrollmentInProgress" : false }RESPONSE
{ "enrollmentInfo" : null }RESPONSE STATUS CODE
| 200 | Enrollment disabled. |
|---|---|
| 404 | User does not exist. |
Get all enrollment data for a given user
GET /api/rest/provisioner/users/{username}/enrollmentData?creationTimeAfter={creationTimeAfter}&creationTimeBefore={creationTimeBefore}&mobileApplicationIdentifier={mobileApplicationIdentifier}
PATH VARIABLES
| username | String: user's username. |
|---|
REQUEST PARAMETERS
| creationTimeAfter | Long (optional): milliseconds since Unix epoch. |
|---|---|
| creationTimeBefore | Long (optional): milliseconds since Unix epoch. |
| mobileApplicationIdentifier | String (optional): the mobile application identifier. |
REQUEST HEADERS
| x-hex-encoded-username | Boolean (optional): true if the username is hexadecimal encoded (default: false) |
|---|
RESPONSE
[ { "id" : "1234abcd", "username" : "username", "creationTime" : 1484960610593, "deviceModel" : "samsung GT-I9505", "deviceName" : "Galaxy S4", "osVersion" : "5.0.1", "operatingSystem" : "ANDROID", "enabled" : true }, { "id" : "5678efgh", ... }, ... ]RESPONSE STATUS CODE
| 200 | OK |
|---|---|
| 404 | User does not exist |
Get all enrollment data
GET /api/rest/provisioner/enrollmentData?creationTimeAfter={creationTimeAfter}&creationTimeBefore={creationTimeBefore}&mobileApplicationIdentifier={mobileApplicationIdentifier}
REQUEST PARAMETERS
| creationTimeAfter | Long (optional): milliseconds since Unix epoch. |
|---|---|
| creationTimeBefore | Long (optional): milliseconds since Unix epoch. |
| mobileApplicationIdentifier | String (optional): the mobile application identifier. |
RESPONSE
RESPONSE STATUS CODE
| 200 | OK |
|---|
Disenroll app
DELETE /api/rest/provisioner/users/{username}/enrollmentData/{id}
PATH VARIABLES
| username | String: user's username. |
|---|---|
| id | String: enrollmentData's id. |
RESPONSE STATUS CODE
| 204 | App has been disenrolled. |
|---|---|
| 404 | User or enrollmentData not found. |
Disenroll all apps
DELETE /api/rest/provisioner/users/{username}/enrollmentData
PATH VARIABLES
| username | String: user's username. |
|---|
RESPONSE STATUS CODE
| 204 | All apps have been disenrolled. |
|---|---|
| 404 | User does not exist. |
Send a notification to all devices of the user
POST /api/rest/provisioner/users/{username}/notification
PATH VARIABLES
| username | String: user to be notified. |
|---|
BODY
PushNotificationMessage
{
"notificationTitle" : "notificationTitle", <1>
"notificationBody" : "notificationBody", <2>
"localizedNotificationTitleKey" : "localizedNotificationTitleKey", <3>
"localizedNotificationTitleArgs" : ["arg1", "arg2"] <4>
"localizedNotificationBodyKey": "localizedNotificationBodyKey" <5>
"localizedNotificationBodyArgs": ["arg1", "arg2"] <6>
"backgroundNotification" : false <7>
"data": {"key1": "value1", "key2": "value2"} <8>
"badge": 123456 <9>
}- The title of the notification
- The body of the notification
- The key for localized notification title
- Arguments for localized notification title
- The key for localized notification body
- Arguments for localized notification body
- Default false, specifies if the notification should be handled by the app itself
- Additional data for the notification
- Badge number for the notification
DETAILS
| message | PushNotificationMessage: Represents a push notification message |
|---|
RESPONSE STATUS CODE
| 204 | All users' devices have been notified. |
|---|---|
| 404 | User not found. |
Send a notification to a specific user's device
POST /api/rest/provisioner/users/{username}/enrollmentData/{enrollmentDataId}/notification
PATH VARIABLES
| username | String: user to be notified. |
|---|---|
| username | authenticationHash: the enrolled device reference |
BODY
PushNotificationMessage
{
"notificationTitle" : "notificationTitle", <1>
"notificationBody" : "notificationBody", <2>
"localizedNotificationTitleKey" : "localizedNotificationTitleKey", <3>
"localizedNotificationTitleArgs" : ["arg1", "arg2"] <4>
"localizedNotificationBodyKey": "localizedNotificationBodyKey" <5>
"localizedNotificationBodyArgs": ["arg1", "arg2"] <6>
"backgroundNotification" : false <7>
"data": {"key1": "value1", "key2": "value2"} <8>
"badge": 123456 <9>
}- The title of the notification
- The body of the notification
- The key for localized notification title
- Arguments for localized notification title
- The key for localized notification body
- Arguments for localized notification body
- Default false, specifies if the notification should be handled by the app itself
- Additional data for the notification
- Badge number for the notification
DETAILS
| message | PushNotificationMessage: Represents a push notification message |
|---|
RESPONSE STATUS CODE
| 204 | Specific user's device have been notified. |
|---|---|
| 404 | User not found. |
| 404 | Enrollment data not found for specified user |