Retrieve environment
Retrieve the preparation status and safe installed metadata of an environment by ID.
Endpoint
Returns the current status and safe metadata of the specified environment. A successful call returns 200.
/agents/environments/{environment_id}Path parameters
environment_idstringRequiredEnvironment ID from the create response; not a session ID, template ID, or sandbox ID
No request body.
Request example
curl -sS "$BASE_URL/agents/environments/ccarenv_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"],
)
environment = client.beta.agents.environments.retrieve("ccarenv_xxx")
print(environment.status)
Response fields
idstringEnvironment ID
objectstringEnvironment object type, fixed as agent.environment
typestringEnvironment type, fixed as openai_hosted
statusstringEnvironment status: pending, ready, connected, disconnected, suspended, expired, or failed
filesarraySafe metadata for installed files; file content is not returned.
Properties
idstringEnvironment file ID
typestringFile reference type, fixed as file_id
pathstringFile path in the environment
size_bytesintegerFile size in bytes
file_idstringOriginal source file ID
skillsarraySafe metadata for installed skills; package content is not returned.
Properties
typestringSkill reference type, fixed as skill_reference
namestringSkill name
descriptionstringSkill description
skill_idstringSkill resource ID
versionstringFrozen version
pluginsarrayPlugin list; currently [] for managed environments; plugin fields in historical records do not mean plugins can be created
ready means preparation is complete and a session can reference the environment. connected means the instance is connected, which does not guarantee that every subsequent command succeeds.
Response example
{
"id": "ccarenv_xxx",
"object": "agent.environment",
"type": "openai_hosted",
"status": "ready",
"files": [],
"skills": [],
"plugins": []
}
Error codes
| HTTP status | Error type / code | Solution |
|---|---|---|
404 | not_found_error / not_found_error | Use an environment ID that exists and is visible in the current workspace |
503 | server_error / environment_unavailable | Retry later. If it keeps failing, submit a ticket with x-request-id |
The error body has the shape {"error":{"type","code","message","param"}}. Gateway errors can use a different structure. Keep the HTTP status, x-request-id, and environment ID for troubleshooting.