# List analysis groups for an agent

> GET https://api.nabrah.ai/api/ext/agent/{agent_id}/analysis_groups

Group: Agents. Page: https://www.nabrah.ai/en/docs/api-reference/agents/list-analysis-groups-for-an-agent

Lists all analysis groups currently linked to the agent identified by `agent_id`. Agents and analysis groups have a many-to-many relationship; this endpoint shows that relationship from the agent's side. Crucially, each returned item includes the `link_id` for the agent↔analysis-group association — you need that `link_id` to unlink them later via DELETE /api/ext/analysis/link/{link_id}.

## Where agent_id comes from

- **Discovering the ID**: Use GET /api/ext/agent to list agents, or the `agent_id` returned by POST /api/ext/agent.

## Response shape

Returns an object with an `analysis_groups` array.

- **The link_id matters**: Each analysis group in the array carries a `link_id` representing this specific agent↔group link. Save it to unlink later. The `id` field is the analysis group's own ID (usable with the /api/ext/analysis endpoints). Fields: `name`, `id`, `project_id`, `created_at`, `updated_at`, `link_id`.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Path parameters

- `agent_id` (string, required): UUID of the agent whose linked analysis groups you want to list. Get this from GET /api/ext/agent or from the create-agent response (POST /api/ext/agent).

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "analysis_groups": [
    {
      "name": "string",
      "id": "00000000-0000-4000-8000-000000000000",
      "project_id": "00000000-0000-4000-8000-000000000000",
      "created_at": "2026-01-15T12:00:00.000Z",
      "updated_at": "2026-01-15T12:00:00.000Z",
      "link_id": "00000000-0000-4000-8000-000000000000"
    }
  ]
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request GET \
  --url 'https://api.nabrah.ai/api/ext/agent/<agent_id>/analysis_groups' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/agent/<agent_id>/analysis_groups"
headers = {"X-API-Key": "<your-api-key>"}

response = requests.get(url, headers=headers)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/agent/<agent_id>/analysis_groups", {
  method: "GET",
  headers: { "X-API-Key": "<your-api-key>" },
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://api.nabrah.ai/api/ext/agent/<agent_id>/analysis_groups", nil)
	req.Header.Set("X-API-Key", "<your-api-key>")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
