Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Delete an agent session

AgentSessionDeleted beta().agents().sessions().delete(SessionDeleteParamsparams = SessionDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
DELETE/agents/sessions/{session_id}

Removes a managed agent session from the public API and returns a deletion confirmation. If backend execution has ended, deletion can cancel a still-open public turn and abandon unpublished outputs. Running execution must be cancelled first. Physical cleanup may continue asynchronously. See managing sessions.

ParametersExpand Collapse
SessionDeleteParams params
Optional<String> sessionId
minLength0
maxLength1048576
ReturnsExpand Collapse
class AgentSessionDeleted:

A Managed Agents session removed from the public API. Physical cleanup may continue asynchronously.

String id

The ID of the deleted session.

minLength0
boolean deleted

Whether the session has been removed from the public API. Always true. Physical cleanup may still be in progress.

JsonValue; object_ "agent.session.deleted"constant"agent.session.deleted"constant

The object type. Always agent.session.deleted.

Delete an agent session

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.agents.AgentSessionDeleted;
import com.openai.models.beta.agents.sessions.SessionDeleteParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        AgentSessionDeleted agentSessionDeleted = client.beta().agents().sessions().delete("session_id");
    }
}
{
  "id": "id",
  "deleted": true,
  "object": "agent.session.deleted"
}
Returns Examples
{
  "id": "id",
  "deleted": true,
  "object": "agent.session.deleted"
}