Delete the agent¶
Delete the agent in the current workspace. The deletion is completed in the same transaction as the agent’s resource ownership cleanup; the deletion is complete when data.deleted in the successful response is true. Agents created through Agent Builder must have an active workspace ownership record before this operation can complete.
DELETE https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agents/{agent_id}
Preparation before calling¶
First query the agent details and confirm the agent to be deleted. Prepare the personal access token, target workspace ID, and agent ID that have access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed through theX-Workspace-IDHeader and asworkspace_idin the path.$AGENT_ID: The agent ID to delete, asagent_idin the path.
Request example¶
curl -X DELETE "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/agents/$AGENT_ID" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID"
Path parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Current workspace ID, must be consistent with |
|
string |
Yes |
The ID of the agent to delete. |
Successful response¶
Returns 200 on success. Deletion is irreversible.
{
"code": 0,
"data": {
"deleted": true
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
boolean |
|
Error response¶
{
"code": 3,
"message": "agent not found"
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The path parameter is invalid. |
Check workspace ID and agent ID. |
|
|
Lack of valid identity credentials. |
Check API Key. |
|
|
The current identity does not have delete permission, or the target is a read-only resource. |
Use an authorized identity; system shared agents cannot be deleted through this interface. |
|
|
The agent does not exist in the current workspace. |
Check the agent ID, or query the agent list first. |
|
|
The agent resource service or its authorized dependencies are temporarily unavailable. |
Try again later. |
Follow-up operations¶
After deleting, use Query the list of agents to confirm that the agent will no longer appear.