> This page is for version 2025-09-18 (default).
> For other versions, use one of these documentation indexes:
> - 2025-09-18 (default): https://apidocs.polytomic.com/2025-09-18/llms.txt
> - 2024-02-08: https://apidocs.polytomic.com/2024-02-08/llms.txt
> - 2023-04-25: https://apidocs.polytomic.com/2023-04-25/llms.txt
> - 2022-12-12: https://apidocs.polytomic.com/2022-12-12/llms.txt
> - 2021-05-23: https://apidocs.polytomic.com/2021-05-23/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://apidocs.polytomic.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server.

# Get Harbor Activity Session

GET https://app.polytomic.com/api/organization/harbor-activity/sessions/{session_id}

Returns one Harbor Activity session and its events.

You must be an active Organization administrator to use this endpoint. The
session must belong to the Organization against which you authenticated.

Events are ordered from oldest to newest by default. Set `order` to `desc` to
retrieve the newest events first. A page contains at most 100 events. Pass
`next_page_token` from the response as `page_token` with the same order and
limit to retrieve the next page.

`history_truncated` is `true` when Activity retention removed events from the
beginning of the session. The lifecycle summary remains available while the
session itself is retained.

The response uses the same event allowlist as the Activity list and detail
endpoints. It does not include session tokens, submitted SQL, raw field names,
detailed provider errors, result rows, or raw pagination tokens.

> ℹ️ Activity retention
>
> Polytomic retains Activity events for at least 90 days. Pagination tokens
> expire 24 hours after the first page.

Reference: https://apidocs.polytomic.com/api-reference/activity/get-session

## Authentication

- `Authorization` header (bearer token, required) — Bearer user API key
- `Authorization` header (basic auth, required) — Basic organization-scoped API key

## Request

### Path parameters

- `session_id` (string, required) — Harbor Activity session ID

### Query parameters

- `limit` (integer, optional, default: 50) — Maximum number of events to return. Defaults to 50 and cannot exceed 100.
- `page_token` (string, optional) — Opaque pagination cursor returned by the previous request. It expires 24 hours after the first page.
- `order` (enum, optional, default: asc) — Order in which events were recorded. Defaults to asc.
  - Allowed values: `asc`, `desc`

## Response

### 200

OK

- `data` (HarboractivityapiHarborActivitySession, optional) — The session and its events on this page
- `pagination` (PaginationDetails, optional) — Pagination details for the next page

## Errors

### 400 Bad Request Error

Bad Request

- `key` (string, optional) — Machine-readable error key, when the error has one
- `message` (string, optional) — Error message
- `metadata` (map from string to any, optional) — Structured details about the error, when available
- `status` (integer, optional) — HTTP status code

### 401 Unauthorized Error

Unauthorized

- `key` (string, optional) — Machine-readable error key, when the error has one
- `message` (string, optional) — Error message
- `metadata` (map from string to any, optional) — Structured details about the error, when available
- `status` (integer, optional) — HTTP status code

### 403 Forbidden Error

Forbidden

- `key` (string, optional) — Machine-readable error key, when the error has one
- `message` (string, optional) — Error message
- `metadata` (map from string to any, optional) — Structured details about the error, when available
- `status` (integer, optional) — HTTP status code

### 404 Not Found Error

Not Found

- `key` (string, optional) — Machine-readable error key, when the error has one
- `message` (string, optional) — Error message
- `metadata` (map from string to any, optional) — Structured details about the error, when available
- `status` (integer, optional) — HTTP status code

### 410 Gone Error

Gone

- `key` (string, optional) — Machine-readable error key, when the error has one
- `message` (string, optional) — Error message
- `metadata` (map from string to any, optional) — Structured details about the error, when available
- `status` (integer, optional) — HTTP status code

### 422 Unprocessable Entity Error

Unprocessable Entity

- `key` (string, optional) — Machine-readable error key, when the error has one
- `message` (string, optional) — Error message
- `metadata` (map from string to any, optional) — Structured details about the error, when available
- `status` (integer, optional) — HTTP status code

## Types

### HarboractivityapiHarborActivitySession

- `client_name` (string, optional) — MCP-observed client name
- `client_version` (string, optional) — MCP-observed client version
- `credential` (HarboractivityapiHarborActivityIdentitySnapshot, optional) — Harbor credential that registered the session
- `ended_at` (datetime, optional, nullable) — When the session closed or expired
- `events` (list of HarboractivityapiHarborActivityEvent, optional, nullable) — Session events on this page
- `expires_at` (datetime, optional) — When the session expires
- `external_run_id` (string, optional) — Client-supplied run correlation value
- `harbor_id` (string, optional) — Harbor ID of the session
- `history_truncated` (boolean, optional) — Whether retention removed events from the beginning of the session
- `id` (string, optional) — Harbor session ID
- `profile` (HarboractivityapiHarborActivityIdentitySnapshot, optional) — Harbor profile of the session's credential
- `started_at` (datetime, optional) — When the session started
- `started_event_id` (string, optional) — ID of the session.started event
- `status` (enum, optional) — Session status
  - Allowed values: `active`, `closed`, `expired`
- `terminal_event_id` (string, optional) — ID of the event that closed or expired the session

### PaginationDetails

- `next_page_token` (string, optional) — Token for fetching the next page of results

### HarboractivityapiHarborActivityIdentitySnapshot

- `id` (string, optional) — ID of the actor, credential, or profile

### HarboractivityapiHarborActivityEvent

- `actor` (HarboractivityapiHarborActivityActorSnapshot, optional) — Actor that performed the operation
- `attempt_id` (string, optional) — Query attempt ID
- `client_name` (string, optional) — MCP-observed client name of the event's session
- `client_version` (string, optional) — MCP-observed client version of the event's session
- `connection_id` (string, optional) — Connection ID involved in the event
- `context_id` (string, optional) — Context document ID involved in the event
- `context_revision_id` (string, optional) — Context revision ID involved in the event
- `credential` (HarboractivityapiHarborActivityIdentitySnapshot, optional) — Harbor credential associated with the event
- `event_type` (string, optional) — Type of operation the event records
- `harbor_id` (string, optional) — Harbor ID of the event
- `id` (string, optional) — Activity event ID
- `lifecycle_events` (list of HarboractivityapiHarborActivityEvent, optional)
- `metadata` (HarboractivityapiHarborActivityMetadata, optional) — Event-specific details
- `occurred_at` (datetime, optional) — When the operation occurred
- `operation_id` (string, optional) — Operation ID shared by the events of one query or action
- `outcome` (string, optional) — Outcome of the operation: succeeded, failed, denied, or unknown
- `profile` (HarboractivityapiHarborActivityIdentitySnapshot, optional) — Harbor profile associated with the event
- `provenance` (string, optional) — How the event was attested: server_observed, service_attested, or client_asserted
- `query_source` (HarboractivityapiHarborActivityQuerySource, optional) — Source of the query, for query events
- `recorded_at` (datetime, optional) — When Polytomic recorded the event
- `session_id` (string, optional) — Harbor session ID of the event
- `targets` (list of HarboractivityapiHarborActivityTarget, optional, nullable) — Resources involved in the event

### HarboractivityapiHarborActivityActorSnapshot

- `display_name` (string, optional) — Actor display name when the event was recorded
- `email` (string, optional) — Actor email when the event was recorded
- `id` (string, optional) — ID of the actor, credential, or profile
- `type` (string, optional) — Actor type

### HarboractivityapiHarborActivityMetadata

- `action_enabled` (boolean, optional, nullable) — Whether the action is enabled
- `action_field_ids` (list of string, optional) — Field IDs granted, submitted, or returned by the action
- `action_id` (string, optional) — Action identity, as the schema ID and operation ID joined by a slash
- `action_lookup_field_id` (string, optional) — Lookup field ID used by the action
- `action_lookup_field_ids` (list of string, optional) — Lookup field IDs granted by the action configuration
- `action_request_id` (string, optional) — Action execution ID
- `attempt_number` (integer, optional, nullable) — Query attempt number
- `category` (string, optional) — Category of the access denial
- `client_name` (string, optional) — MCP-observed client name of the session
- `client_version` (string, optional) — MCP-observed client version of the session
- `connection_name` (string, optional, nullable) — Connection name when the query was submitted
- `connection_name_truncated` (boolean, optional, nullable) — Whether the connection name snapshot was truncated
- `connection_type` (string, optional, nullable) — Connection type of the queried connection
- `context_version` (integer, optional, nullable) — Published context version number at fetch time, when recorded
- `error_category` (string, optional) — Category of a failed query or action
- `execution_duration_ms` (integer, optional, nullable) — Milliseconds the query spent executing
- `external_run_id` (string, optional) — Client-supplied run correlation value of the session
- `failure_code` (string, optional) — Failure code of a failed query
- `field_count` (integer, optional, nullable) — Number of fields returned by a query. Raw field names are not returned.
- `has_next_page` (boolean, optional, nullable) — Whether the listed page had more results
- `label` (string, optional, nullable) — Bounded resource label snapshot
- `label_truncated` (boolean, optional, nullable) — Whether the resource label snapshot was truncated
- `operation` (string, optional) — Operation that was denied
- `phase` (string, optional) — Query phase in which the query finished: dispatch, preflight, or execution
- `queue_duration_ms` (integer, optional, nullable) — Milliseconds between query submission and the start of execution
- `reason` (string, optional) — Reason the session ended or access was denied
- `record_id` (string, optional) — Record ID of the created record view link
- `row_count` (integer, optional, nullable) — Number of rows returned by the query
- `saved_query_id` (string, optional) — Saved query ID
- `saved_query_revision_id` (string, optional) — Saved query revision ID
- `saved_query_version` (integer, optional, nullable) — Saved query version
- `schema_id` (string, optional) — Schema ID involved in the event
- `statement_category` (string, optional) — Statement category of the submitted query: select, other, or unknown
- `supported` (boolean, optional, nullable) — Whether record view links can be created for the schema
- `total_duration_ms` (integer, optional, nullable) — Milliseconds between query submission and its final outcome

### HarboractivityapiHarborActivityQuerySource

- `kind` (string, optional) — Query source: saved_query, ad_hoc, or unknown when the submission is no longer retained
- `saved_query` (HarboractivityapiHarborActivitySavedQuerySource, optional) — Saved query that was submitted, when kind is saved_query
- `submission_event_id` (string, optional) — ID of the query.submitted event
- `submitted_at` (datetime, optional, nullable) — When the query was submitted

### HarboractivityapiHarborActivityTarget

- `id` (string, optional) — Target resource ID
- `label` (string, optional) — Label snapshot of the target resource
- `label_truncated` (boolean, optional) — Whether the label snapshot was truncated
- `revision_id` (string, optional) — Saved query revision ID, for saved query targets
- `type` (string, optional) — Type of the target resource: connection, schema, context, context_revision, or saved_query
- `version` (integer, optional, nullable) — Saved query version, for saved query targets

### HarboractivityapiHarborActivitySavedQuerySource

- `id` (string, optional) — Saved query ID
- `name` (string, optional) — Saved query name when the query was submitted
- `name_truncated` (boolean, optional) — Whether the name snapshot was truncated
- `revision_id` (string, optional) — Saved query revision ID that was submitted
- `version` (integer, optional) — Saved query version that was submitted

## Examples

**Response**

```json
{
  "data": {
    "client_name": "string",
    "client_version": "string",
    "credential": {
      "id": "248df4b7-aa70-47b8-a036-33ac447e668d"
    },
    "ended_at": "2024-01-15T09:30:00Z",
    "events": [
      {
        "actor": {
          "display_name": "string",
          "email": "string",
          "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
          "type": "string"
        },
        "attempt_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "client_name": "string",
        "client_version": "string",
        "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "context_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "context_revision_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "credential": {
          "id": "248df4b7-aa70-47b8-a036-33ac447e668d"
        },
        "event_type": "string",
        "harbor_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "lifecycle_events": [
          null
        ],
        "metadata": {
          "action_enabled": true,
          "action_field_ids": [
            "string"
          ],
          "action_id": "string",
          "action_lookup_field_id": "string",
          "action_lookup_field_ids": [
            "string"
          ],
          "action_request_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
          "attempt_number": 1,
          "category": "string",
          "client_name": "string",
          "client_version": "string",
          "connection_name": "string",
          "connection_name_truncated": true,
          "connection_type": "string",
          "context_version": 1,
          "error_category": "string",
          "execution_duration_ms": 1,
          "external_run_id": "string",
          "failure_code": "string",
          "field_count": 1,
          "has_next_page": true,
          "label": "string",
          "label_truncated": true,
          "operation": "string",
          "phase": "string",
          "queue_duration_ms": 1,
          "reason": "string",
          "record_id": "string",
          "row_count": 1,
          "saved_query_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
          "saved_query_revision_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
          "saved_query_version": 1,
          "schema_id": "string",
          "statement_category": "string",
          "supported": true,
          "total_duration_ms": 1
        },
        "occurred_at": "2024-01-15T09:30:00Z",
        "operation_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "outcome": "string",
        "profile": {
          "id": "248df4b7-aa70-47b8-a036-33ac447e668d"
        },
        "provenance": "string",
        "query_source": {
          "kind": "string",
          "saved_query": {
            "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
            "name": "string",
            "name_truncated": true,
            "revision_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
            "version": 1
          },
          "submission_event_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
          "submitted_at": "2024-01-15T09:30:00Z"
        },
        "recorded_at": "2024-01-15T09:30:00Z",
        "session_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "targets": [
          {
            "id": "string",
            "label": "string",
            "label_truncated": true,
            "revision_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
            "type": "string",
            "version": 1
          }
        ]
      }
    ],
    "expires_at": "2024-01-15T09:30:00Z",
    "external_run_id": "string",
    "harbor_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "history_truncated": true,
    "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "profile": {
      "id": "248df4b7-aa70-47b8-a036-33ac447e668d"
    },
    "started_at": "2024-01-15T09:30:00Z",
    "started_event_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "status": "active",
    "terminal_event_id": "248df4b7-aa70-47b8-a036-33ac447e668d"
  },
  "pagination": {
    "next_page_token": "AmkYh8v0jR5B3kls2Qcc9y8MjrPmvR4CvaK7H0F4rEwqvg76K=="
  }
}
```

**SDK Code**

```python
import requests

url = "https://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d"

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

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

print(response.json())
```

```javascript
const url = 'https://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d"

	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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d")

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
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.polytomic.com/api/organization/harbor-activity/sessions/248df4b7-aa70-47b8-a036-33ac447e668d")! 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()
```