# Retrieve command history for a managed device gets the command history for the device ## Endpoints `GET /api/v1/mdm/devices/{device_id}/commandhistory` ## Request URL ```text https://{server-hostname}:8383/api/v1/mdm/devices/{device_id}/commandhistory ``` ## Scope ```text MDMInventory.READ ``` ## Header ```text Authorization: d92d4xxxxxxxxxxxxx15f52 ``` ## Request Parameters ### Request Headers - **Accept** (`string`, Mandatory): `application/json` ### Path Parameters - **device_id** (`string`, Mandatory): Unique identifier of the device. Obtain from the [Get Device List](https://www.manageengine.com/products/desktop-central/help/api/onpremise/devices-get-device-list.html) response ### Query Parameters - **limit** (`integer`, Optional): Maximum number of records to return in a single response. Used together with offset for pagination - **skip-token** (`string`, Optional): Pagination continuation token returned by a previous response. Pass it to fetch the next page of results - **offset** (`integer`, Optional): Zero-based index of the first record to return. Used together with limit for pagination - **delta-token** (`string`, Optional): Token used for delta/incremental fetches. Pass the token returned from a previous response to retrieve only items modified since that point - **days** (`integer`, Optional): Number of days to look back from the current time when filtering results - **start_time** (`string`, Optional): Start of the time range to filter by (epoch milliseconds, inclusive) - **end_time** (`string`, Optional): End of the time range to filter by (epoch milliseconds, inclusive) ## Sample Request ### Curl ```curl curl --request GET \ --url 'https://appdomain/api/v1/mdm/devices/{device_id}/commandhistory?limit=SOME_INTEGER_VALUE&skip-token=SOME_STRING_VALUE&offset=SOME_INTEGER_VALUE&delta-token=SOME_STRING_VALUE&days=SOME_INTEGER_VALUE&start_time=SOME_STRING_VALUE&end_time=SOME_STRING_VALUE' \ --header 'Accept: application/json' \ --header 'Authorization: d92d4xxxxxxxxxxxxx15f52' ``` ## Response Parameters ### HTTP Code 200 Response Body — `application/json` - `JSON Object` - **metadata** (`JSON Object`): Metadata about the result set - **paging** (`JSON Object`): Pagination links for navigating results - **delta-token** (`string`): Delta token for incremental queries - **commands** (`JSON Array`): Array of commands sent to the device ## Possible Response Codes - **200** (`HTTP code`) ## Sample Response: HTTP 200 Paginated command history with lifecycle details ```json { "metadata": { "total_record_count": 4 }, "delta-token": "aHR0cDovL2xvY2FsaG9zdDo5MDIwL2FwaS92MS9tZG0vcHJvZmlsZXMvc2NlcHNldHRpbmdzOjoxNTQyOTU0OTEzOTI0", "paging": { "next": "https://appDomain/api/v1/mdm/devices/9007199254741001/commandhistory?skip-token=MjozOjE6MTU0Mjk1NDkxMzkxOA%3D%3D", "previous": "https://appDomain/api/v1/mdm/devices/9007199254741001/commandhistory?skip-token=Aexzsjk6nkL1psqmWdKigzGxOA%3D%3D" }, "commands": [ { "command_status": 2, "managed_status": 2, "command_id": 9007199254741304, "added_time": "1523370360750", "device_id": "9007199254741001", "added_by": 9007199254740996, "command_history_id": 9007199254740996, "command_life": [ { "updated_time": 1560141503246, "status_description": "Command Success", "command_id": 9007199254741304, "status_code": 2, "added_by": 9007199254740996, "command_name": "AssetScan", "added_by_name": "admin", "remarks": "--" } ], "remarks_args": null, "command_name": "AssetScan", "added_by_name": "admin", "remarks": "--" } ] } ``` ![](https://www.zohowebstatic.com/sites/zweb/images/people/ico-help.png) **Duration:** 1 minute | **Threshold:** 250 | **Lock period:** 5 minutes Duration - Time window for the threshold. Threshold - Number of API calls allowed within the specified duration. Lock Period - Wait time before consecutive API requests.