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)
  ]
}
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, accurate to nanoseconds. Example: "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.

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 API level 24+.

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.

Try it!