Skip to main content
POST
/
api
/
v2
/
sessions
/
{id}
/
share
Share a session
curl --request POST \
  --url https://agp.eu.hcompany.ai/api/v2/sessions/{id}/share \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://agp.eu.hcompany.ai/api/v2/sessions/{id}/share"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch('https://agp.eu.hcompany.ai/api/v2/sessions/{id}/share', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://agp.eu.hcompany.ai/api/v2/sessions/{id}/share",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://agp.eu.hcompany.ai/api/v2/sessions/{id}/share"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://agp.eu.hcompany.ai/api/v2/sessions/{id}/share")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://agp.eu.hcompany.ai/api/v2/sessions/{id}/share")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
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

id
string
required
The session ID.

Response

Response
{
  "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

hai sessions share "$SESSION_ID"
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/share \
  -H "Authorization: Bearer $HAI_API_KEY"
from hai_agents import Client

client = Client()

link = client.sessions.share_session(session_id)
print(link.share_url)
import { HaiAgentsClient } from "hai-agents";

const client = new HaiAgentsClient();

const link = await client.sessions.shareSession({ id: sessionId });
console.log(link.shareUrl);

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

curl -X DELETE https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/share \
  -H "Authorization: Bearer $HAI_API_KEY"
from hai_agents import Client

client = Client()

client.sessions.unshare_session(session_id)
import { HaiAgentsClient } from "hai-agents";

const client = new HaiAgentsClient();

await client.sessions.unshareSession({ id: sessionId });