Method: enterprises.devices.issueCommand

Issues a command to a device. The Operation resource returned contains a Command in its metadata field. Use the get operation method to get the status of the command.

HTTP request

POST https://androidmanagement.googleapis.com/v1/{name=enterprises/*/devices/*}:issueCommand

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
name

string

The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.

Request body

The request body contains an instance of Command.

Response body

If successful, the response body contains an instance of Operation.

Authorization Scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/androidmanagement

For more information, see the OAuth 2.0 Overview.

Command

A command.

JSON representation
{
  "type": enum (CommandType),
  "createTime": string,
  "duration": string,
  "userName": string,
  "errorCode": enum (CommandErrorCode),
  "newPassword": string,
  "resetPasswordFlags": [
    enum (ResetPasswordFlag)
  ],
  "clearAppsDataParams": {
    object (ClearAppsDataParams)
  },
  "clearAppsDataStatus": {
    object (ClearAppsDataStatus)
  }
}
Fields
type

enum (CommandType)

The type of the command.

createTime

string (Timestamp format)

The timestamp at which the command was created. The timestamp is automatically generated by the server.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

duration

string (Duration format)

The duration for which the command is valid. The command will expire if not executed by the device during this time. The default duration if unspecified is ten minutes. There is no maximum duration.

A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

userName

string

The resource name of the user that owns the device in the form enterprises/{enterpriseId}/users/{userId}. This is automatically generated by the server based on the device the command is sent to.

errorCode

enum (CommandErrorCode)

If the command failed, an error code explaining the failure. This is not set when the command is cancelled by the caller.

newPassword

string

For commands of type RESET_PASSWORD, optionally specifies the new password.

resetPasswordFlags[]

enum (ResetPasswordFlag)

For commands of type RESET_PASSWORD, optionally specifies flags.

clearAppsDataParams

object (ClearAppsDataParams)

Parameters for the CLEAR_APP_DATA command to clear the data of specified apps from the device. See ClearAppsDataParams. If this is set, then it is suggested that type should not be set. In this case, the server automatically sets it to CLEAR_APP_DATA. It is also acceptable to explicitly set type to CLEAR_APP_DATA.

clearAppsDataStatus

object (ClearAppsDataStatus)

Output only. Status of the CLEAR_APP_DATA command to clear the data of specified apps from the device. See ClearAppsDataStatus.

CommandType

Types of commands.

Enums
COMMAND_TYPE_UNSPECIFIED This value is disallowed.
LOCK Lock the device, as if the lock screen timeout had expired.
RESET_PASSWORD Reset the user's password.
REBOOT Reboot the device. Only supported on fully managed devices running Android 7.0 (API level 24) or higher.
RELINQUISH_OWNERSHIP Removes the work profile and all policies from a company-owned Android 8.0+ device, relinquishing the device for personal use. Apps and data associated with the personal profile(s) are preserved. The device will be deleted from the server after it acknowledges the command.
CLEAR_APP_DATA Clears the application data of specified apps. This is supported on Android 9 and above. Note that an application can store data outside of its application data, for example in external storage or in a user dictionary. See also clearAppsDataParams.

CommandErrorCode

A command error code.

Enums
COMMAND_ERROR_CODE_UNSPECIFIED There was no error.
UNKNOWN An unknown error occurred.
API_LEVEL The API level of the device does not support this command.
MANAGEMENT_MODE The management mode (profile owner, device owner, etc.) does not support the command.
INVALID_VALUE The command has an invalid parameter value.
UNSUPPORTED The device doesn't support the command. Updating Android Device Policy to the latest version may resolve the issue.

ResetPasswordFlag

Flags that can be used for the RESET_PASSWORD command type.

Enums
RESET_PASSWORD_FLAG_UNSPECIFIED This value is ignored.
REQUIRE_ENTRY Don't allow other admins to change the password again until the user has entered it.
DO_NOT_ASK_CREDENTIALS_ON_BOOT Don't ask for user credentials on device boot.
LOCK_NOW Lock the device after password reset.

ClearAppsDataParams

Parameters associated with the CLEAR_APP_DATA command to clear the data of specified apps from the device.

JSON representation
{
  "packageNames": [
    string
  ]
}
Fields
packageNames[]

string

The package names of the apps whose data will be cleared when the command is executed.

ClearAppsDataStatus

Status of the CLEAR_APP_DATA command to clear the data of specified apps from the device.

JSON representation
{
  "results": {
    string: {
      object (PerAppResult)
    },
    ...
  }
}
Fields
results

map (key: string, value: object (PerAppResult))

The per-app results, a mapping from package names to the respective clearing result.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

PerAppResult

The result of an attempt to clear the data of a single app.

JSON representation
{
  "clearingResult": enum (ClearingResult)
}
Fields
clearingResult

enum (ClearingResult)

The result of an attempt to clear the data of a single app.

ClearingResult

The result of an attempt to clear the data of a single app.

Enums
CLEARING_RESULT_UNSPECIFIED Unspecified result.
SUCCESS This app’s data was successfully cleared.
APP_NOT_FOUND This app’s data could not be cleared because the app was not found.
APP_PROTECTED This app’s data could not be cleared because the app is protected. For example, this may apply to apps critical to the functioning of the device, such as Google Play Store.
API_LEVEL This app’s data could not be cleared because the device API level does not support this command.