Delete agent
Delete an agent configuration; existing sessions keep the snapshot created with the session and are not affected.
Endpoint
Returns 200 and a delete envelope. Deletion is a soft archive: the agent is marked as deleted and a deletion time is recorded. Later retrieve or delete requests return 404.
Deletion only archives the agent. It does not stop existing sessions or clean up environments. Existing sessions keep the agent snapshot created with the session and are not affected by the deletion.
/agents/{agent_id}Path parameters
agent_idstringRequiredAgent ID. Treat it as an opaque string
This endpoint has no request body or query parameters.
Request example
curl -sS -X DELETE "$BASE_URL/agents/agent_xxx" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "OpenAI-Beta: agents=v1"
client.beta.agents.delete("agent_xxx")
Response fields
idstringID of the deleted agent
objectstringAgent deletion result object type, fixed as agent.deleted
deletedbooleanWhether deletion succeeded, true when deletion succeeds
Response example
{
"id": "agent_xxx",
"object": "agent.deleted",
"deleted": true
}
Error codes
Business errors return an error object with type, code, message, and param. Common errors:
| HTTP status | Error type / code | Solution |
|---|---|---|
401 | authentication_error / invalid_api_key | Send a valid Authorization: Bearer $DASHSCOPE_API_KEY header |
404 | not_found_error / not_found_error | Use an agent ID that exists and has not been deleted in the current workspace |
500 | server_error / server_error | Retry later. If it keeps failing, submit a ticket with x-request-id |