Directory API: Mobile Devices

The Google Workspace Directory API allows you to manage mobile devices within your organization. This page includes examples of how to list your mobile devices, obtain details of a specific device, as well as adding or removing a device.

This document assumes you have successfully completed the Prerequisites. Android devices need to have the device policy app installed. iOS devices must be registered with the Google Mobile Management service.

In these examples, the placeholders customerId and resourceId are used to indicate where you would provide those IDs. The customerId can be obtained from the Users.get method. The resourceId is a unique Google identifier for a device and is found in the response of the Retrieve all mobile devices method.

Retrieve all mobile devices

To retrieve all of an account's mobile devices, use the following GET request and include the authorization described in Authorize requests. For readability, this example uses line returns:

GET https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}
  /devices/mobile?projection={BASIC|FULL}&query=query
  &orderBy=orderBy category&sortOrder={ASCENDING|DESCENDING}
  &pageToken=token for next results page
  &maxResults=max number of results per page

For the request and response properties, see the API Reference.

JSON response

{
   "kind": "directory#mobiledevices",
   "mobiledevices": [
    {
     "kind": "directory#mobiledevice",
     "resourceId": "resourceId",
     "deviceId": "deviceId",
     "name": [
      "Sales"
     ],
     "email": [
      "[email protected]"
     ],
     "model": "Nexus 4",
     "os": "Android 4.2.2",
     "type": "ANDROID",
     "status": "APPROVED",
     "hardwareId": "1234567890",
     "firstSync": "2013-05-15T17:30:04.325Z",
     "lastSync": "2013-06-05T17:30:04.325Z",
     "userAgent": "Google Apps Device Policy 4.14",
   },
   {
     "kind": "directory#mobiledevice",
     "resourceId": "resourceId",
     "deviceId": "deviceId",
     "name": [
      "Liz"
     ],
     "email": [
      "[email protected]"
     ],
     "model": "Galaxy Nexus",
     "os": "Android 4.2.2",
     "type": "ANDROID",
     "status": "APPROVED",
     "hardwareId": "9123456780",
     "firstSync": "2013-06-05T17:30:04.325Z",
     "lastSync": "2013-08-12T17:30:04.325Z",
     "userAgent": "Google Apps Device Policy 4.14",
    }
   ],
   "nextPageToken": "next_page_token_value"
  }

Retrieve a mobile device

To retrieve a mobile device's properties, use the following GET request and include the authorization described in Authorize requests. For readability, this example uses line returns:

GET https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}
  /devices/mobile/resourceId?projection={FULL|BASIC}

For the request and response properties, see the API Reference.

JSON request

An example request for the resourceId is:

GET https://admin.googleapis.com/admin/directory/v1/customer/my_customer/devices/
  mobile/resourceId?projection=FULL

JSON response

{
   "kind": "directory#mobiledevice",
   "resourceId": "resourceId",
   "deviceId": "deviceId",
   "name": [
    "Sales3"
   ],
   "email": [
    "[email protected]"
   ],
   "model": "Nexus 4",
   "os": "Android 4.2.2",
   "type": "ANDROID",
   "status": "APPROVED",
   "hardwareId": "1234567890",
   "firstSync": "2010-05-15T17:30:04.325Z",
   "lastSync": "2013-06-05T17:30:04.325Z",
   "userAgent": "Google Apps Device Policy 4.14",
  }

Approve a mobile device

To approve a mobile device, use the following POST request and include the authorization described in Authorize requests. For readability, this example uses line returns:

POST https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}
  /devices/mobile/resourceId/action

For the request and response properties, see the API Reference.

JSON request

The following JSON request shows a sample request to approve a device:

POST https://admin.googleapis.com/admin/directory/v1/customer/my_customer/devices
  /mobile/resourceId/action

The request body is:

{
    "action": "approve"
}

A successful request returns an HTTP 200 status code.

Remove a mobile device

To remove a mobile device, use the following DELETE request and include the authorization described in Authorize requests. For readability, this example uses line returns:

DELETE https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}
  /devices/mobile/resourceId

For the request and response properties, see the API Reference.

A successful request returns an HTTP 200 status code.