Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Agent Sessions

Create a session

POST /agents/{agent_name}/endpoint/sessions

Creates a new session for an agent endpoint. The endpoint resolves the backing agent version from version_indicator and enforces session ownership using the provided user identity for session-mutating operations.

Path parameters

agent_name string required

The name of the agent to create a session for.

Query parameters

api-version string required

The API version to use for this operation.

Request Body

Content-Type: application/json
agent_session_id string

Optional caller-provided session ID. If specified, it must be unique within the agent endpoint. Auto-generated if omitted.

version_indicator version_ref required

Version indicator determining which agent version backs the session.

One of the following:
version_ref VersionRefIndicator

Version indicator that references a specific agent version by name.

type enum required

Discriminator value for version_ref.

version_ref
agent_version string required

The agent version identifier returned by the agent version APIs.

Responses

The request has succeeded and a new resource has been created as a result.

Body

Content-Type: application/json
agent_session_id string required

The session identifier.

version_indicator version_ref required

Version indicator determining which agent version backs the session.

One of the following:
version_ref VersionRefIndicator

Version indicator that references a specific agent version by name.

type enum required

Discriminator value for version_ref.

version_ref
agent_version string required

The agent version identifier returned by the agent version APIs.

status string | enum required

The status of an agent session.

Any of the following:
string
enum
creatingactiveidleupdatingfaileddeletingdeletedexpired
created_at integer required

The Unix timestamp (in seconds) when the session was created.

last_accessed_at integer required

The Unix timestamp (in seconds) when the session was last accessed.

expires_at integer required

The Unix timestamp (in seconds) when the session expires (rolling, 30 days from last activity).

stopped_at integer

The Unix timestamp (in seconds) when the session sandbox was last observed to stop or go idle. Present only after the session has gone idle at least once, used for accurate idle-billing reconciliation.

Client error

Body

Content-Type: application/json
error OpenAI.Error required
code string | null required
message string required
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Any of the following:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string required

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Body

Content-Type: application/json
error OpenAI.Error required
code string | null required
message string required
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Any of the following:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string required

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Request

POST /agents/{agent_name}/endpoint/sessions HTTP/1.1

Response

Status: 201
Content-Type: application/json
Status: 4XX
Content-Type: application/json
Status: 5XX
Content-Type: application/json
en-us
Your Privacy Choices
  • AI Disclaimer
  • Previous Versions
  • Blog
  • Contribute
  • Privacy
  • Consumer Health Privacy
  • Terms of Use
  • Trademarks
  • © Microsoft 2026