Skip to main content
GET
/
v1
/
knowledge
/
{kb_id}
/
documents
/
{document_id}
Get Knowledge Base Document By Id
curl --request GET \
  --url https://api.xpander.ai/v1/knowledge/{kb_id}/documents/{document_id} \
  --header 'x-api-key: <api-key>'
import requests

url = "https://api.xpander.ai/v1/knowledge/{kb_id}/documents/{document_id}"

headers = {"x-api-key": "<api-key>"}

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

print(response.text)
const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};

fetch('https://api.xpander.ai/v1/knowledge/{kb_id}/documents/{document_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xpander.ai/v1/knowledge/{kb_id}/documents/{document_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://api.xpander.ai/v1/knowledge/{kb_id}/documents/{document_id}"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("x-api-key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://api.xpander.ai/v1/knowledge/{kb_id}/documents/{document_id}")
.header("x-api-key", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.xpander.ai/v1/knowledge/{kb_id}/documents/{document_id}")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
{
  "document_url": "<string>",
  "kb_id": "<string>",
  "id": "<string>",
  "organization_id": "<string>",
  "name": "<string>",
  "raw_data": "<string>",
  "local_env": false,
  "sync": false
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
Retrieve complete details about a specific document including metadata, processing status, and content information.

Path Parameters

kb_id
string
required
Unique identifier of the knowledge base (UUID format)
document_id
string
required
Unique identifier of the document (UUID format)

Response

kb_id
string
Knowledge base ID this document belongs to
id
string
Unique identifier for the document (UUID)
document_url
string
URL of the document
organization_id
string
UUID of the organization that owns this document
name
string
Document name (typically the document URL)
raw_data
string
The extracted text content of the document

Example Request

curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/knowledge/<kb-id>/documents/<document-id>"

Example Response

{
  "kb_id": "<kb-id>",
  "id": "<document-id>",
  "document_url": "https://example.com/product-guide.pdf",
  "organization_id": "<org-id>",
  "name": "https://example.com/product-guide.pdf",
  "raw_data": "The extracted text content of the document..."
}

Notes

  • The raw_data field contains the extracted text content of the document
  • Returns 404 if the document or knowledge base is not found

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

kb_id
string
required
document_id
string
required

Response

Successful Response

Represents a document item within a Knowledge Base.

Attributes: kb_id (Optional[str]): KB identifier. id (str): Document unique identifier. document_url (str): URL of the document. raw_data (Optional[str]): Raw textual data of the document. local_env (Optional[bool]): Indicates if the document is in a local environment. Defaults to False.

document_url
string
required

Document URL

kb_id
string | null

KB identifier

id
string | null

Document unique identifier

organization_id
string | null

Organization ID

name
string | null

Doc name

raw_data
string | null

Raw data (textual)

local_env
boolean | null
default:false

Is local

sync
boolean | null
default:false

Is sync?