---
title: "Save and trigger a command"
method: POST
path: "/rest/manager/command/save"
tags: ["Command APIs"]
---

# Save and trigger a command

`POST /rest/manager/command/save`

## Request

- Base URL: `https://masonconsole.com`
- URL: `https://masonconsole.com/rest/manager/command/save`
- Auth: HTTP bearer

This API endpoint allows for the creation and saving of a new command. It takes a `Command` object as the request body which includes the execution condition as set in the reference trigger and returns the unique identifier (`commandID`) of the newly created command.

## Request body

- Command
  - `id` string: The unique identifier for the command.
  - `creationTime` string, date-time: The date and time when the command was created.
  - `ownerUserName` string: The username of the owner of the command.
  - `domain` string: The domain associated with the command.
  - `commandData` union
    - object
      - `@class` string, required
      - `advancedMessagingItem` AdvancedMessagingItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `bodyText` string
        - `image` AssetsItem
          - `repositoryItemId` string
          - `repositoryItemName` string
          - `repositoryItemDesc` string
          - `domain` string
          - `owner` string
          - `color` string
          - `fontIcon` string
          - `creationDate` string, date-time
          - `moreData` object
          - `privateRepoItem` boolean
          - `url` string
          - `type` string
          - `thumbnail` string
          - `properties` object
        - `audio` AssetsItem
          - `repositoryItemId` string
          - `repositoryItemName` string
          - `repositoryItemDesc` string
          - `domain` string
          - `owner` string
          - `color` string
          - `fontIcon` string
          - `creationDate` string, date-time
          - `moreData` object
          - `privateRepoItem` boolean
          - `url` string
          - `type` string
          - `thumbnail` string
          - `properties` object
        - `stretchImage` boolean
        - `horizontal` boolean
        - `audioLoop` boolean
        - `withTimeout` boolean
        - `timeOut` integer
        - `textColor` string
        - `webUrl` string
        - `youtubeLoop` boolean
        - `htmlCode` string
        - `embedUrl` string
        - `embedType` string
        - `youtubeBaseUrl` string
        - `youtubeId` string
        - `advMsgType` string
    - object
      - `@class` string, required
      - `mcmId` string
      - `productId` string
      - `productTitle` string
      - `isApply` boolean
      - `configurationName` string
    - object
      - `@class` string, required
      - `products` string[]
      - `productSetBehavior` string
    - object
      - `@class` string, required
      - `products` string[]
      - `isInstall` boolean
    - object
      - `@class` string, required
      - `message` string
      - `emails` string[]
    - object
      - `@class` string, required
      - `packageName` string
      - `packageID` string
    - object
      - `@class` string, required
      - `packages` string[]
    - object
      - `@class` string, required
      - `path` string
      - `urlPut` string
      - `urlGet` string
      - `collectLogFile` boolean
    - object
      - `@class` string, required
      - `name` string
      - `description` string
      - `type` string
      - `values` object
    - object
      - `@class` string, required
      - `customPlistItem` CustomPlistItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `values` object
    - object
      - `@class` string, required
      - `depProfileItem` DepProfileItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `values` object
        - `serverid` string
    - object
      - `@class` string, required
      - `packageName` string
      - `enablePackage` boolean
      - `packageID` string
    - object
      - `@class` string, required
      - `enablePackage` boolean
      - `packages` string[]
    - object
      - `@class` string, required
      - `start` string
      - `end` string
    - object
      - `@class` string, required
      - `hide` boolean
    - object
      - `@class` string, required
    - object
      - `@class` string, required
      - `props` object
      - `metaData` object
    - object
      - `@class` string, required
      - `lock_message` string
      - `lock` boolean
    - object
      - `@class` string, required
      - `user` string
      - `action` string
    - object
      - `@class` string, required
    - object
      - `@class` string, required
      - `title` string
      - `message` string
    - object
      - `@class` string, required
      - `remoteExecItem` RemoteExecItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `command` string
        - `args` string[]
        - `authority` string
        - `waitForExit` boolean
        - `collectOutput` boolean
        - `maxOutSize` integer
        - `successCode` integer
        - `isScript` boolean
        - `props` object
    - object
      - `@class` string, required
      - `remoteSettingsBundles` RemoteSettingsBundle[]
        - `settingsBundleId` string
        - `settingsBundleName` string
        - `description` string
        - `domain` string
        - `owner` string
        - `settingsType` string
        - `color` string
        - `fontIcon` string
        - `privateRepoItem` boolean
        - `moreData` object
        - `remoteSettingsItems` RemoteSettingsItem[]
          - union
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
        - `creationDate` string, date-time
    - object
      - `@class` string, required
      - `removeType` string
      - `accountType` string
      - `accounts` string[]
    - object
      - `@class` string, required
    - object
      - `@class` string, required
    - object
      - `@class` string, required
      - `inputSource` string
      - `volume` integer
      - `brightness` integer
    - object
      - `@class` string, required
      - `repositoryFileMetaData` RepositoryFileMetaData
        - `repositoryFileMetaDataID` string
        - `fileID` string
        - `fileName` string
        - `fileLocation` string
        - `ownerUser` string
        - `ownerDomain` string
        - `lastEditorUser` string
        - `privateFile` boolean
        - `fileDesc` string
        - `fileAction` string
        - `arguments` string
        - `properties` object
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `lastUpdate` string, date-time
    - object
      - `@class` string, required
      - `otaItem` OTAItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `properties` object
        - `version` string
        - `url` string
        - `hash` string
        - `hashType` string
        - `fileSize` integer
        - `fileName` string
        - `precedingMin` string
        - `precedingMax` string
        - `models` string
        - `versionPattern` string
        - `verPropPath` string
    - object
      - `@class` string, required
      - `policy` Policy
        - `policyId` string
        - `policyName` string
        - `description` string
        - `policyType` string
        - `triggerId` string
        - `fontIcon` string
        - `color` string
        - `properties` object
        - `creationDate` string, date-time
        - `privateRepoItem` boolean
        - `policySubCatagories` object
        - `policyTrigger` PolicyTrigger
        - `domain` string
        - `owner` string
      - `trigger` Trigger
        - `triggerId` string
        - `triggerName` string
        - `description` string
        - `domain` string
        - `owner` string
        - `triggerData` TriggerData
          - `execCondition` string
          - `execConditionSuccessCode` integer
          - `execConditionScript` boolean
          - `@class` string, required
        - `creationDate` string, date-time
        - `privateRepoItem` boolean
        - `color` string
        - `fontIcon` string
    - object
      - `@class` string, required
      - `prefsMap` object
    - object
      - `@class` string, required
      - `password` string
    - object
      - `@class` string, required
    - object
      - `@class` string, required
    - object
      - `@class` string, required
      - `smartRecoveryItem` SmartRecoveryItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `model` string
        - `smartRecoveryAction` SmartRecoveryActionBase
          - `restart` boolean
          - `@class` string, required
    - object
      - `@class` string, required
      - `packageName` string
      - `packageID` string
    - object
      - `@class` string, required
      - `packageName` string
      - `packageID` string
    - object
      - `@class` string, required
    - object
      - `@class` string, required
    - object
      - `@class` string, required
      - `packageName` string
      - `packageID` string
    - object
      - `@class` string, required
      - `packages` string[]
    - object
      - `@class` string, required
      - `deviceIDs` string[]
      - `deviceFilters` string[]
      - `macAddressToWake` string[]
      - `broadcastAddress` string
      - `port` integer
    - object
      - `@class` string, required
      - `wbList` WifiWBListEntry[]
        - `networkSSID` string
        - `allow` boolean
        - `networkPSK` string
    - object
      - `@class` string, required
      - `networkSSID` string
      - `networkPass` string
      - `securityProtocol` string
    - object
      - `@class` string, required
      - `wipe_message` string
    - object
      - `@class` string, required
      - `workFlowItem` WorkFlowItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `workflowList` WorkFlowListEntry[]
          - `commandName` string
          - `commandData` CommandData (recursive)
          - `wait` boolean
          - `stopOnFailure` boolean
          - `desc` string
          - `color` string
          - `owner` string
          - `privateRepoItem` boolean
          - `missingRepo` boolean
    - object
      - `@class` string, required
      - `waitSeconds` integer
    - object
      - `@class` string, required
      - `filesBundleRepoItem` FilesBundleRepoItem
        - `repositoryItemId` string
        - `repositoryItemName` string
        - `repositoryItemDesc` string
        - `domain` string
        - `owner` string
        - `color` string
        - `fontIcon` string
        - `creationDate` string, date-time
        - `moreData` object
        - `privateRepoItem` boolean
        - `filesBundleId` string
        - `destPath` string
        - `files` string[]
        - `bundleUrl` string
        - `properties` object
    - object
      - `@class` string, required
      - `message` string
      - `duration` 'SHORT' | 'LONG'
    - object
      - `@class` string, required
    - object
      - `@class` string, required
      - `intentAction` string: The action of the intent to be sent. This action shall be filtered and handled by the receiver app.
      - `packageName` string: The package name to which the intent will be sent. Omitting this will send a public broadcast.
      - `componentName` string: The component name to which the intent will be sent. Omitting this will send a broadcast to the entire app.
      - `declaredPermission` string: The declared permission for the intent action. The receiving app must declare this permission and be signed with the same key as the MDM agent app.
      - `intentExtras` object: Extra fields to be included with the intent.
      - `waitForResponse` boolean: Whether the MDM agent needs to listen for a broadcast intent as a response. If true, a 'commandId' will be added to the broadcast intent as an extra. The response intent should be sent by the receiver with the action 'com.viso.mdm.COMMAND_BROADCAST_RECEIVER' and it must include the 'commandId' as an extra. If permission is enforced in the response, the response intent must be sent with the permission 'com.viso.mdm.COMMAND_BROADCAST_PERMISSION'.
    - object
      - `@class` string, required
      - `downloadUrl` string
      - `uploadUrl` string
      - `uploadTest` boolean
      - `downloadTest` boolean
      - `pingTest` boolean
  - `trigger` Trigger
    - `triggerId` string
    - `triggerName` string
    - `description` string
    - `domain` string
    - `owner` string
    - `triggerData` TriggerData
      - `execCondition` string
      - `execConditionSuccessCode` integer
      - `execConditionScript` boolean
      - `@class` string, required
    - `creationDate` string, date-time
    - `privateRepoItem` boolean
    - `color` string
    - `fontIcon` string
  - `description` string: A description of the command.
  - `filterId` string: The ID of the filter associated with the command.
  - `currentDevices` string[]: The list of devices currently targeted by the command.
  - `state` string: The state of the command.
  - `notifiedUsers` string[]: A set of usernames representing users who have been notified about the command.
  - `notifyDirty` boolean: Flag indicating whether the command has unsaved changes.
  - `lastChange` string, date-time: The date and time of the last change to the command.
  - `failureCount` integer: The count of failures associated with the command.
  - `successCount` integer: The count of successful executions of the command.
  - `sentCount` integer: The count of times the command has been sent.
  - `executedCount` integer: The count of times the command has been executed.
  - `readyCount` integer: The count of devices ready to receive the command.
  - `persist` boolean: Flag indicating whether the command should be persisted for future reference.
  - `persistentGroupID` string: The ID of the persistent group associated with the command.
  - `persistentGroupName` string: The name of the persistent group associated with the command.
  - `props` object: Additional properties associated with the command.
  - `lastCommandStatus` CommandStatus: A list of command statuses.
    - `id` string
    - `commandid` string
    - `date` string, date-time
    - `status` 'PENDING' | 'sent' | 'READY' | 'UPDATE_SENT' | 'EXECUTED' | 'FAILURE': Status of the command: - PENDING: The device is offline and has not received the command yet. - sent: Command was sent to the device. - READY: Command is scheduled for later but has not been executed yet. - UPDATE_SENT: Scheduled command has been changed. - EXECUTED: Command has been executed. - FAILURE: Command was executed but failed.
    - `note` string: General note about the status of the command.
    - `deviceid` string
    - `properties` object
    - `additionalprops` object

## Response `200`

Successful response

- SaveCommandResponse
  - `data` SaveCommandData: The data returned in the response.
    - `commandid` string: Id of the saved command
  - `result` string: The result of the login operation. Should be either 'SUCCESS' or 'FAILURE'.
  - `message` string: The message associated with the login response (applicable in case of 'FAILURE').
  - `@class` string, required

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `429`: Too Many Requests
- `500`: Internal server error
- `503`: Service Unavailable

---

[API](https://skmtc.dev/bymason/apis/mason-device-console-api-docs.md) - [All operations](https://skmtc.dev/bymason/apis/mason-device-console-api-docs/llms.txt) - [OpenAPI document](https://skmtc.dev/bymason/apis/mason-device-console-api-docs/revisions/d9cdcc14b7d1?raw)
