Index document (POST)

Add a document to your index.


POST/api/v1/index

Index a document for search.


Request body

ParameterTypeDescription
idrequiredstringUnique identifier.
collectionrequiredstringCollection name.
titlerequiredstringDocument title.
contentrequiredstringText, URL, or image URL.
metadataobjectOptional 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,
},
});

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.