Values and handles

Documents, recordings, images, generated PDFs and long tool results are not copied around in Hilus: each is stored once and passed by its handle. This guide shows how to find out what a handle is, read the part of it you need, look at pages and clips, pass part of a value to another call without copying it, fill a PDF form, edit and create values, store a credential, and upload a file.

What a handle is

A handle is a content hash prefixed with the value's type: pdf-aB3kQ9 is a PDF document, audio-7hT2mW a recording, tree-9gVb2kQ1 a structured tool result, markdown-Qm7xL4 a text document. The value behind it is called a dtype. This guide covers what every dtype shares; each dtype's page in the data model says how its values are written, read, queried and edited.

Describe a handle

info tells you what a handle is and where it came from: its type, its size or shape, and its provenance, the tool call that produced it and the value it was derived from.

curl -X POST "https://api.hilus.ai/Platform/dtypes/info" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "tree-9gVb2kQ1"
}'

Response:

{
  "handle": "tree-9gVb2kQ1",
  "dtype": "tree",
  "description": "(tree, AppointmentSearch, 48 leaves, depth 3)",
  "type": "AppointmentSearch",
  "size_chars": 5210,
  "provenance": [
    {
      "handle": "tree-9gVb2kQ1",
      "producer": "tool",
      "tool_name": "get_appointments",
      "tool_call_id": "call_9H1X",
      "conversation_id": "conv_789"
    }
  ]
}

Read text

get_content is how you read a value. Give it at least one of range, query or path. Without query it returns the selection verbatim; with query it searches within it. Results carry locators (PDF page and line numbers, audio time windows, tree pointers) so the next call can be narrower.

Read part of a value. range counts in the value's own unit, which its dtype page gives; for a PDF document it is pages, so this reads pages 3 and 4:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "pdf-aB3kQ9",
  "range": [
    3,
    4
  ]
}'

Response:

{
  "handle": "pdf-aB3kQ9",
  "slices": "page 3, line 1: Vaccination record\npage 3, line 2: Rabies, given 2026-03-14, due 2027-03-14\n...",
  "mode_used": null
}

Find something. With query, the default mode (auto, which resolves to hybrid) ranks passages by meaning and words together:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "pdf-aB3kQ9",
  "query": "when is the next vaccine due",
  "max_chars": 1500
}'

For an exact string or pattern, use grep mode with a little context around each match, like grep -C:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "pdf-aB3kQ9",
  "query": "invoice number",
  "mode": "grep",
  "context": 1
}'
Mode Use it for
grep Exact strings and patterns; fast.
bm25 Keyword relevance.
similarity Meaning only.
hybrid (auto) Meaning and words; the default.
match "Find every ..." and "is there any ..." questions, and what the other modes miss. A decision model checks the passages; the ones it flags come first, then the closest by ranking, and the first line says how many were flagged of how many checked. Not proof that nothing else matches; costs small model calls that grow with the value.

Read a long text. A text too long to show is first shown as an outline of its sections, each with its line range, such as ## Opening hours (lines 263-287). Pass that range to read the section (see markdown):

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "markdown-Qm7xL4",
  "range": [
    263,
    287
  ]
}'

A long text without headings, such as a transcript, is shown as a map of its parts instead, one line per part: (lines 31-58) Thanks for holding, I have the account open… [refund, invoice] gives the part's line range, how it begins, and a few words that set it apart from the other parts. Read a part with its line range in the same way, or search the text when no part looks right. A text whose parts read alike, such as rows of data or a log, has no such map and is shown as its numbered beginning and end.

A long text inside a structured result, such as the text of a fetched page, is outlined or mapped under its key in the same way. Read it with its path and a line range:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "tree-9gVb2kQ1",
  "path": "/text",
  "range": [
    263,
    287
  ]
}'

Every line number you are shown, in an outline, next to a search hit or in a read, is the number range takes.

Read a recording. A recording reads as its transcript, one window at a time:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "audio-7hT2mW",
  "range": [
    60,
    120
  ]
}'

Read structured data. Trees are read by path; that page gives the path forms and what range counts there. The confirmed appointments:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "tree-9gVb2kQ1",
  "path": "appointments[*][status=confirmed]"
}'

[!NOTE] Fetch only the part you need. Asking for a whole large document is slow and usually unnecessary: the outline you already have says where to look, and each result's locators say where to look next.

Look at pages, images and clips

Reading text is exact and cheap; looking at a page is for what text cannot show, such as layout, stamps, signatures, checkboxes and handwriting. get_media renders a value for viewing; the formats it takes and what range selects are on the pdf, image, audio and tree pages. Page 2 of a PDF as a picture:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-media" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "pdf-aB3kQ9",
  "format": "png",
  "range": [
    2,
    2
  ]
}'

Response:

{
  "handle": "pdf-aB3kQ9",
  "parts": [
    {
      "kind": "image",
      "mime": "image/png",
      "base64": "iVBORw0KGgo...",
      "meta": {
        "page": 2
      }
    }
  ]
}

A PDF's pages can also come back as a PDF of their own under a new handle, the way to pass a few pages of a long document on without the rest. A recording comes back as a link to the clip:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-media" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "audio-7hT2mW",
  "format": "mp3",
  "range": [
    60,
    90
  ]
}'

markers_only stores the page images but returns only their <attachment id="..."/> markers, which is useful when you need to forward the images rather than see them.

Pass part of a value without copying it

Any argument of any call may name a stored value instead of carrying it. <ref id="<handle>" path="/json/pointer"/> substitutes that part of the value verbatim, with its native type; a bare handle, or an <attachment id="..."/> marker, stands for the whole value where a parameter expects one. Here the text of a stored markdown value is appended to a document without being pasted into the request:

curl -X POST "https://api.hilus.ai/Platform/entities/Document/doc_456/execute-tool" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "tool_name": "append",
  "branch": "feature/new-hours",
  "arguments": {
    "lines": "<ref id=\"markdown-Qm7xL4\"/>"
  }
}'

To hand on a subset of a large result, store the selection as a new value with as_handle and pass its handle:

curl -X POST "https://api.hilus.ai/Platform/dtypes/get-content" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "tree-9gVb2kQ1",
  "path": "appointments[*][status=confirmed]",
  "as_handle": true
}'

The response's derived_handle holds only the confirmed appointments.

Fill a PDF form

Filling a form takes two calls. extract_form_fields finds the fields, each with a stable id. What it finds, and how a fill or a drawing lands, is on the pdf and image pages.

curl -X POST "https://api.hilus.ai/Platform/dtypes/extract-form-fields" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "pdf-Fm8pL2"
}'

Response:

{
  "handle": "pdf-Fm8pL2",
  "has_widgets": true,
  "engines": [
    "vision",
    "widget"
  ],
  "fields": [
    {
      "id": "p1hAB12CD34",
      "name": "Owner name",
      "type": "text",
      "value": null,
      "page": 1,
      "bbox": [
        0.12,
        0.21,
        0.4,
        0.03
      ],
      "source": "both"
    },
    {
      "id": "p1hEF56GH78",
      "name": "Consent",
      "type": "checkbox",
      "value": "false",
      "page": 1,
      "bbox": [
        0.1,
        0.8,
        0.02,
        0.02
      ],
      "source": "widget"
    }
  ]
}

Then edit fills them by id, and draw edits add text, a picture or SVG to a page:

curl -X POST "https://api.hilus.ai/Platform/dtypes/edit" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "pdf-Fm8pL2",
  "edits": [
    {
      "op": "fill",
      "field_id": "p1hAB12CD34",
      "value": "Jordan Lee"
    },
    {
      "op": "fill",
      "field_id": "p1hEF56GH78",
      "value": true
    },
    {
      "op": "draw",
      "page": 1,
      "bbox": [
        0.6,
        0.9,
        0.3,
        0.04
      ],
      "kind": "text",
      "value": "Signed on file"
    }
  ],
  "flatten": true
}'

Response:

{
  "handle": "pdf-Fm8pL2",
  "edited_ref": "pdf-Xy4nR7",
  "applied": [
    {
      "op": "fill",
      "field_id": "p1hAB12CD34",
      "via": "widget"
    },
    {
      "op": "fill",
      "field_id": "p1hEF56GH78",
      "via": "widget"
    },
    {
      "op": "draw",
      "kind": "text",
      "via": "draw"
    }
  ],
  "skipped": [],
  "engines": [
    "pdf"
  ]
}

edited_ref is the filled form; skipped lists any edit that could not be applied, with its reason.

[!WARNING] An edit never changes where the value came from. The filled PDF exists only as edited_ref until you store it somewhere: attach it to an entity, or pass it to the tool that sends or files it.

Edit text and structured values

The same route edits text values with old and new, like an entity text edit:

curl -X POST "https://api.hilus.ai/Platform/dtypes/edit" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "markdown-Qm7xL4",
  "old": "Open until 1pm",
  "new": "Open until 2pm"
}'

and structured values (trees, tables, addresses, events) with JSON Pointer ops; each dtype's page says what the pointers address:

curl -X POST "https://api.hilus.ai/Platform/dtypes/edit" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ref": "tree-9gVb2kQ1",
  "ops": [
    {
      "op": "replace",
      "path": "/appointments/0/status",
      "value": "cancelled"
    }
  ]
}'

Create a value

create builds a value from a source: literal text, a URL, or another handle. opts selects a generative path by its kind; each path and its options are on its dtype's page: render on pdf, tts on audio, generate on image. Render markdown to a PDF:

curl -X POST "https://api.hilus.ai/Platform/dtypes/create" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "dtype": "pdf",
  "source": "# Discharge summary\n\nRest for two days. Return if symptoms persist.",
  "opts": {
    "kind": "render"
  }
}'

Response:

{
  "handle": "pdf-Ds2qW8",
  "dtype": "pdf"
}

Synthesize speech from text:

curl -X POST "https://api.hilus.ai/Platform/dtypes/create" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "dtype": "audio",
  "source": "Your appointment is confirmed for Tuesday at 10am.",
  "opts": {
    "kind": "tts",
    "provider": "openai"
  }
}'

Generate an image from a prompt:

curl -X POST "https://api.hilus.ai/Platform/dtypes/create" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "dtype": "image",
  "source": "A simple line drawing of a clinic building",
  "opts": {
    "kind": "generate",
    "quality": "low",
    "size": "1024x1024"
  }
}'

Scalar and structured types need only source. Speech synthesis and image generation are paid model calls.

A credential someone gave you

When a person has told you a password, an API key or a token, store it as a secret value at once and never repeat it. create with dtype secret takes source as the value itself, even text that looks like a handle, and stores it in your organization's secret store:

curl -X POST "https://api.hilus.ai/Platform/dtypes/create" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "dtype": "secret",
  "source": "sk_live_EXAMPLE_TOKEN"
}'

Response:

{
  "handle": "secret-Vf3kP9xQ2mN8",
  "dtype": "secret"
}

Each call returns a new handle, and nothing ever returns the value. Write the handle into the field of the record that uses the credential, as you would any other value:

curl -X POST "https://api.hilus.ai/Platform/entities/MCPServer/patch" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": "mcp_963",
  "branch": "feature/front-desk",
  "commit_message": "set the help desk token",
  "ops": [
    {
      "op": "replace",
      "path": "/auth_token",
      "value": "secret-Vf3kP9xQ2mN8"
    }
  ]
}'

A record write that carries the plain value instead of a handle is refused. When nobody has given you the credential, do not ask for it in the conversation: ask with an upload link for a secret ("Ask for a secret" in Uploading large files), and the person types it on a page you never see. The secrets topic has the whole rule.

When you have a file to store

Pick the way in by where the file is. Every way ends with a handle you pass on.

curl -X POST "https://api.hilus.ai/Platform/dtypes/create" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "file": {
    "download_url": "https://files.example.com/intake-form.pdf",
    "file_id": "file_8Kc2",
    "file_name": "intake-form.pdf"
  }
}'

Response:

{
  "handle": "pdf-Fm8pL2",
  "dtype": "pdf"
}

Browser clients that hold a file in memory can also send it in one request to upload_dtype. Images, PDFs and audio are stored as their own type; anything else as a generic file.

Validate a value

validate_dtype checks a value against a type and returns the form it would be stored in, for example a phone number in international format:

curl -X POST "https://api.hilus.ai/Platform/dtypes/validate" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "dtype": "phonenumber",
  "value": "(555) 555-0143"
}'

Response:

{
  "valid": true,
  "normalized": "+15555550143",
  "failures": []
}

When a handle does not resolve

A 404 for a handle has one of four causes, deliberately indistinguishable: the handle is mistyped, it was produced in another organization, it belongs to an entity you may not read, or it never existed. Check the organization first (see the discovery topic): a handle from a support thread, for example, may live in a different organization from the configuration it is about. A 422 means the handle resolved but the operation does not apply to that type, such as page images of an audio file.

Next steps