> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Revoke a session

> Revoke an Agent Vault session with the Python SDK.

`client.agent_vault.sessions.revoke()` revokes a session. Revoke a session when its agent finishes, even if the agent fails. The proxy stops attaching credentials to the session's requests within one [poll interval](https://infisical.com/docs/documentation/platform/agent-vault/proxies#poll-interval).

If the agent can run longer than the client's access token lasts, log in again before you revoke the session, because the SDK doesn't renew the access token on its own. Set `ttl` close to how long the agent runs, so that the session expires soon after the agent finishes even if revoking the session fails.

## Parameters

**session\_id** `str` *required*

The ID of the session.

## Returns

**session** `AgentVaultSession`

The revoked session, with `accessBundle` and `services` set to `None` (call `get` for them).

```python Basic theme={"dark"}
client.agent_vault.sessions.revoke(session_id="<session-id>")
```

```python When the agent finishes theme={"dark"}
session = client.agent_vault.sessions.create(
    project_id="<project-id>",
    access_bundle="<access-bundle-name>",
    ttl="1h",
)

try:
    run_agent(session.token)  # Your code that starts the agent with the session token
finally:
    client.agent_vault.sessions.revoke(session_id=session.id)
```

```json Response theme={"dark"}
{
  "id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
  "label": "nightly deploy",
  "actor": {
    "type": "machineIdentity",
    "id": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
    "name": "deploy-bot"
  },
  "onBehalfOf": null,
  "status": "revoked",
  "expiresAt": "2026-12-02T13:00:00.000Z",
  "revokedAt": "2026-12-02T12:18:44.000Z",
  "createdAt": "2026-12-02T12:00:00.000Z",
  "accessBundle": null,
  "services": null,
  "metadata": { "runId": "8812" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.