Index document (POST)
Add a document to your index.
POST
/api/v1/indexIndex a document for search.
Request body
| Parameter | Type | Description |
|---|---|---|
idrequired | string | Unique identifier. |
collectionrequired | string | Collection name. |
titlerequired | string | Document title. |
contentrequired | string | Text, URL, or image URL. |
metadata | object | Optional extra data. |
Example
import { Etoile } from "@etoile-dev/client";
const etoile = new Etoile({
apiKey: process.env.ETOILE_API_KEY,
});
await etoile.index({
id: "starry-night",
collection: "paintings",
title: "The Starry Night",
content: "A swirling night sky over a village...",
metadata: {
artist: "Vincent van Gogh",
year: 1889,
},
});const response = await fetch("https://etoile.dev/api/v1/index", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ETOILE_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
id: "starry-night",
collection: "paintings",
title: "The Starry Night",
content: "A swirling night sky over a village...",
metadata: {
artist: "Vincent van Gogh",
year: 1889,
},
}),
});curl -X POST "https://etoile.dev/api/v1/index" \
-H "Authorization: Bearer $ETOILE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "starry-night",
"collection": "paintings",
"title": "The Starry Night",
"content": "A swirling night sky over a village...",
"metadata": {
"artist": "Vincent van Gogh",
"year": 1889
}
}'Response
{
"id": "starry-night",
"message": "Document indexed successfully.",
"type": "text",
"usage": 847
}Content types
The content field accepts:
- Text — indexed directly
- Website URL — content extracted automatically
- Image URL — analyzed and indexed (PNG, JPEG, WEBP, GIF, max 5MB)
Auth
Requires secret key.