You can use the mgwutil delete-agent command to interactively or forcibly delete a specified agent.
This operation is irreversible. Be sure to confirm the deletion before you proceed.
Command format
mgwutil delete-agent <agent-name> [--force]Parameter description
Parameter | Required | Description |
agent-name | Yes | Name of the agent to delete. |
--force | No | Force deletion without interactive confirmation. Disabled by default. |
Examples
Interactive mode
Run the delete command and confirm the deletion when prompted. This is the default safe mode, which helps prevent accidental deletion.
mgwutil delete-agent mgwutil_agent-12After you run the command, the system displays the following prompt to confirm the deletion.
please confirm if you want to delete agent: (y/n) Enter
nand press Enter to abort the operation. The messagecancel the delete agent operationis displayed, indicating that the deletion was canceled.Enter
yand press Enter to confirm the deletion.
Force delete (non-interactive)
This example shows how to forcibly delete the agent mgwutil_agent-12.
You can use the following command to forcibly delete the specified agent. This operation is irreversible. Proceed with caution.
mgwutil delete-agent mgwutil_agent-12 --forceResponse
Success response
{
"Code": "success" ,
"StatusCode": 204,
"LogTime": "2025-12-25 17:51:37",
"Data": {}
}Failure response
{
"Code": "fail",
"StatusCode": 409,
"LogTime": "2026-01-16 11:24:02",
"ErrorMsg": "SDKError: StatusCode: 409 Code: ImportAgentIsOccupied Message: The import agent is occupied by import address Data: {'AccessDeniedDetail':null,'Recommend':null,'ecCode':null,'hostId':'1****9****69***5.cn-hangzhou.mgw.aliyuncs.com','requestId':'6969AF52F8BE36363969434D','statusCode':409} ",
"ErrorCode": "ImportAgentIsOccupied",
"RequestId": "6969AF52F8BE36363969434D"
}Error codes
Error codes indicate the category of an error. For more information, see the error message (ErrorMsg).
These error codes include common error codes.
ErrorCode | Description |
CancelOperation | Delete operation canceled. |
InvalidInput | Invalid confirmation input. Enter only 'y' to confirm or 'n' to cancel. |
ImportAgentIsOccupied | This agent is already associated with the specified data address. |