Enjab Developers
Enjab RAG

REST API

Search and ingest over plain HTTP, for backends and tools that are not MCP clients.

For anything that is not an MCP client (a backend, a webhook, a script), Enjab RAG exposes two HTTP endpoints. Base URL: https://rag.enjab.ae. Every request sends an API key in the Authorization: Bearer header, see Authentication.

Semantic search over the shared knowledge. Read key.

POST /api/search
Authorization: Bearer enjabrag_YOUR_KEY
Content-Type: application/json

Body

FieldTypeDefaultNotes
querystringRequired. Natural-language query.
limitnumber8Max passages (1–50).
collectionstringglobalCollection to search.

Example

curl -s https://rag.enjab.ae/api/search \
  -H "Authorization: Bearer enjabrag_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"where do patients park?","limit":5}'

Response{ results: [...] }, ranked by similarity:

{
  "results": [
    {
      "chunk_id": "…",
      "document_id": "…",
      "idx": 0,
      "content": "Free underground parking is available on levels B1 and B2…",
      "similarity": 0.74,
      "title": "Parking info",
      "summary": "Parking and valet details for the centre.",
      "tags": ["parking", "valet"],
      "metadata": { "parking_levels": ["B1", "B2"] },
      "source_type": "text"
    }
  ]
}
fetch (JS/TS)
const res = await fetch("https://rag.enjab.ae/api/search", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ENJAB_RAG_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ query: "what time do the clinics open?", limit: 5 }),
});
const { results } = await res.json();

Ingest

Add a document. It is extracted, processed (title, summary, tags, metadata are generated automatically), chunked, embedded, and indexed. Write key.

POST /api/ingest
Authorization: Bearer enjabrag_YOUR_KEY

Accepts either a file (multipart) or JSON:

File (multipart/form-data) — field file, plus optional collection:

curl -s https://rag.enjab.ae/api/ingest \
  -H "Authorization: Bearer enjabrag_WRITE_KEY" \
  -F "file=@refund-policy.pdf"

URL or text (application/json):

# a link
curl -s https://rag.enjab.ae/api/ingest \
  -H "Authorization: Bearer enjabrag_WRITE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://enjab.ae/policies/refunds"}'

# raw text
curl -s https://rag.enjab.ae/api/ingest \
  -H "Authorization: Bearer enjabrag_WRITE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Clinic hours are 8am to 9pm daily."}'
FieldTypeNotes
filefileMultipart. PDF, Word, spreadsheet, image, audio, or text.
urlstringJSON. A web page to fetch and index.
textstringJSON. Raw text to index.
collectionstringOptional. Defaults to global (the only collection today; an unknown one fails).
titlestringOptional. Omit it, the model writes the best title.
ingest a file (JS/TS)
const form = new FormData();
form.set("file", new Blob([bytes]), "refund-policy.pdf");

const res = await fetch("https://rag.enjab.ae/api/ingest", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.ENJAB_RAG_WRITE_KEY}` },
  body: form,
});
const { id, status } = await res.json();

Response{ id, status }. status is ready or failed (with an error, HTTP 422):

{ "id": "fabe8a3a-7806-4207-a53e-91b5a4ffaceb", "status": "ready" }

Ingestion runs the full extract → process → contextualize → embed pipeline inline. Allow a few seconds, more for audio, large PDFs, or documents that produce many chunks (each chunk gets a context pass). See How it works.

Reading a full document

There is no REST "get document by id" endpoint. To pull a whole source back (after a search hit), agents use the MCP fetch tool with the document_id from the search result.

Errors

StatusMeaning
401Missing or invalid API key (or a read key on /api/ingest).
400Missing query, or no file / url / text provided.
422Ingest ran but nothing could be extracted ({ status: "failed", error }).
500Unexpected server error.

On this page