Documents
Retrieve a list of documents
Retrieve a paginated list of documents for the authenticated organization.
GET
/
v1
/
namespace
/
{namespaceId}
/
documents
TypeScript
import { Agentset } from "agentset";
const agentset = new Agentset({ apiKey: 'agentset_xxx' });
const ns = agentset.namespace('ns_xxx');
const docs = await ns.documents.all();
console.log(docs);from agentset import Agentset
with Agentset(
namespace_id="ns_123",
x_tenant_id="<id>",
token="AGENTSET_API_KEY",
) as a_client:
res = a_client.documents.list(order_by="createdAt", order="desc", cursor_direction="forward", per_page=30)
while res is not None:
# Handle items
res = res.next()curl --request GET \
--url https://api.agentset.ai/v1/namespace/{namespaceId}/documents \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.agentset.ai/v1/namespace/{namespaceId}/documents', 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.agentset.ai/v1/namespace/{namespaceId}/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.agentset.ai/v1/namespace/{namespaceId}/documents"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.agentset.ai/v1/namespace/{namespaceId}/documents")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentset.ai/v1/namespace/{namespaceId}/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": [
{
"id": "<string>",
"ingestJobId": "<string>",
"name": "<string>",
"tenantId": "<string>",
"error": "<string>",
"source": {
"type": "<string>",
"text": "<string>"
},
"properties": {
"fileSize": 123,
"mimeType": "<string>"
},
"config": {
"chunkSize": 4503599627370512,
"delimiter": "<string>",
"metadata": {},
"disableImageExtraction": true,
"disableImageCaptions": true,
"chartUnderstanding": true,
"keepPageheaderInOutput": true,
"keepPagefooterInOutput": true,
"forceOcr": true,
"disableOcrMath": true,
"useLlm": true,
"chunkOverlap": 123,
"maxChunkSize": 123
},
"totalChunks": 123,
"totalTokens": 123,
"totalCharacters": 123,
"totalPages": 123,
"createdAt": "<string>",
"queuedAt": "<string>",
"preProcessingAt": "<string>",
"processingAt": "<string>",
"completedAt": "<string>",
"failedAt": "<string>"
}
],
"pagination": {
"nextCursor": "<string>",
"prevCursor": "<string>",
"hasMore": true
}
}{
"success": false,
"error": {
"code": "bad_request",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#bad-request"
}
}{
"success": false,
"error": {
"code": "unauthorized",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unauthorized"
}
}{
"success": false,
"error": {
"code": "forbidden",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#forbidden"
}
}{
"success": false,
"error": {
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#not-found"
}
}{
"success": false,
"error": {
"code": "conflict",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#conflict"
}
}{
"success": false,
"error": {
"code": "invite_expired",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#invite-expired"
}
}{
"success": false,
"error": {
"code": "unprocessable_entity",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unprocessable-entity"
}
}{
"success": false,
"error": {
"code": "rate_limit_exceeded",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#rate-limit_exceeded"
}
}{
"success": false,
"error": {
"code": "internal_server_error",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#internal-server_error"
}
}Authorizations
Default authentication mechanism
Headers
Optional tenant id to use for the request. If not provided, the namespace will be used directly. Must be alphanumeric and up to 64 characters.
Pattern:
^[A-Za-z0-9]{1,64}$Path Parameters
The id of the namespace (prefixed with ns_)
Example:
"ns_123"
Query Parameters
Comma separated list of statuses to filter by.
The status of the document.
Available options:
BACKLOG, QUEUED, QUEUED_FOR_RESYNC, QUEUED_FOR_DELETE, PRE_PROCESSING, PROCESSING, DELETING, CANCELLING, COMPLETED, FAILED, CANCELLED The field to order by. Default is createdAt.
Available options:
createdAt The order to sort by. Default is desc.
Available options:
asc, desc The ingest job ID to filter documents by.
The cursor to paginate by.
The direction to paginate by.
Available options:
forward, backward The number of records to return per page.
Required range:
1 <= x <= 100⌘I
TypeScript
import { Agentset } from "agentset";
const agentset = new Agentset({ apiKey: 'agentset_xxx' });
const ns = agentset.namespace('ns_xxx');
const docs = await ns.documents.all();
console.log(docs);from agentset import Agentset
with Agentset(
namespace_id="ns_123",
x_tenant_id="<id>",
token="AGENTSET_API_KEY",
) as a_client:
res = a_client.documents.list(order_by="createdAt", order="desc", cursor_direction="forward", per_page=30)
while res is not None:
# Handle items
res = res.next()curl --request GET \
--url https://api.agentset.ai/v1/namespace/{namespaceId}/documents \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.agentset.ai/v1/namespace/{namespaceId}/documents', 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.agentset.ai/v1/namespace/{namespaceId}/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.agentset.ai/v1/namespace/{namespaceId}/documents"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.agentset.ai/v1/namespace/{namespaceId}/documents")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentset.ai/v1/namespace/{namespaceId}/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": [
{
"id": "<string>",
"ingestJobId": "<string>",
"name": "<string>",
"tenantId": "<string>",
"error": "<string>",
"source": {
"type": "<string>",
"text": "<string>"
},
"properties": {
"fileSize": 123,
"mimeType": "<string>"
},
"config": {
"chunkSize": 4503599627370512,
"delimiter": "<string>",
"metadata": {},
"disableImageExtraction": true,
"disableImageCaptions": true,
"chartUnderstanding": true,
"keepPageheaderInOutput": true,
"keepPagefooterInOutput": true,
"forceOcr": true,
"disableOcrMath": true,
"useLlm": true,
"chunkOverlap": 123,
"maxChunkSize": 123
},
"totalChunks": 123,
"totalTokens": 123,
"totalCharacters": 123,
"totalPages": 123,
"createdAt": "<string>",
"queuedAt": "<string>",
"preProcessingAt": "<string>",
"processingAt": "<string>",
"completedAt": "<string>",
"failedAt": "<string>"
}
],
"pagination": {
"nextCursor": "<string>",
"prevCursor": "<string>",
"hasMore": true
}
}{
"success": false,
"error": {
"code": "bad_request",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#bad-request"
}
}{
"success": false,
"error": {
"code": "unauthorized",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unauthorized"
}
}{
"success": false,
"error": {
"code": "forbidden",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#forbidden"
}
}{
"success": false,
"error": {
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#not-found"
}
}{
"success": false,
"error": {
"code": "conflict",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#conflict"
}
}{
"success": false,
"error": {
"code": "invite_expired",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#invite-expired"
}
}{
"success": false,
"error": {
"code": "unprocessable_entity",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unprocessable-entity"
}
}{
"success": false,
"error": {
"code": "rate_limit_exceeded",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#rate-limit_exceeded"
}
}{
"success": false,
"error": {
"code": "internal_server_error",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#internal-server_error"
}
}