List Sessions
curl --request GET \
--url https://api.agenthuman.com/v1/sessions \
--header 'x-api-key: <api-key>'import requests
url = "https://api.agenthuman.com/v1/sessions"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.agenthuman.com/v1/sessions', 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://api.agenthuman.com/v1/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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://api.agenthuman.com/v1/sessions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.agenthuman.com/v1/sessions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agenthuman.com/v1/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"sessions": [
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W4T",
"status": "ended",
"started_at": "2024-01-15T12:00:00Z",
"ended_at": "2024-01-15T12:05:30Z",
"expiration": "2024-01-15T14:35:00Z",
"aspect_ratio": "4:3",
"duration": 330,
"metadata": {
"user_name": "John Doe"
},
"billing": {
"minutes_consumed": 6,
"minutes_source": "plan",
"billing_status": "free",
"minutes_billed": 0
}
},
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W5U",
"status": "started",
"started_at": "2024-01-15T14:00:00Z",
"ended_at": null,
"expiration": "2024-01-15T18:00:00Z",
"aspect_ratio": "4:3",
"duration": 90,
"metadata": {}
}
]
}
Sessions
List Sessions
Get all sessions for the authenticated user with optional filtering
GET
/
v1
/
sessions
List Sessions
curl --request GET \
--url https://api.agenthuman.com/v1/sessions \
--header 'x-api-key: <api-key>'import requests
url = "https://api.agenthuman.com/v1/sessions"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.agenthuman.com/v1/sessions', 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://api.agenthuman.com/v1/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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://api.agenthuman.com/v1/sessions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.agenthuman.com/v1/sessions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agenthuman.com/v1/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"sessions": [
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W4T",
"status": "ended",
"started_at": "2024-01-15T12:00:00Z",
"ended_at": "2024-01-15T12:05:30Z",
"expiration": "2024-01-15T14:35:00Z",
"aspect_ratio": "4:3",
"duration": 330,
"metadata": {
"user_name": "John Doe"
},
"billing": {
"minutes_consumed": 6,
"minutes_source": "plan",
"billing_status": "free",
"minutes_billed": 0
}
},
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W5U",
"status": "started",
"started_at": "2024-01-15T14:00:00Z",
"ended_at": null,
"expiration": "2024-01-15T18:00:00Z",
"aspect_ratio": "4:3",
"duration": 90,
"metadata": {}
}
]
}
Query Parameters
string
default:"all"
Filter sessions by status. Options:
all- Return all sessions (default)started- Return only active/started sessionsended- Return only ended sessions (includes billing data)
all and return all sessions.Response
boolean
Whether the request was successful
array
Array of session objects (See Session schema). Ended sessions include billing information.
{
"success": true,
"sessions": [
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W4T",
"status": "ended",
"started_at": "2024-01-15T12:00:00Z",
"ended_at": "2024-01-15T12:05:30Z",
"expiration": "2024-01-15T14:35:00Z",
"aspect_ratio": "4:3",
"duration": 330,
"metadata": {
"user_name": "John Doe"
},
"billing": {
"minutes_consumed": 6,
"minutes_source": "plan",
"billing_status": "free",
"minutes_billed": 0
}
},
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W5U",
"status": "started",
"started_at": "2024-01-15T14:00:00Z",
"ended_at": null,
"expiration": "2024-01-15T18:00:00Z",
"aspect_ratio": "4:3",
"duration": 90,
"metadata": {}
}
]
}
For active sessions (
status = started), duration is calculated at request time (seconds since started_at).Ended sessions include a
billing object with information about minutes consumed and billing status. Active/created sessions do not include billing information.⌘I