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

# Share a session

> Make a session publicly accessible or revoke access.

Make a session publicly accessible via a share URL. Anyone with the link can view the session without authentication.

***

## Make public

**`POST /api/v2/sessions/{id}/share`**

**Returns** `200` with a `ShareLink` object.

### Path parameters

<ParamField path="id" type="string" required>
  The session ID.
</ParamField>

### Response

```json Response theme={null}
{
  "share_url": "/share/api/v1/trajectories/{id}"
}
```

`share_url` is a path relative to the API host you called, so prepend your regional base URL (for example `https://agp.eu.hcompany.ai`) before handing it out.

### Example

<CodeGroup>
  ```bash CLI theme={null}
  hai sessions share "$SESSION_ID"
  ```

  ```bash cURL theme={null}
  curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/share \
    -H "Authorization: Bearer $HAI_API_KEY"
  ```

  ```python Python theme={null}
  from hai_agents import Client

  client = Client()

  link = client.sessions.share_session(session_id)
  print(link.share_url)
  ```

  ```typescript TypeScript theme={null}
  import { HaiAgentsClient } from "hai-agents";

  const client = new HaiAgentsClient();

  const link = await client.sessions.shareSession({ id: sessionId });
  console.log(link.shareUrl);
  ```
</CodeGroup>

***

## Revoke public access

**`DELETE /api/v2/sessions/{id}/share`**

Revokes the public share link. The session is no longer accessible without authentication.

**Returns** `204 No Content`.

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/share \
    -H "Authorization: Bearer $HAI_API_KEY"
  ```

  ```python Python theme={null}
  from hai_agents import Client

  client = Client()

  client.sessions.unshare_session(session_id)
  ```

  ```typescript TypeScript theme={null}
  import { HaiAgentsClient } from "hai-agents";

  const client = new HaiAgentsClient();

  await client.sessions.unshareSession({ id: sessionId });
  ```
</CodeGroup>
