Index Management API
Index Management API
The Index Management API allows you to bulk index documents into SearchJet and delete individual documents. Use these endpoints to keep your search index up to date.
Bulk Index Documents
POST /api/v1/index/bulk
Add or update multiple documents in a single request. This is the recommended way to index content.
Authentication
Requires a Bearer token with a private key (sj_prv_):
Authorization: Bearer sj_prv_xxxxxxxxxxxxxxxx
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
documents |
array | Yes | Array of document objects |
Document Schema:
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | Unique document identifier |
title |
string | Yes | Document title |
content |
string | Yes | Full text content |
url |
string | Yes | Document URL path |
excerpt |
string | No | Short summary |
author |
string | No | Author name |
date |
string | No | Publication date (ISO 8601) |
Example Request
curl -X POST "https://app.searchjetengine.com/api/v1/index/bulk" \
-H "Authorization: Bearer sj_prv_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"documents": [
{
"id": "post-1",
"title": "Getting Started with SearchJet",
"content": "SearchJet is a powerful site search solution...",
"url": "/blog/getting-started",
"excerpt": "Learn how to set up SearchJet...",
"author": "SearchJet Team",
"date": "2024-01-15"
}
]
}'
const response = await fetch(
'https://app.searchjetengine.com/api/v1/index/bulk',
{
method: 'POST',
headers: {
'Authorization': 'Bearer sj_prv_xxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
documents: [
{
id: 'post-1',
title: 'Getting Started with SearchJet',
content: 'SearchJet is a powerful site search solution...',
url: '/blog/getting-started',
excerpt: 'Learn how to set up SearchJet...',
author: 'SearchJet Team',
date: '2024-01-15'
}
]
})
}
);
const data = await response.json();
console.log(data); // { success: true }
import httpx
response = httpx.post(
"https://app.searchjetengine.com/api/v1/index/bulk",
headers={
"Authorization": "Bearer sj_prv_xxxxxxxxxxxxxxxx",
"Content-Type": "application/json",
},
json={
"documents": [
{
"id": "post-1",
"title": "Getting Started with SearchJet",
"content": "SearchJet is a powerful site search solution...",
"url": "/blog/getting-started",
"excerpt": "Learn how to set up SearchJet...",
"author": "SearchJet Team",
"date": "2024-01-15",
}
]
},
)
data = response.json()
print(data) # {"success": true}
[
[
'id' => 'post-1',
'title' => 'Getting Started with SearchJet',
'content' => 'SearchJet is a powerful site search solution...',
'url' => '/blog/getting-started',
'excerpt' => 'Learn how to set up SearchJet...',
'author' => 'SearchJet Team',
'date' => '2024-01-15',
]
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.searchjetengine.com/api/v1/index/bulk');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer sj_prv_xxxxxxxxxxxxxxxx',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
print_r(json_decode($response, true));
?>
Response
{
"success": true
}
Delete a Document
DELETE /api/v1/index/destroy
Remove a single document from the search index.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | Document ID to delete |
Example Request
curl -X DELETE "https://app.searchjetengine.com/api/v1/index/destroy" \
-H "Authorization: Bearer sj_prv_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"id": "post-1"}'
import httpx
response = httpx.delete(
"https://app.searchjetengine.com/api/v1/index/destroy",
headers={
"Authorization": "Bearer sj_prv_xxxxxxxxxxxxxxxx",
"Content-Type": "application/json",
},
json={"id": "post-1"},
)
print(response.json()) # {"success": true}
Response
{
"success": true
}
Best Practices
- Batch documents - Send multiple documents in one request (up to 1000 per batch)
- Use stable IDs - Consistent document IDs prevent duplicates
- Update incrementally - Only index changed documents
- Handle errors - Check for
success: truein responses - Monitor index size - Use
/v1/client-infoto check your index status