POST
/
documents
/
add
import Hyperspell from 'hyperspell';

const client = new Hyperspell({
  apiKey: process.env['HYPERSPELL_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const documentStatus = await client.documents.add({ collection: 'collection', text: 'text' });

  console.log(documentStatus.id);
}

main();
{
  "id": 123,
  "status": "pending",
  "collection": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
collection
string
required

Name of the collection to add the document to. If the collection does not exist, it will be created.

text
string
required

Full text of the document.

title
string | null

Title of the document.

date
string

Date of the document. Depending on the document, this could be the creation date or date the document was last updated (eg. for a chat transcript, this would be the date of the last message). This helps the ranking algorithm and allows you to filter by date range.

source
default:
generic

Source of the document. This helps in parsing the document. Note that some sources require the document to be in a specific format.

Available options:
generic,
markdown,
chat,
email,
transcript,
legal,
website,
image,
pdf,
audio

Response

200
application/json
Successful Response
id
integer
required
status
enum<string>
required
Available options:
pending,
processing,
completed,
failed
collection
string
required