curl --request GET \
--url https://api.{domain}/v1/sessions \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.{domain}/v1/sessions"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.{domain}/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.{domain}/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 => [
"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://api.{domain}/v1/sessions"
req, _ := http.NewRequest("GET", 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.get("https://api.{domain}/v1/sessions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.{domain}/v1/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"object": "session",
"id": "<string>",
"status": "idle",
"created_at": 123,
"updated_at": 123,
"agent": {
"id": "<string>",
"model": "<string>",
"model_credential_id": "<string>",
"approval_mode": "<string>",
"instructions": "<string>",
"permission_rules": [
{}
],
"tools": [
{}
]
},
"environment": {
"type": "sandbox",
"state": "unknown",
"workspace_directory": "<string>",
"repo": {
"full_name": "<string>",
"branch": "<string>",
"clone_error": "<string>"
}
},
"preview": {
"url": "<string>",
"port": 123,
"published_url": "<string>"
},
"title": "<string>",
"source": "api",
"created_by_token": "<string>",
"required_actions": [
{
"type": "function_call",
"turn_id": "<string>",
"call_id": "<string>",
"name": "<string>",
"arguments": "<unknown>",
"created_at": 123,
"expires_at": 123
}
]
}
],
"has_more": true,
"last_id": "<string>"
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}List sessions
List the organization’s sessions.
curl --request GET \
--url https://api.{domain}/v1/sessions \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.{domain}/v1/sessions"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.{domain}/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.{domain}/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 => [
"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://api.{domain}/v1/sessions"
req, _ := http.NewRequest("GET", 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.get("https://api.{domain}/v1/sessions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.{domain}/v1/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"object": "session",
"id": "<string>",
"status": "idle",
"created_at": 123,
"updated_at": 123,
"agent": {
"id": "<string>",
"model": "<string>",
"model_credential_id": "<string>",
"approval_mode": "<string>",
"instructions": "<string>",
"permission_rules": [
{}
],
"tools": [
{}
]
},
"environment": {
"type": "sandbox",
"state": "unknown",
"workspace_directory": "<string>",
"repo": {
"full_name": "<string>",
"branch": "<string>",
"clone_error": "<string>"
}
},
"preview": {
"url": "<string>",
"port": 123,
"published_url": "<string>"
},
"title": "<string>",
"source": "api",
"created_by_token": "<string>",
"required_actions": [
{
"type": "function_call",
"turn_id": "<string>",
"call_id": "<string>",
"name": "<string>",
"arguments": "<unknown>",
"created_at": 123,
"expires_at": 123
}
]
}
],
"has_more": true,
"last_id": "<string>"
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>"
}
}Authorizations
A gbr_pat_ access token. Scopes are recorded on the token when it is minted.
Query Parameters
How many to return, 1–100. Default 20.
1 <= x <= 100Newest first (desc, the default) or oldest first (asc).
asc, desc The last_id of the previous page. A cursor this collection cannot place — expired, deleted, or never issued — answers with an empty page rather than starting over, so a paging loop ends instead of repeating itself.
Only sessions in this state. requires_action is the one to ask for after a restart: it is everything waiting on your code.
idle, working, requires_action, failed api for sessions your code created, console for ones a person made in the Console. A list is organization-wide, so without this a second client sharing the organization appears in yours.
api, console Only the sessions one token created — me for the token making this call. The narrowest answer to "which of these are mine", and the one to reach for when several integrations share an organization.
One of your own labels, as key:value — ?metadata=job:8842. Finds the session for a job without keeping a map of your own.