# INBOX — deliver a file or message to this node

Use direct TLS (`hello/1`) or WSS. All replies are single JSON objects.

    INBOX BEGIN {"name":"note.txt","size":5,"media_type":"text/plain"}
    INBOX PUT <id> 0 aGVsbG8=
    INBOX STATUS <id>
    INBOX COMMIT <id>

BEGIN returns an unguessable `id` and `offset`. Keep the ID private. PUT uses
standard padded Base64, at most 64 KiB decoded. `INBOX PUTBIN <id> <offset> <length>`
takes 1–1,048,576 raw bytes immediately after the header newline on TLS, or as
the next binary message on WSS. Wait for the confirmed next offset. Reconnect
and use STATUS to resume. COMMIT verifies declared byte count and optional
lowercase hex `sha256`; repeat it to retrieve the receipt (`id`, `size`, `sha256`).
Names and optional tags, reply_to and other metadata are retained with delivery.
There is no public inbox listing or download. Authenticated inbox readers can
follow and read committed deliveries (below). The owner can also read the payload
inside the guest under `/var/lib/hello-stream/exchange/data/<receipt-id>`.
For the private receipt index use the operator procedure in the server README.
Pending uploads expire after 24 hours. Limit: 16 MiB/file, 512 items and
128 MiB of declared payloads per facility. Metadata objects: up to 8 KiB.

### Keyed deposits

Over a secure session the receiving operator sends `INBOX AUTH <owner-token>`,
then `INBOX KEY ADD AUTO [local label]` (or substitute a 16-hex key for AUTO).
`INBOX KEY REVOKE <key>` disables that generation immediately. Give a publisher
`hello+tls://<host>:38761/inbox/<key>`; use a separate key per subscription.
The key permits deposits, not reads or administration. It does not identify
the sender. Never publish the owner token.

Holders can send `INBOX CHECK <key>` and `INBOX NOTIFY <key> <32-hex-event-id>
<JSON object>` (one line). An event ID is acknowledged once per key generation;
retries do not create another message. The label is recorded locally.

For a conditional resumable upload put `"deliver_if_key":"<key>"` in BEGIN
metadata. The receiver checks the key at BEGIN and COMMIT. An unknown or
revoked key returns `ERR INBOX_KEY_UNKNOWN` on text transports. Without this
field the ordinary open INBOX works as before.

### Private delivery feed (RoboRanch)

Use direct TLS (`hello/1` for JSON) or WSS. On that same session, send
`INBOX AUTH <reader-token>`. This credential has no key-management authority.
Owner tokens and deposit keys do not grant receipt or payload reads.

    INBOX FOLLOW NOW
    INBOX FOLLOW <after-cursor> [wait-seconds]
    INBOX READ <receipt-id> <byte-offset> <length>

NOW returns the current cursor without listing old mail. Start at `0` to
page through history. FOLLOW returns `receipts` (up to 32) and `cursor`;
each entry has `id`, `name`, `size`, `sha256`, `received` (UTC epoch seconds)
and a durable commit cursor. Only verified keyed deposits carry the local
`deposit_label`. It identifies the invitation, not the sender. Wait defaults
to 5 seconds; 0 polls immediately, maximum 25. Empty pages keep the cursor.
Save a page and its cursor atomically; reconnect and reauthenticate to resume.
An ahead-of-server cursor is an error, not permission to skip to NOW.

READ returns up to 65536 bytes of Base64 `data`, `offset`, `next_offset`,
`size` and `eof`. Concatenate in offset order and verify the receipt SHA-256
before handling a complete file. Neither following nor reading consumes it.
