# Get knowledge base by ID

GET https://services.leadconnectorhq.com/knowledge-bases/{knowledgeBaseId}

Retrieves one knowledge base by id, including name, metadata, and timestamps.
WHEN TO USE: use this when you need to inspect a single knowledge base; use listAllKnowledgeBasesPaginated to browse; use updateKnowledgeBase to rename it.
RETURNS: success and the knowledge base record.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `knowledge-bases.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `knowledgeBaseId` | string | Yes | The unique identifier of the knowledge base |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/knowledge-bases/{knowledgeBaseId}": {
      "get": {
        "summary": "Get knowledge base by ID",
        "operationId": "getKnowledgeBaseById",
        "description": "Retrieves one knowledge base by id, including name, metadata, and timestamps.\nWHEN TO USE: use this when you need to inspect a single knowledge base; use listAllKnowledgeBasesPaginated to browse; use updateKnowledgeBase to rename it.\nRETURNS: success and the knowledge base record.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "knowledgeBaseId",
            "required": true,
            "in": "path",
            "description": "The unique identifier of the knowledge base",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge base by ID retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetKnowledgeBaseByIdResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "knowledge-bases.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "GetKnowledgeBaseByIdResponseDTO": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Success status of the operation",
            "example": true
          },
          "data": {
            "description": "Knowledge base details",
            "example": {},
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "Knowledge base ID",
                    "example": "Arc9QRauPKkSuMJO8D0m"
                  },
                  "name": {
                    "type": "string",
                    "description": "Knowledge base name",
                    "example": "KB for Bot Training"
                  },
                  "nameLowerCase": {
                    "type": "string",
                    "description": "Knowledge base name in lowercase",
                    "example": "kb for bot training"
                  },
                  "locationId": {
                    "type": "string",
                    "description": "Location ID",
                    "example": "qIyivCmsuEOSnyoFYEej"
                  },
                  "deleted": {
                    "type": "boolean",
                    "description": "Whether the knowledge base is deleted",
                    "example": false
                  },
                  "createdAt": {
                    "type": "string",
                    "description": "Date when knowledge base was created",
                    "example": "2025-08-01T07:50:41.244Z"
                  },
                  "updatedAt": {
                    "type": "string",
                    "description": "Date when knowledge base was last updated",
                    "example": "2025-08-01T10:05:58.694Z"
                  },
                  "kbMetadata": {
                    "description": "Knowledge base metadata with content counts",
                    "example": {},
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "faqs": {
                            "type": "number",
                            "description": "Number of FAQs in the knowledge base",
                            "example": 2
                          },
                          "urls": {
                            "type": "number",
                            "description": "Number of URLs in the knowledge base",
                            "example": 64
                          },
                          "richText": {
                            "type": "number",
                            "description": "Number of rich text documents in the knowledge base",
                            "example": 0
                          },
                          "files": {
                            "type": "number",
                            "description": "Number of files in the knowledge base",
                            "example": 0
                          },
                          "webSearches": {
                            "type": "number",
                            "description": "Number of web searche configs in the knowledge base",
                            "example": 0
                          },
                          "tables": {
                            "type": "number",
                            "description": "Number of tables in the knowledge base",
                            "example": 0
                          }
                        },
                        "required": [
                          "faqs",
                          "urls",
                          "richText",
                          "files",
                          "webSearches",
                          "tables"
                        ],
                        "title": "KnowledgeBaseMetadataDTO"
                      }
                    ],
                    "readOnly": true
                  },
                  "isDefault": {
                    "type": "boolean",
                    "description": "Whether the knowledge base is default or not",
                    "example": false
                  },
                  "description": {
                    "type": "string",
                    "description": "Description of the knowledge base",
                    "example": "This is a knowledge base for bot training"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "nameLowerCase",
                  "locationId",
                  "deleted",
                  "createdAt",
                  "updatedAt",
                  "kbMetadata"
                ],
                "title": "GetKnowledgeBaseByIdDataDTO"
              }
            ]
          }
        },
        "required": [
          "success",
          "data"
        ],
        "title": "GetKnowledgeBaseByIdResponseDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/knowledge-bases/<knowledgeBaseId>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/knowledge-bases/<knowledgeBaseId>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/knowledge-bases/{knowledgeBaseId}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

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

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/knowledge-bases/<knowledgeBaseId>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/knowledge-bases/<knowledgeBaseId>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/knowledge-bases/<knowledgeBaseId>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

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

url = URI("https://services.leadconnectorhq.com/knowledge-bases/<knowledgeBaseId>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/knowledge-bases/<knowledgeBaseId>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
