# GTM Knowledge Base

> Search and list org-scoped knowledge base documents used by GTM campaigns and AI agents

Source: https://docs.graph8.com/developers/gtm-knowledge-base/

The GTM Knowledge Base stores structured documents that power your campaigns and AI agents. These endpoints let you search across KB content and list all available documents in your org's knowledge base.

---

## Search Knowledge Base

`POST /kb/search`

Performs a semantic search over your org's knowledge base and returns the most relevant document chunks ranked by score.

### Request Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `query` | string | **Yes** | The search query string |
| `limit` | integer | No | Maximum number of results to return. Range: 1–50. Default: `10` |

### Example

**cURL**

```bash
curl -X POST "https://be.graph8.com/api/v1/kb/search" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "pricing",
    "limit": 10
  }'
```

### Response

```json
{
  "data": [
    {
      "doc_path": "...",
      "section": "...",
      "title": "...",
      "content": "<500 chars>",
      "score": 0.87
    }
  ]
}
```

| Field | Type | Description |
|-------|------|-------------|
| `doc_path` | string | Path identifier of the source document |
| `section` | string | Section within the document where the chunk was found |
| `title` | string | Title of the document or section |
| `content` | string | Matched content excerpt, up to 500 characters |
| `score` | float | Relevance score for this result |

---

## List Knowledge Base Documents

`GET /kb`

Returns all documents in your org's knowledge base, including metadata about each document's structure and freshness.

### Example

**cURL**

```bash
curl "https://be.graph8.com/api/v1/kb" \
  -H "Authorization: Bearer $API_KEY"
```

### Response

```json
{
  "data": [
    {
      "doc_path": "...",
      "section": "...",
      "title": "...",
      "chunks": 3,
      "last_updated": "..."
    }
  ]
}
```

| Field | Type | Description |
|-------|------|-------------|
| `doc_path` | string | Path identifier of the document |
| `section` | string | Section label within the document |
| `title` | string | Human-readable document title |
| `chunks` | integer | Number of indexed chunks in this document |
| `last_updated` | string | ISO 8601 timestamp of the most recent update |
