---
title: Add sessions to an Agent Analytics dataset
description: "Adds sessions to a dataset. Sessions already in the dataset are ignored, so the call is safe to repeat. Every session must belong to the path project; a sess…"
product: general
lang: en
last_updated: 2026-10-21
token_estimate: 1506
---
# Add sessions to an Agent Analytics dataset

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

## Add sessions to an Agent Analytics dataset

**POST** `/v1/projects/{project_id}/agent-analytics/datasets/{dataset_id}/sessions`

Full URL: `https://developer-api.amplitude.com/v1/projects/{project_id}/agent-analytics/datasets/{dataset_id}/sessions`

**Servers:**
- Production (US): `https://developer-api.amplitude.com/v1/projects/{project_id}/agent-analytics/datasets/{dataset_id}/sessions`
- Production (EU): `https://developer-api.eu.amplitude.com/v1/projects/{project_id}/agent-analytics/datasets/{dataset_id}/sessions`

Add sessions to an Agent Analytics dataset

Adds sessions to a dataset. Sessions already in the dataset are ignored, so
the call is safe to repeat. Every session must belong to the path project;
a session from another project fails the whole request with `422`.

## Authorizations

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Authorization | string | Yes | — | http |

## Path parameters

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| project_id (path) | string | Yes | 12345 | Amplitude project identifier, backed by the canonical app ID. Constraints: pattern: ^[0-9]+$ |
| dataset_id (path) | string | Yes | — | Stable dataset identifier, returned by create or by the Agent Analytics read surface. |

## Header parameters

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Idempotency-Key (header) | string | Yes | — | Unique idempotency key used to safely retry write operations. Constraints: min length: 8, max length: 255 |

## Body (application/json)

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| session_ids | string[] | Yes | — | Session identifiers. All must belong to the path project. |

## Response (application/json)

**200** — Dataset after the sessions were added, with refreshed counts.

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| data | object | Yes | — | — |
| data.id | string | Yes | — | Stable dataset identifier (ULID). |
| data.object | string | Yes | — | — |
| data.project_id | string | Yes | — | — |
| data.name | string | Yes | — | Constraints: min length: 1 |
| data.description | string | Yes | — | Constraints: nullable |
| data.agent_name | string | Yes | — | Agent the dataset is scoped to. Null for project-level datasets. Constraints: nullable |
| data.source_type | string | Yes | — | How the dataset was assembled, such as `manual`. |
| data.session_count | integer | Yes | — | Sessions currently in the dataset. |
| data.reviewed_count | integer | Yes | — | Sessions in the dataset that carry a human review. |
| data.created_at | string | Yes | — | Constraints: format: date-time |
| data.created_by | string | No | — | Constraints: nullable |

```json
{
  "data": {
    "id": "string",
    "object": "agent_analytics_dataset",
    "project_id": "string",
    "name": "string",
    "description": "string",
    "agent_name": "string",
    "source_type": "string",
    "session_count": 0,
    "reviewed_count": 0,
    "created_at": "2024-01-01T00:00:00Z",
    "created_by": "string"
  }
}
```

**400**

**401**

**403**

**404**

**422**

**429**

**502**

## Code samples

### cURL

```bash
curl -X POST "https://developer-api.amplitude.com/v1/projects/12345/agent-analytics/datasets/{dataset_id}/sessions" \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_API_KEY"
```

### Python

```python
import requests

response = requests.post(
    "https://developer-api.amplitude.com/v1/projects/12345/agent-analytics/datasets/{dataset_id}/sessions",
    headers={
        "Content-Type": "application/json",
        "Authorization": "YOUR_API_KEY"
    }
)
data = response.json()
```

### JavaScript

```javascript
const response = await fetch("https://developer-api.amplitude.com/v1/projects/12345/agent-analytics/datasets/{dataset_id}/sessions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "YOUR_API_KEY"
  }
});
const data = await response.json();
```

### PHP

```php
<?php
$ch = curl_init("https://developer-api.amplitude.com/v1/projects/12345/agent-analytics/datasets/{dataset_id}/sessions");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Authorization: YOUR_API_KEY"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
```

### Go

```go
package main

import (
  "bytes"
  "net/http"
)

func main() {
req, _ := http.NewRequest("POST", "https://developer-api.amplitude.com/v1/projects/12345/agent-analytics/datasets/{dataset_id}/sessions", nil)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "YOUR_API_KEY")
  client := &http.Client{}
  resp, _ := client.Do(req)
  defer resp.Body.Close()
}
```

### Java

```java
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://developer-api.amplitude.com/v1/projects/12345/agent-analytics/datasets/{dataset_id}/sessions"))
      .method("POST", HttpRequest.BodyPublishers.noBody())
.header("Content-Type", "application/json")
      .header("Authorization", "YOUR_API_KEY")
      .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
```

### Ruby

```ruby
require "net/http"
require "json"

uri = URI("https://developer-api.amplitude.com/v1/projects/12345/agent-analytics/datasets/{dataset_id}/sessions")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end
```

