# Output format

Every `dromas` command prints [JSON Lines](https://jsonlines.org/): one JSON object per line. The first member of each object is `type`, which names what the line reports. The only output in plain text is help, and the notice that `-h` is deprecated in favor of `--help`.

The second member of every line is `time`: the time when the client made the line, by this machine's clock, in UTC. The time is truncated to the millisecond and always has three digits after the seconds, for example `"2026-11-16T16:11:26.042Z"`. As a result, lines sorted as text are in time order. A service's log keeps the lines as the command printed them, so `time` dates each line. The only line without `time` is the `revocation_record` line that `dromas revocation make` prints, because that line is exactly the record that a server accepts, with the same members.

A command prints to stdout what it did and what it encountered along the way, including messages and refusals. A command prints only these JSON lines to stderr:

- `error`, when the command fails
- `usage_error`, when the command line is invalid
- `config_error`, when a setting in the config file, a flag, or an environment variable is invalid
- `waiting`, while the command waits

With `--log-file <file>`, `dromas recv` appends to the file the lines that it would otherwise print to stdout and stderr. If `recv` ends with an `error` line, that line goes to the file, not to stderr. A `usage_error` or `config_error` line still goes to stderr, because `recv` stops before it opens the file.

A `detail` member always contains the client's own words. It never contains words from a sender or from a server.

## Line types

| `type` | Printed by | Members |
|---|---|---|
| `message` | `recv`, `peer allow`, `inbox show` | `id`; `alias`, this mailbox's name for the sender, if the mailbox named the sender with `dromas alias add` (the name is always the mailbox's, never the sender's); then `envelope`, the envelope's checked fields: `v`, `from`, `to`, `sent_at`, `msg_id`, `body`, and, when set, `subject`, `in_reply_to`, and `supersedes`. The file `inbox/<id>.json` contains only the envelope. A file in `sent/` keeps the envelope as `envelope`, next to the server's `receipt`. The line's strings escape every invisible character: each character of Unicode's `Default_Ignorable_Code_Point`, every control character, U+FFF9 to U+FFFB, and each line break except LF. An escaped string has the same value, with nothing hidden in it |
| `message_headers` | `recv --headers`, `inbox list` | A message without any of the text that the sender chose: `id`; `alias`, as in `message`; `envelope`, without the body or subject: `v`, `from`, `to`, `sent_at`, `msg_id`, and also `in_reply_to` and `supersedes`, each when it has the form of a `msg_id`; and `body_size`, the size of the body in bytes. To print the `message` line, run `dromas inbox show <id>` |
| `refused` | `recv`, `refused list` | `id`, `code` (see Refusal codes), and `detail`. The message is kept in `refused/`. Lines from `refused list` also have `received_at`, the time that the server gives, when it has the form of a time. They then have what the checks established when they judged the message: `judged_at`, by this machine's clock; `signed_by` or `claims_identity`; and, with `signed_by`, `sent_at`, `msg_id`, and, for a message signed under a certificate, `certificate_serial`, `certificate_not_before`, and `certificate_not_after`. `signed_by` names the identity that signed the message, and appears only when two conditions are met. First, the signature verifies: either the identity made it, or a working key that the identity certified made it, under a certificate that the mailbox holds no revocation of. A working key's signature is checked at its certificate's own start, not at the time of the judgment, so this condition holds even when the certificate hasn't begun yet or has ended. Second, the mailbox holds no revocation of that address. Otherwise, the line has `claims_identity` |
| `held`, `dropped`, `duplicate` | `recv` | `id` and `detail`. A `held` line also has `from`, and the message is kept in `held/`. A `dropped` line reports a message from a sender that this mailbox blocked |
| `rate_limited`, `more` | `recv` | `detail`, and for `rate_limited`, `retry_after`. The remaining messages are still on the server: run `recv` again, after `retry_after` seconds for `rate_limited` |
| `exec_attempt_failed`, `exec_failed`, `exec_skipped` | `recv --exec` | `id` and `detail`. `exec_attempt_failed` reports one failed run of the `--exec` program for a message, and has `attempt`, then `exit_status`, `signal`, or `start_error`, and `timed_out` when `--exec-timeout` killed the run. `exec_failed` reports a message with no attempts left, and has `attempts`. `dromas status` lists the message under `attention` and in `exec_failed` until `dromas inbox retry-failed` or `dromas inbox clear-failed` takes all of them. `exec_skipped` reports a message that's due a run of the program, but that `inbox/` no longer holds as `recv` wrote it. None of these lines quotes the message or the program's output, which `dromas` discards unread |
| `webhook_attempt_failed`, `webhook_failed`, `webhook_skipped` | `recv --webhook` | `id` and `detail`. `webhook_attempt_failed` reports one failed post of a message to the webhook, and has `attempt`, then either `status` or `failure`. `status` is the HTTP status code of the endpoint's response, which can be a redirect. `failure` says, in this client's own words, why no response came. `webhook_failed` reports a message with no attempts left, and has `attempts`. `dromas status` lists the message under `attention` and in `webhook_failed` until `dromas inbox retry-failed` or `dromas inbox clear-failed` takes all of them. `webhook_skipped` reports a message that's due a post, but that `inbox/` no longer holds as `recv` wrote it. None of these lines quotes the message, the URL, the header, the secret, the response's body or headers, or the words of `net/http` errors |
| `renewal_failed`, `acl_sync_failed` | `recv`. `send` and `outbox flush` also print `acl_sync_failed`: they post anyway when the ACL that the server last accepted admits the recipient's reply | The members of an `error` line |
| `acl_replaced` | `recv` | `detail`. The server held an ACL that this mailbox didn't send, and the mailbox replaced it with its own. The other ACL came from another machine of this mailbox, from someone who holds the mailbox's pass, or from the server |
| `prekey_not_made` | `recv`, `prekey renew` | `serial`, `read_at`, and `detail`; for a statement under a certificate, `certificate_serial` and `own_certificate`; and, once the server has accepted a statement of the mailbox's own with a higher serial, `renewed_above`, the serial of that statement. When the mailbox read its own record at `read_at`, its server served a prekey statement in the mailbox's name that the mailbox didn't make. The statement is either signed by the mailbox's identity or under a certificate that the mailbox didn't make, which means someone else has the identity; or it's signed under a certificate that the mailbox made (`own_certificate`), which means someone copied the working key and the identity stored with it. In both cases, the line recommends that you revoke the address. `recv` makes no renewal with a higher serial than the statement. `dromas prekey renew` does, for an owner who knows who made the statement. That renewal takes the address back but not the identity, so the recommendation still applies. A mailbox restored from its identity alone encounters the statements of the lost machine. `status` also reports the statement until a read serves the mailbox's own |
| `lookup_failed` | `cert revoke-earlier` | The members of an `error` line. The mailbox couldn't read its own server, or the server served something that the mailbox doesn't accept, and the remedy continued from what the mailbox knows |
| `sent` | `send`, `outbox flush`, `recv --follow` | `id`, `msg_id`, `to`, and `alias` if the mailbox named the recipient |
| `queued` | `send` to a group, `outbox flush` | `msg_id`, `to`, `alias` if the mailbox named the recipient, and `at`, when the message is due. A refusal about this mailbox or the path stopped the send or the flush before this message, for as long as the server's `Retry-After` says |
| `warning` | `send` to a group that has more than 5 members besides this mailbox, before its `sent` and `queued` lines | `members`, the number of members besides this mailbox, and `detail`, which says that each member costs one of the mailbox's sends. The message is sent, and the exit status doesn't change |
| `send_failed` | `recv --follow` | `code`, `detail`, and the members of an `error` line. A flush left messages in the outbox; each one is posted again when it's due |
| `mailbox` | `init`, `addr` | `address` and `link`. From `init`, also a `detail` warning in each of these cases: the identity is of an optional key type, which only some clients verify; `init` restored the mailbox from its identity without its `allowed` and `blocked` files; or the identity key file or `rotating-keys-dir` is inside a git working tree |
| `restore` | `init --restore`, before the `mailbox` line; or, if its acknowledgment was committed and `init` then failed, before the `error` line | `acknowledged` and `detail`. `acknowledged` is `true` when `state` didn't match `prekeys/` and the mismatch is now acknowledged, and `false` when they matched and nothing changed |
| `deprecated`, `sunset` | Any command that called a server, as its last line | `version`, this client's version; `deprecated_at` or `sunset_at`, the date from which the server considers this version deprecated, or stops accepting it, from the `Deprecation` or `Sunset` header of the server's responses (`PROTOCOL.md` §11.17); and `detail`. The exit status doesn't change. `status` reports each one in its `attention` list, a deprecation only once its date has passed, and exits with `3` |
| `upgrade_available` | Any command that called a server, as its last line, at most once a day | `version`, this client's version; `latest`, the latest version that the server's document names, which is higher than this client's version in a part of the version that the document writes; and `detail`. The exit status doesn't change |
| `version` | `version`, `--version` | `version`, the tag of a release, or Go's pseudo-version between releases; `commit`, if the build recorded it; `go`; and `platform` |
| `agent`, `agent_add`, `agent_added` | `agent start`, `agent add` | `socket`, and `command`, the stock command line that `dromas` runs. `agent_add` also has `identity_file`. `agent_added`, printed once the agent holds the key, has `signer`, as `status` names it |
| `certificate_request` | `cert request` | `address`; `working_key`, the public key of the new working key, in the form that a `.pub` file holds; `lowest_serial`, the lowest certificate serial that `cert install` accepts; `max_certificate_lifetime_seconds`, the longest validity that the certificate can have; and `command`, the `ssh-keygen -s` command that certifies the working key. The command calls the identity key file `identity`: put the file's own name in its place. Run the command in the directory of the identity key file, with the working key saved there as `request.pub`. `cert install` then prints a `prekey` line |
| `agent_not_added` | Any command that unlocks the identity's key file when `add-keys-to-agent` isn't `no` | `socket` and `detail`. The agent didn't accept the key, and the command continued with the key, as ssh does |
| `prekey_lifetime` | `prekey lifetime` | `lifetime_seconds`; `lifetime`, the same value as a duration such as `8d`; and `detail`, a warning when the lifetime is short enough that one missed daily check-in leaves the mailbox unable to receive messages |
| `waiting` | Any command, on stderr, while it waits | `reason` and `detail`. `reason` is one of these values: `lock`, for this mailbox's lock, which another command on the mailbox holds; `passphrase`, for the identity's passphrase, with `identity_file`; `server`, for a server response that waiting might fix, with the members of an `error` line; or `connection`, for a held list request that dropped, with `held_seconds`, how long the server held it, and `wait_seconds` and `keep_alive_seconds` |
| `config` | `config` | `file` and `profile`, each when there is one; and `values`, which has each setting in effect, by key, with its `value` and with `from`, where the value came from |
| `config_error` | Any command, on stderr, when a setting in the config file, a flag, or an environment variable is invalid, and nothing ran (exit status `2`) | `file`, `key` when a key is at fault, and `detail` |
| `usage_error` | Any command, on stderr, when the command line is wrong (exit status `2`) | `usage`, the command's usage line; `help`, the command that shows the help; and `detail` |
| `error` | Any command, on stderr | `detail`. From `recv`, and from any command refused with `restore_required`: `fatal`, when no wait can fix the refusal (exit status `4`). From a server's response: `status`, the `code` if this client knows it, `retry_after`, and the values that the code carries, each checked against its type. Otherwise, from a mailbox in a format other than this client's: its `code` (see Refusal codes), `format`, and `client_format`. From a refusal with a code of its own: that `code` (see Refusal codes). From a locked identity: `code` with the value `identity_locked`, `identity_file`, and `agent`. Each line reports one failure. For a flush of several entries, the line has the members of the first server response, and its `detail` names each entry that failed. |

The names of the other line types say what they report. `allowed` and `blocked` carry `alias` as `sent` does. The other line types are `status`, `unknown_sender`, `allowed`, `allowed_rebuilt`, `blocked`, `alias`, `alias_removed`, `removed` (from `refused/`), `failed_retried`, `failed_cleared`, `prekey`, `certificates_revoked`, `no_earlier_certificate`, `account`, `revoked`, `not_revoked`, and `revocation_record`. `failed_cleared` comes from `inbox clear-failed`, with `count`, the number of records cleared, both those of the `--exec` programs and those of the webhook, so a message whose program and webhook both gave up counts twice. `failed_retried` comes from `inbox retry-failed`, with `count`, the number of records that it marks for the next `recv` to try again, counted in the same way. `revocation_record` is the record itself, exactly the body that every server accepts. Save it where only you can read it (`umask 077; dromas revocation make > <file>`).

## Exit codes

| Code | Meaning |
|---|---|
| `0` | Success. Refused and held messages don't change the exit code, because any sender can cause either one |
| `1` | Failure |
| `2` | An invalid command line, or an invalid setting, so nothing ran. Help that you ask for exits with `0` |
| `3` | Success, but the mailbox needs attention. From `recv`, whether or not any message arrived: the prekey wasn't renewed, the server served a prekey that the mailbox didn't make (`prekey_not_made`), the mailbox's ACL wasn't sent to its server, the server held an ACL that the mailbox didn't send, an `--exec` program ran out of tries (`exec_failed`), or the webhook ran out of tries (`webhook_failed`). From `send` and `outbox flush`: the post went ahead although the mailbox's ACL wasn't sent (`acl_sync_failed`). From `prekey renew`: `prekey_not_made`. Later runs retry. If `dromas status` still reports the problem a day later, the server is refusing the change or can't be reached. From `status`: its `attention` list isn't empty, as it is when the server has announced a sunset of this client's version or a deprecation whose date has passed |
| `4` | From `recv`: a refusal that no wait can fix, and its `error` line has `fatal`. The refusal is a revocation, no mailbox at this address with its registration refused, a mailbox in another format, a missing folder of the mailbox, this machine's clock running behind, or any other such refusal from a server or from this client. The systemd unit doesn't restart on `4`, so the service stays failed until its owner fixes the cause and starts it again. Exit status `4` also comes from any command that receives, sends, delivers, or renews, including `init` and `peer allow`, when the command is refused with `restore_required`. A restarted process gets the same refusal. By contrast, exit status `1` from `recv` is a failure that a later run might get past, and `recv --follow` repeats on its own a call that waiting might fix. Under `--follow` or `--wait`, a refusal for this machine's clock is such a call: a pass that the server refuses for its time (`pass_expired`), or the mailbox's certificate that hasn't begun by this machine's clock. `recv` tries again until the two clocks agree or the wait ends |

## Refusal codes

The `code` member of a `refused` line or an `error` line names the check that failed. The words of a refusal are the client's own, never text from the message, its sender, or the server.

| Code | Check that failed |
|---|---|
| `decrypt_error` | The message isn't encrypted to a prekey that this mailbox holds, or isn't encrypted to exactly one recipient of a prekey's type, as every server requires of a send |
| `malformed_message` | The decrypted content isn't an envelope line followed by a signature block |
| `invalid_envelope` | The envelope isn't UTF-8 JSON: one object with no key given twice, at version 1, with a body, a `msg_id`, and a `sent_at` |
| `invalid_identity` | The envelope carries no identity document, or carries one that breaks its format or fails its key checks |
| `unsupported_key_type` | The sender's identity has a key type that this client doesn't verify |
| `invalid_signature` | The message isn't signed for this mailbox by the sender's identity, or by a working key that the identity certified under a certificate that's valid at the time of the check |
| `sender_mismatch` | The envelope's `from` isn't the address of the identity that signed it |
| `recipient_mismatch` | The envelope's `to` isn't this mailbox |
| `sender_revoked` | This mailbox holds a revocation of the sender that verifies. The mailbox accepts nothing signed for that address, whenever it was signed |
| `certificate_revoked` | The message is signed under a certificate that the sender's identity revoked, by a revocation that this mailbox holds and that verifies. The address stays in use, but the mailbox accepts nothing signed under that certificate, whenever it was signed |
| `message_expired` | The message's `sent_at` is more than 7 days old, or is earlier than the oldest time that this mailbox's replay set covers |
| `message_not_yet_valid` | The message's `sent_at` is more than an hour ahead of this machine's clock |
| `message_already_received` | This mailbox already received this ciphertext |
| `id_mismatch` | The server's ID for the message isn't the SHA-256 hash of its ciphertext |
| `unsupported_prekey_type` | In the `error` line of a send: the recipient's prekey is an age recipient of a type that this client can't encrypt to, so nothing is sent |
| `identity_locked` | In the `error` line of a command that signs with the identity, when no source provides the key. Either the agent listed the key and then refused the signature or didn't answer within 2 minutes, or the agent didn't list the key and the key file is missing or has a passphrase that wasn't given or doesn't unlock it. Nothing is signed |
| `restore_required` | In the `error` line, with `fatal`, of any command that receives, sends, delivers, or renews, including `init` and `peer allow`. `prekeys/` holds a prekey, in a file named by its serial, that `state` doesn't name, as happens after `state` is lost or restored from a copy older than a renewal. Nothing is listed, acknowledged, sent, or renewed until you run `dromas init --restore`; `status` reports this |
| `unsupported_mailbox_format` | In the `error` line of any command: a newer client wrote the mailbox in a format that this client doesn't read, so this client reads and writes nothing of the mailbox. Run a newer `dromas` |
| `mailbox_upgrade_required` | In the `error` line of a command that only reads (`status`, `inbox list` and `inbox show`, `held list`, `peer list`, `alias list`, `refused list`, `prekey lifetime`): the mailbox is in an older format. `dromas recv`, or any other command that writes to the mailbox, upgrades it. After the upgrade, an older client refuses the mailbox |

## Server errors

`dromas` reports a server's error as an `error` line with the server's `status`, its `code`, the `retry_after` that it asks for, the values that the code carries, and a `detail` of the form `ERROR <status> <code>: <what the code means, in this client's words>`. `dromas` prints none of the server's own words, because whoever reads them might be a model, and the server might be hostile (`PROTOCOL.md` §11.3). For a code that this client doesn't know, or a code next to a `type` that isn't the code's own, the line has no `code`, and its `detail` is `ERROR <status>: an answer this client does not know`.
