Appearance
Files
Agents can read PDFs, images, Office documents and text files. You upload a file once, get an id, and pass the id in the files array of a run or conversation message.
Upload
POST /v1/files (scope files:write) takes a multipart body with one field named file:
bash
curl "$HEVKAR_BASE_URL/v1/files" \
-H "Authorization: Bearer $HEVKAR_API_KEY" \
-F "file=@scan.pdf"ts
import { readFile } from 'node:fs/promises';
import { createReadStream } from 'node:fs';
const a = await hevkar.files.upload(await readFile('scan.pdf'), { name: 'scan.pdf' }); // Buffer
const b = await hevkar.files.upload(createReadStream('photo.jpg')); // stream, name from the path
const c = await hevkar.files.upload(new File([bytes], 'notes.txt')); // File or Blobts
const form = new FormData();
form.append('file', new Blob([bytes]), 'scan.pdf');
const file = await fetch(`${baseUrl}/v1/files`, {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}` },
body: form,
}).then((r) => r.json());Response 201:
json
{
"id": "0b8f9a43-6f55-4a8e-8f43-0d1b1c7e2a11",
"name": "scan.pdf",
"mimeType": "application/pdf",
"size": 182044,
"pages": 3,
"sha256": "9f2c…",
"purpose": "input",
"expiresAt": "2026-11-28T10:15:00.000Z",
"createdAt": "2026-11-21T10:15:00.000Z"
}- The type is detected from the file's bytes, not from the name or the
Content-Typethe client sends. Text formats are recognized by being valid UTF-8; the extension then picks Markdown, CSV, HTML or JSON. pagesis set for PDFs. A PDF whose page count cannot be read (damaged or unusual files) is refused with422 PDF_PAGE_COUNT_UNKNOWN, since it could not be checked against page limits.- Uploaded run inputs expire (by default after 7 days) and are deleted.
- Uploads count toward the organization's storage limit (
402 STORAGE_LIMIT_REACHED).
Supported types and upload limits
| Kind | MIME types |
|---|---|
application/pdf | |
| Images | image/png, image/jpeg, image/webp, image/gif, image/tiff |
| Office | DOCX (application/vnd.openxmlformats-officedocument.wordprocessingml.document), PPTX (...presentationml.presentation) |
| Text | text/plain, text/markdown, text/html, text/csv, application/json |
Other types answer 415 FILE_TYPE_NOT_SUPPORTED. Files above the platform's upload limit (50 MB by default) answer 413 FILE_TOO_LARGE; a missing file field answers 400 FILE_REQUIRED.
Read and delete
ts
const detail = await hevkar.files.get(file.id);
// FileObject + { url, urlExpiresAt }: a signed download URL valid for a few minutes
await hevkar.files.delete(file.id); // { deleted: true }Use files in runs
ts
const result = await hevkar.agents.run('letter-analyzer', { files: [file.id] });Up to 20 file ids per run or message. Each file is checked against the agent's files settings before the run starts:
| Setting | Default | Error when violated |
|---|---|---|
acceptedMimeTypes | application/pdf, image/png, image/jpeg | 400 FILE_TYPE_NOT_ACCEPTED |
maxSizeMb | 20 (max 100) | 413 FILE_TOO_LARGE |
maxPages | 30 (max 500) | 400 FILE_TOO_MANY_PAGES |
| (PDF without a known page count) | 422 PDF_PAGE_COUNT_UNKNOWN | |
strategy | auto |
acceptedMimeTypes entries may use wildcards such as image/*. An unknown id (or a file of another project) answers 404 FILE_NOT_FOUND.
Workflow agents take run files too: their files settings apply, and nodes see the files as $files and pass them on to agents with their files expression (see Workflows).
Vision vs OCR
The strategy decides how a file reaches the model:
| Strategy | Images | PDFs | Other documents |
|---|---|---|---|
vision | sent as images | each page rendered as an image (up to maxPages) | text |
ocr | text recognized by OCR | text extracted; OCR for scanned pages | text |
auto | vision when the model has the vision capability, else ocr | text |
visionneeds a model with thevisioncapability; with another model the file falls back to text extraction.- Text extraction is done by the platform's document worker. Pages that needed OCR are metered as
ocr_pageswith the run. Plain text, Markdown, CSV and JSON are read directly. - Extracted text is wrapped as
<file name="…">…</file>in the user message and cut at 200 000 characters per file. - Vision is better for layout-heavy documents (forms, tables, handwriting, photos). OCR is cheaper for long text documents and works with any model.
The run detail (GET /v1/runs/{id}) shows the strategy used for each file in files[].strategy.
Files in knowledge
Files for data sources are uploaded to the data source itself (POST /v1/datasources/{id}/documents, multipart, up to 20 files), not through /v1/files.