MojarMojar
DevelopersRAG-API reference

Document ingestion

Index plain text and PDF files into an agent's knowledge base via the ingestion endpoints.

Use the ingestion endpoints to embed content into an agent's vector store. After a successful call the chunks are immediately available for search and RAG.

POST /documents/embed/text

Indexes a plain-text document and returns the assigned document ID and chunk count.

Authentication: Bearer API key required (see Authentication).

Request body

Prop

Type

Example

curl -X POST https://api.mojar.ai/documents/embed/text \
  -H "Authorization: Bearer nest-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": 42,
    "title": "Q2 Product Roadmap",
    "content": "This document outlines the product roadmap for Q2 2026..."
  }'
const response = await fetch("https://api.mojar.ai/documents/embed/text", {
  method: "POST",
  headers: {
    Authorization: "Bearer nest-YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    agentId: 42,
    title: "Q2 Product Roadmap",
    content: "This document outlines the product roadmap for Q2 2026...",
  }),
});

const data = await response.json();

Response — 201 Created

{
  "message": "Text content indexed successfully",
  "documentId": 1001,
  "chunkCount": 14
}

Prop

Type


POST /documents/embed/pdf

Uploads one or more PDF files and indexes their extracted text. Files are sent as multipart/form-data.

Authentication: Bearer API key required.

Limits:

  • Maximum 10 files per request.
  • Maximum 10 MB per file.
  • Only application/pdf MIME type is accepted.

Request — multipart/form-data

FieldTypeRequiredDescription
filesfile (repeatable)YesOne or more PDF files. Field name must be files.
agentIdnumberYesID of the agent that will own the documents.

Example

curl -X POST https://api.mojar.ai/documents/embed/pdf \
  -H "Authorization: Bearer nest-YOUR_API_KEY" \
  -F "agentId=42" \
  -F "files=@report.pdf;type=application/pdf" \
  -F "files=@appendix.pdf;type=application/pdf"
const form = new FormData();
form.append("agentId", "42");
form.append("files", pdfBlob1, "report.pdf");
form.append("files", pdfBlob2, "appendix.pdf");

const response = await fetch("https://api.mojar.ai/documents/embed/pdf", {
  method: "POST",
  headers: {
    Authorization: "Bearer nest-YOUR_API_KEY",
  },
  body: form,
});

const data = await response.json();

Response — 201 Created

{
  "message": "PDF files processed successfully",
  "results": [
    {
      "filename": "report.pdf",
      "documentId": 1002,
      "chunkCount": 38
    },
    {
      "filename": "appendix.pdf",
      "documentId": 1003,
      "chunkCount": 12
    }
  ]
}

Prop

Type

On this page