Upload documents. Search them. Ask questions.
The core DocSlurp API is intentionally small: ingest content into a workspace, retrieve relevant passages, and generate grounded answers with citations.
Set DOCSLURP_URL to your service origin and DOCSLURP_API_KEY to a key from API keys. The example uses Node.js 22 or later. New uploads create a workspace; provide workspaceId to append to one.
import { createDocSlurpClient } from '@docslurp/sdk';
import { readFile } from 'node:fs/promises';
const client = createDocSlurpClient({
apiUrl: process.env.DOCSLURP_URL!,
apiKey: process.env.DOCSLURP_API_KEY,
});
const { workspace, run } = await client.upload({
files: [{
filename: 'contract.pdf',
data: new Blob([await readFile('contract.pdf')], { type: 'application/pdf' }),
}],
});
await client.waitForRun(run.id);
const { results } = await client.search({
workspaceId: workspace.id,
q: 'auto renewal clause',
});
for (const hit of results) {
console.log(hit.text, hit.citation);
}
const answer = await client.chat({
workspaceId: workspace.id,
q: 'Which contracts renew automatically?',
});
console.log(answer.answer, answer.citations);waitForRun polls until processing completes, with a five-minute default timeout. It throws if processing fails, pauses, is cancelled, or times out. For large batches, pass { timeoutMs: 600_000 }. getRun returns the current run record.
curl -X POST "$DOCSLURP_URL/v1/ingest/bulk" \
-H "Authorization: Bearer $DOCSLURP_API_KEY" \
-F "[email protected]"The upload response includes workspace, run, and documents. Poll GET /v1/runs/<run-id>/progress before searching. Inspect availability when indexing is still finishing. Read requests and uploads with an idempotencyKey retry transient failures at most twice; search and chat are not retried automatically.
Use your own chat UI with OpenAI-compatible workspace chat, including streaming. Keep service API keys on your server; browser apps should use an authenticated session or server proxy.
ingest for uploads and URL ingestion, search for retrieval/chat, and artifacts for document reads.