Collections

Collections are groups of documents that can be used and created on Scout. Each document can contain metadata and text content. The text content is chunked and used for vector search. The metadata can be used to filter and sort the documents.

POST/v1/collections/:collection_id/documents

Add Document

This endpoint allows you to upsert documents to a collection.

Require document attributes

The two required document attributes are id and text. The id is used to identify the document and the text is converted to a vector and can be used for vector search.

  • Name
    id
    Type
    string
    Description

    The ID of the source you want to add the content to. If a document with this ID exists in the collection already, it will be overwritten.

  • Name
    text
    Type
    string
    Description

    The text content to be saved.

Optional document attributes

All additional attributes on the document payload will be saved as metadata. This metadata can be used to filter and sort the documents, as well as to provide additional context to the different use cases.

Request

POST
/collections/:collection_id/documents
fetch(`https://api.scoutos.com/collections/COLLECTION_ID_HERE/documents`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_access_token',
 },
  body: JSON.stringify({
    documents: [
      {
        id: 'document_id',
        text: 'document text',
        title: 'document title',
        url: 'https://example.com',            
      },
      {
        id: 'document_id_2',
        text: 'document text 2',
        title: 'document title 2',
        label: 'document label 2',
      }
    ]
  }),
});

Response

{
  "ok": true,
}