Delete an artifact
Delete a single immutable artifact version without affecting other versions or the original environment file.
Endpoint
Deletes the specified artifact version. A successful call returns 200 and a delete envelope.
/agents/sessions/{session_id}/artifacts/{artifact_id}Path parameters
session_idstringRequiredSession that owns the artifact
artifact_idstringRequiredArtifact version ID to delete
No request body.
Request example
curl -sS -X DELETE \
"$BASE_URL/agents/sessions/sess_xxx/artifacts/artifact_xxx" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "OpenAI-Beta: agents=v1"
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url=os.environ["BASE_URL"],
)
deleted = client.beta.agents.sessions.artifacts.delete(
"artifact_xxx",
session_id="sess_xxx",
)
print(deleted.deleted)
Response fields
idstringDeleted artifact version ID
objectstringArtifact deletion result object type, fixed as agent.session.artifact.deleted
deletedbooleanWhether deletion succeeded, true on success
Delete removes only the specified artifact version. After deletion, retrieve, download, and repeated delete return 404, and the version no longer appears in lists. Deleting an artifact does not delete the original file in the sandbox or the uploaded source file.
Response example
{
"id": "artifact_xxx",
"object": "agent.session.artifact.deleted",
"deleted": true
}
Error codes
| HTTP status | Error type / code | Solution |
|---|---|---|
404 | not_found_error / not_found_error | Use an artifact ID that exists and has not been deleted in the current workspace |
The error body has the shape {"error":{"type","code","message","param"}}. Gateway errors can use a different structure.