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 the X-API-Key Header.

  • $WORKSPACE_ID: Target workspace ID, passed through the X-Workspace-ID Header and as workspace_id in the path.

  • $AGENT_ID: The agent ID to delete, as agent_id in 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

workspace_id

string

Yes

Current workspace ID, must be consistent with X-Workspace-ID.

agent_id

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

code

integer

0 on success.

data.deleted

boolean

true indicates that the agent and its resource ownership cleanup have completed.

Error response

{
  "code": 3,
  "message": "agent not found"
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

2(INVALID_ARGUMENT)

The path parameter is invalid.

Check workspace ID and agent ID.

401

6(UNAUTHENTICATED)

Lack of valid identity credentials.

Check API Key.

403

5(PERMISSION_DENIED)

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.

404

3(NOT_FOUND)

The agent does not exist in the current workspace.

Check the agent ID, or query the agent list first.

503

15(UNAVAILABLE)

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.

Last updated on