> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://humanloop.com/docs/v4/api/sessions/get/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://humanloop.com/_mcp/server. # Get GET https://api.humanloop.com/v4/sessions/{id} Get a session by ID. Reference: https://humanloop.com/docs/v4/api/sessions/get ## Authentication - `X-API-KEY` header (required) — API Key authentication via header ## Request ### Path parameters - `id` (string, required) — String ID of session to return. Starts with `sesh_`. ## Response ### 200 Successful Response - `id` (string, required) — String ID of session. Starts with `sesh_`. - `projects` (list of SessionProjectResponse, required) — List of projects that have datapoints associated to this session. - `datapoints_count` (integer, required) — Number of datapoints associated to this session. - `created_at` (datetime, required) - `updated_at` (datetime, required) - `reference_id` (string, optional) — Unique user-provided string identifying the session. - `first_inputs` (map from string to any, optional) — Inputs for the first datapoint in the session. - `last_output` (string, optional) — Output for the last datapoint in the session. ## Errors ### 422 Sessions Get Request Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### SessionProjectResponse - `id` (string, required) — String ID of project the datapoint belongs to. Starts with `pr_`. - `name` (string, required) - `type` (enum, required) — Type of project. e.g. `prompt` or `tool`. - Allowed values: `prompt`, `tool`, `dataset`, `evaluator`, `flow`, `agent` ### ValidationError - `loc` (list of ValidationErrorLocItem, required) - `msg` (string, required) - `type` (string, required) ### ValidationErrorLocItem ## Examples **Response** ```json { "id": "id", "projects": [ { "id": "id", "name": "name", "type": "prompt" } ], "datapoints_count": 1, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "reference_id": "reference_id", "first_inputs": { "key": "value" }, "last_output": "last_output" } ``` **SDK Code** ```python import requests url = "https://api.humanloop.com/v4/sessions/id" headers = {"X-API-KEY": ""} response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.humanloop.com/v4/sessions/id'; const options = {method: 'GET', headers: {'X-API-KEY': ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.humanloop.com/v4/sessions/id" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-API-KEY", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.humanloop.com/v4/sessions/id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-API-KEY"] = '' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.humanloop.com/v4/sessions/id") .header("X-API-KEY", "") .asString(); ``` ```php request('GET', 'https://api.humanloop.com/v4/sessions/id', [ 'headers' => [ 'X-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.humanloop.com/v4/sessions/id"); var request = new RestRequest(Method.GET); request.AddHeader("X-API-KEY", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["X-API-KEY": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v4/sessions/id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```