Skip to content

Files

Files by exact id and grants.

Updated

Agents receive files, read them and produce new ones. Files live in CloudRaker tenant storage. One rule applies: an agent reaches a file only by its exact id, and only when something granted that id to the run. There is no list, search or browse tool. An agent cannot discover the files of your org.

Send files to a run

files on POST /{agent} and POST /_run/{id} takes up to 20 entries:

{
  "input": "File this invoice",
  "files": [
    { "url": "https://example.com/invoice.pdf", "name": "invoice.pdf" },
    { "content_base64": "SGVsbG8=", "name": "note.txt", "content_type": "text/plain" },
    { "file_id": "fil_123" }
  ]
}
Entry Rule
url HTTPS only. Private addresses are refused. Max 25 MB.
content_base64 Max 5 MB. name and content_type are required.
file_id An existing tenant file, for example an artifact of another run. Your token must reach it, or the start answers 403 file_forbidden.

Every entry becomes a tenant file and a read grant on the run. The email channel of a front door turns attachments into files the same way.

Grants

A grant is a run, a file id and an access level. Grants persist across turns and end with the run.

Source Access
files on a start or a turn read
A file the agent creates with file.write write
A file_id field in a result of a built-in tool (data.*, file.*) read
A file_id field that an _apis or MCP schema marks as a file reference read
work_session: true read on the session files

A tool call that names a file without a grant answers file_forbidden. The error does not say whether the file exists.

Tools

Tool Needs What it does
file.read read Off by default. With files.read_raw: true, returns the text or base64 bytes, or Markdown when the file was parsed. Max 25 MB per read.
file.write - Creates a tenant file from bytes or from a readable file. Returns file_id and grants write.
file.replace write A new version of a file the run wrote. Input files are never replaced.
file read or write Emits the file event, the artifact for the caller.

Paperwork tools

A run that holds at least one file grant also gets the Paperwork tools. No agent.yml key is necessary. The tools call the Paperwork API backend as your org.

Tool Needs What it does
file.parse read Returns the file content as Markdown.
file.extract read Returns structured data. Takes schema, optional instructions, and optional citations: true for source grounding.
file.redact read Removes PII from a PDF, audio or video file. Returns a new file. For Word, call file.convert_pdf first.
file.markdown_to_pdf - Renders Markdown to a new PDF file. Returns its file_id.
file.form_fields read Returns the fields of a PDF form: name, label, type, options, page (from 1).
file.fill read Fills a PDF form from values, or drafts the values from source_file_ids. Writes a new PDF.
file.classify read Labels a file with one of your classes, or finds the documents of a packet page by page.
file.split read Cuts a PDF into one new PDF per page range. Returns one file_id per range.
file.redline_read read Reads a Word document: paragraphs, tracked changes, comments and a summary.
file.redline read Edits a Word document with tracked changes and comments. Writes a new .docx.
file.convert_pdf read Converts a Word, Excel, PowerPoint, image or text file to a new PDF.
file.merge read Joins 2 to 20 PDFs into one PDF, or audio files into one audio file.
file.render_page read Renders one page of a PDF as a new PNG file.
file.sign_send read Sends a PDF for e-signature by email. Returns an envelope_id. Follows the approval rules of an email send.
file.sign_status - Returns the status of an envelope. When it is signed, it saves the signed PDF in the run.
file.sign_void - Cancels an open envelope. Follows the approval rules of an email send.

A tool that writes a file grants write on the new file. The new file has the source file as its parent. The model sees the tools with _ in place of ., for example file_fill.

Each call bills your org credits at the Paperwork API rates. Read Limits and pricing. The run trace is the record of these calls: they do not show in GET /v1/runs, in the audit log or on your org webhook endpoints. A failed call returns a tool error with a code and a message. Read Errors.

Extract with source citations

Set citations: true on file_extract. The result includes value, the original file_id, the source run_id and a citations map. Each field maps to its source citations. Keep missing and uncited markers. Do not invent page locations or confidence values.

Set save_result: true to retain the exact result in a JSON file. The response includes result_file with its file and run ids. The file uses the run’s normal grants and retention. It does not replace the original source document. An agent with files.read_raw: true can read it through file_read and copy citations into records in code. Call file_extract directly, then copy the saved JSON in a separate code call. Long Paperwork calls can exceed the code timeout.

Citation pages start at zero. A bounding box uses normalized x, y, width and height, from the page’s top-left corner. The file_render_page input starts at one. Convert its page number before storing it for a document viewer.

Use the DocumentViewer Agent UI component to show page images and highlights. It checks access to both the source run and its file grants. Store file ids and citations in records. Resolve signed URLs when the viewer opens a document. Do not save signed URLs in records.

Fill a form

Call file.form_fields first to get the field names. Then call file.fill with one of these:

  • values: the values by field name. The tool fills the form as given. An unknown field name answers unknown_fields.
  • source_file_ids and optional instructions: the Paperwork API drafts the values from the source files.

output is flattened (default, the values become fixed text) or editable (the fields stay open). The fill has no review step. Use approvals in agent.yml when a person must approve the work. Only a PDF form is accepted. For a Word form, call file.convert_pdf first.

Classify and split

file.classify takes 2 to 50 classes, each with an id and a description. The tool adds the class other when you do not send it.

  • granularity: document (default) returns one class_id, a confidence from 0 to 5 and the reasoning.
  • granularity: page returns segments with start_page, end_page, class_id and confidence.

Give the segments to file.split to cut the packet. Ranges start at page 1, ascend and do not overlap. A call takes 100 ranges at most.

Redline a Word document

Call file.redline_read to get the ids. Paragraphs are p0, p1, and so on. Tracked changes are tc0, and so on, and comments are c0, and so on. view: accepted (default) applies the tracked changes. view: current shows the inserted and deleted text. A long result is cut at 200,000 characters.

file.redline takes 1 to 100 operations: replace, delete, insert (Markdown), fill, accept, reject, comment, reply and resolve. Edits are tracked by default. All accept and reject operations run first, with the ids of the last file.redline_read. The other operations run in order.

When an operation fails, the tool writes no file. The error redline_failed gives failed_index, operation and detail.code (for example anchor_not_found). Read the document again and send the corrected list. A good call writes <name>.redlined.docx. Only .docx files are accepted.

Convert, merge and render

file.convert_pdf, file.merge and file.render_page take 25 MB of input in one call at most. A run holds the bytes in memory, so these tools and file.fill run one at a time in a run. A merge takes PDFs only or audio files only. For a Word or image file, call file.convert_pdf first. file.render_page takes a page from 1 and an optional scale (default 2).

Send for signature

file.sign_send takes a PDF, 1 to 50 signers (name, email, optional routing_order), and optional cc, message, language (en or fr) and expires_in_days (1 to 6, default 5). It returns when the signers have their invitation. It does not wait for the signatures. The result has notify: true when a run gets a completion event for the envelope: the run that sent it when it is a turns run, or a new run from triggers.paperwork. A turns run that ends before the envelope gets no event without the trigger. With notify: false, call file.sign_status from a later run.

The envelope id is in the run trace as soon as the Paperwork API creates the envelope. When the send does not finish in the call, the tool returns sign_pending with the envelope_id. Do not send again: call file.sign_status.

Call file.sign_status with the envelope_id to read the status: pending, signed, declined, expired, voided or failed. failed means that the send or the seal failed (the signers can have signed already), and the result gives the error. voided means that the sender cancelled the envelope. When the envelope is signed, the tool saves the signed PDF in the run once and returns signed_file_id. An agent reads and voids only its own envelopes: the same repo and the same agent path. Any run of that agent can read or void them, for example a scheduled run. An agent with the same path in another repo of the org cannot see them.

The Paperwork API keeps an envelope for its signing deadline plus one day, and 7 days at most. The maximum deadline is 6 days, so the end of every envelope comes before the purge.

Completion events

You do not have to call file.sign_status again and again. Run reads each open envelope of a run: every minute for 10 minutes, every 5 minutes up to 2 hours, then every 15 minutes. When the envelope ends (signed, declined, expired, voided or failed), the run that sent it gets a Paperwork event:

  • For a signed envelope, Run saves the signed PDF in the run once and grants write on it. The event gives its file_id.
  • A turns run that waits for the caller starts a new turn at once. The turn text starts with Paperwork event: envelope {id} ended. and gives the status, the signed file and each signer.
  • A running run reads the event at its next step.
  • A run that waits for an approval, a question or its child agents keeps the event until it continues. The event never decides an approval and never answers a question.
  • A void from the run itself sends no event.
  • file.sign_void on an envelope that is still in preparation cancels its pipeline, so no signer gets an invitation.

When the run has ended, the event can start a new run of the agent. Add sign.ended to triggers.paperwork in agent.yml:

triggers:
  http: true # keep POST /{agent}: a triggers key turns it off when it is not true
  paperwork: [sign.ended]

The new run gets this input, and metadata.source is paperwork. Its files are the signed PDF and the file that was sent, so the agent can send again after a decline or an expiry. The input is not checked against input_schema.

{
  "event": "sign.ended",
  "envelope_id": "plr_01J...",
  "status": "signed",
  "signers": [
    { "name": "Ana Silva", "email": "ana@example.com", "signed_at": "2026-11-02T10:00:00Z" }
  ],
  "signed_file_id": "f_...",
  "from_run_id": "run_..."
}

A preview deployment never starts a new run. A run of a preview still gets the event while it is live. Without triggers.paperwork, the event of an ended run is dropped, and the agent can still call file.sign_status. A new run needs Run access and credits, as a scheduled run does. Run tries again each hour for 24 hours.

Raw reads

file.read returns no file content by default. It answers the tool error raw_read_refused, and the agent calls file.parse instead. Markdown is smaller than raw bytes and safer to put in a prompt.

Set files.read_raw: true in agent.yml when the agent needs the raw content:

files:
  read_raw: true

File artifacts

A file artifact is { file_id, name, content_type, bytes, url }. The file event carries one, and done can carry them in its result. url is a signed download URL. Read the run again with GET /_run/{id} to get a fresh URL.

The id is the capability. Pass an artifact from run A to run B, and B gets a read grant on that one file only. This is how you chain agents:

# Run A (csio) emitted: { "type": "file", "data": { "file_id": "fil_123", ... } }
# $REPO: the base path of the repo (the repo name by default).
curl -X POST "https://$ORG.cloudraker.run/$REPO/invoice-intake" \
  -H "Authorization: Bearer $RUN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "input": "Fill the intake form", "files": [{ "file_id": "fil_123" }] }'

Agents never call other agents. Your backend, or your webhook consumer, starts the next run.

Token Reaches
crk_ API key Every file in the org.
rrt_ run read token The artifacts of its run only.

Retention

An input file lives as long as the longest run that holds a grant on it. A file the run wrote follows the run retention (30 days by default), unless a later run, a record or a work session references it. The console Run detail screen lists the files of a run with their grants.

Paperwork can return a source score from zero to five when its evidence judge is enabled. This score is not a confidence percentage. Unjudged citations have no score.

Type to search…

↑↓ navigate↵ selectEsc close