Foxy Audit
Request a demoRequest
← The manual

The wire format

Exactly what leaves your program, field by field. This page is a full list, not an example, because what is not sent is the point of the product.

Skip to the chapter
All chapters

What you'll learn

  • the two requests the SDK makes to your backend;
  • every field in a record, when it appears, and what the backend accepts in it;
  • what is never sent;
  • what the optional desktop signal carries.

The requests

The SDK makes two kinds of request to your backend, both with your API key. It sends records to one address:

POST <your backend URL>/v1/logs/batch
Authorization: Bearer <your API key>
Content-Type: application/json

The body is a JSON list of records, up to ten in one request. Records are grouped by key and backend address, and each goes only with the key it was made with. The request waits at most ten seconds for an answer.

It also reads your workspace's enforcement setting, every five minutes, in the background:

GET <your backend URL>/v1/policies
Authorization: Bearer <your API key>

That request carries no record. Set FOXY_ORG_POLICY=off to stop it, and FOXY_ORG_POLICY_TTL to change how often it runs. See Modes.

Give the base address as your backend URL, such as https://app.foxyaudit.tech. Sending records also works with the full ingest address, because the SDK strips the ending, but the read of your workspace's setting does not. It then fails, and only the debug log says so.

The record

Always present

Field Type What it is
event_id an id made on your machine, one for each call
client_id 32 hex characters this installation's lasting name, made up once for each key and address and kept in the spool, unless you set FOXY_CLIENT_ID
client_seq a whole number a counter for that name, added when the record is saved in the spool
event_type text interaction, stream, blocked, redacted, exception or response_blocked
commitment_alg text how the hashes were made: hmac-sha256, hmac-sha256-salted or sha256-legacy
prompt_hash 64 hex characters the commitment of the prompt
response_hash 64 hex characters the commitment of the answer
token_count a whole number a rough count of tokens, not a bill
policy_tag text the policy tag, folded to lower case
pii_signals a list of labels the kinds of personal data found, sorted, with no repeats. On a call checked before it ran, in block or redact mode, it can also hold prompt_injection or secret_key.

The counter lets the backend notice a gap: if record 41 arrives and then record 43, record 42 is missing or late. The backend then adds a client_seq_gap key to the record it stores.

Present when needed

Field When it appears
agent you passed agent= to the decorator
event_metadata at least one of the keys below applies

The SDK never sends occurred_at, a field the backend also accepts. It sends no time of its own.

Inside event_metadata

Key Set by When
decision the checks a prompt or answer check made a decision
policy_rules the checks rules fired, on the prompt or the answer. Answer rules start with response_.
blocked_reason the checks there is a main reason for the decision
ruleset_version, ruleset_hash the ruleset policy_rules is not empty
policy_tag_raw tag folding your spelling of the tag was changed by folding
system_id your settings you set a system, and it is valid
commitment_key_id the commitment key the record's hashes are made with a key, which is every record sent to the backend. 16 hex characters that name the key without giving it away. foxy explain uses it to pick the key.
egress_checked the egress check every record, since version 1.21.0: compared, or nothing_to_compare when there was no text to compare it with
egress_stopped the egress check the first record sent after the check stopped records: how many it stopped
guard_mode the decorator the mode the call ran under, observe, block or redact, after any tightening by your workspace. A record from log_interaction has none.
your own keys you, with metadata= see the warning below

A call in observe mode that nothing flagged, from a function that returns plain text and takes none of the keyword arguments listed below, has only commitment_key_id, egress_checked and guard_mode in its event_metadata (since version 1.21.0), and with no commitment key only the last two. An answer object that carries a model name, an id or token counts adds its keys, even when nothing was flagged.

When there is no system, system_id is left out, not set to null. The backend checks whether the key is there, and a null would make it refuse the whole request.

Only some metadata keys are sent. The backend accepts keys from a fixed list, and it refuses a whole request that has any other key in it. So the SDK drops a key of yours that is not on the list, with a warning, rather than send it. The metadata the decorator collects by itself is all on that list.

The list is: request_id, trace_id, session_id, provider, model, id, usage, choice_count, tool_names, retrieval_refs, decision, blocked_reason, policy_rules, ruleset_version, ruleset_hash, policy_tag_raw, system_id, commitment_key_id, egress_checked, egress_stopped and guard_mode, and client_seq_gap, which the backend adds itself. Each value, or each item of a list, may be up to 256 characters when written out, and a list may hold up to 64 items. A value over those limits is dropped too, with a warning.

What the backend accepts

The backend checks each field. The values the SDK makes itself always fit. The values you choose are checked before they are sent: agent=, client_id= or FOXY_CLIENT_ID, your own metadata, and a tag or event type you pass to log_interaction.

Field What the backend accepts
policy_tag, event_type lower-case letters, digits and _, up to 32
agent letters, digits, _ . - : / ( ) + and spaces, up to 128
client_id, from FOXY_CLIENT_ID letters, digits and _ . : -, up to 128
event_metadata the keys and limits above

If one value does not fit, the backend refuses the whole request it is in, and every record in it. So the SDK checks them first. agent=, client_id= and a tag or event type given to log_interaction raise ValueError. FOXY_CLIENT_ID is logged as an error and not used. A metadata key or value that does not fit is dropped, with a warning. A token count over 10,000,000 is sent as 10,000,000. A tag you give the decorator is checked for you: see Policies and rules.

What the decorator collects by itself

From your function's keyword arguments, when they are there: request_id, trace_id, session_id, provider, model, tool_names and retrieval_refs. Text is cut to 256 characters, list items to 128, and a list to its first 64 items.

From the answer object, when it has them: id, model, provider, token counts under usage, choice_count, and the names of any tools the model asked to call.

The SDK copies these values as your code passes them, and they are sent and linked into your chain for good. So never put personal or patient details in them, such as a patient's name in a session_id or a record number in retrieval_refs. Use ids that mean nothing outside your own systems.

The egress check

Since version 1.21.0 the SDK checks each record before it is spooled. It compares every field the record will carry with your prompt, your model's answer as the SDK reads it, an error's message, and, for a decorated function, its other text arguments, except the keyword arguments the decorator copies into the record. Case and spacing do not matter.

A record is stopped when one of its fields:

  • shares 16 or more characters with that text, across two words or with a character outside plain ASCII, so text in a language written without spaces counts too; or
  • shares with that text a value of 8 or more characters that the SDK's own checks find in the field: an email address, a card or phone number, a Social Security number written with dashes, an IP address or a secret key. A phone number written with spaces or brackets counts as one value.

A stopped record is not spooled and not sent, takes no sequence number, and nothing of it is logged. The SDK logs one warning per field, which names the field, and counts the stop. If the spool cannot keep the count, one more warning says so, because Live proof will not show that stop. The next record it sends carries the count as egress_stopped. A program that sends no other record reports nothing; the count waits in the spool for its next run. With audit_required=True, a stop raises AuditRequiredError, naming the field. The decorator's own agent= is not compared, because it is fixed when you apply the decorator; an agent you pass to log_interaction is.

A source title in retrieval_refs, or a provider name, that your prompt also quotes counts as text and stops the record, so use an id there instead. With a salt file, a stopped record's random salt stays in it; the salt holds no text.

Model names, ids, tool names, web addresses and rule ids are single words that no check flags, so a record that names its model in the system prompt is sent. Measured on the demo's and the testbed's prompts, with copies planted in a field: a copied run of 24 characters or more was caught every time, 16 most of the time, and 12 never. It is a check, measured, not a guarantee. Keep ids in these fields, never text.

Worked examples

A call in observe mode that nothing flagged. The hashes and ids here are shortened, and yours will differ:

JSON
{
  "event_id": "<a new id>",
  "client_id": "<32 hex characters>",
  "client_seq": 42,
  "event_type": "interaction",
  "commitment_alg": "hmac-sha256",
  "prompt_hash": "<64 hex characters>",
  "response_hash": "<64 hex characters>",
  "token_count": 137,
  "policy_tag": "hipaa",
  "pii_signals": [],
  "event_metadata": {
    "commitment_key_id": "<16 hex characters>",
    "egress_checked": "compared",
    "guard_mode": "observe"
  }
}

A prompt stopped in block mode:

JSON
{
  "event_id": "<a new id>",
  "client_id": "<32 hex characters>",
  "client_seq": 43,
  "event_type": "blocked",
  "commitment_alg": "hmac-sha256",
  "prompt_hash": "<64 hex characters>",
  "response_hash": "<the hash of an empty answer>",
  "token_count": 12,
  "policy_tag": "hipaa",
  "pii_signals": ["ssn_pattern"],
  "agent": "my-model",
  "event_metadata": {
    "decision": "blocked",
    "policy_rules": ["phi.ssn_pattern"],
    "blocked_reason": "phi",
    "ruleset_version": "2026.11.1",
    "ruleset_hash": "<64 hex characters>",
    "commitment_key_id": "<16 hex characters>",
    "egress_checked": "compared",
    "guard_mode": "block"
  }
}

The function never ran, so the answer's hash is the hash of an empty answer. The numbers in these examples are only there to show the shape.

What is never sent

  • Your prompt, your model's answer, or any part of either.
  • Where a rule matched, how long the match was, or the matching text.
  • Your commitment key. It is the key in the SDK's key file on your machine, or the one you set with FOXY_COMMITMENT_KEY. Only when the SDK can neither read nor make that file does it use your API key, which goes with every request. It logs a warning when that happens.
  • Your salts. They stay in your own salt file.
  • What the optional deep personal-data check found. Only the kind of thing it found is sent, such as presidio:person.
  • The note the SDK keeps when the backend refused a field. It stays in your spool, because the backend would refuse it too.
  • A record the egress check stopped, or any part of it. Only the count of stopped records is sent, on the next record.

The desktop signal

Unless you turn it off, the SDK also sends small messages to the optional desktop app on your own machine, at 127.0.0.1:9999. Each message is under 4,096 bytes of JSON, and a lost one does no harm:

JSON
{"event": "evaluating", "policy": "hipaa", "tokens": 137, "ts": 1790000000.0, "n": "<16 hex characters>", "mac": "<64 hex characters>"}

Since version 1.20.0 each message is signed, so the app can tell that it came from a program run by the same user. The desktop app makes a secret the first time it starts, in ~/.foxy_audit/ping.key, which only your user can read. The SDK reads that file, adds n, a random value, so that two identical messages are never signed alike, and adds mac: HMAC-SHA-256 of the message under the secret, over the message's JSON with its keys sorted and no spaces, ts and n included. The app ignores a message whose mac is wrong, whose ts is more than 30 seconds from its own clock, or that it has already seen.

No key file, no message. Where the desktop app has never started as this user, such as a server or a container, the SDK sends nothing. This keeps out other users' programs, not a harmful program running as you.

The three messages are:

  • evaluating: a record has been made, after its hashes, and it is about to be saved;
  • hash_ok: the record was saved in the spool, with delivery set to queued. With no API key, nothing is saved, and delivery is local_only;
  • policy_breach: a prompt or answer was stopped. It names up to eight rules.

None of them is a receipt from the backend. Turn them off with FoxyClient(desktop_ping=False).

What comes back

The backend answers each request with receipts, one for each record. The SDK keeps them in the spool. Only log_interaction hands one to your code: with audit_required on, it returns the backend's receipt for its record. A decorated function returns its own value, as it always did.

The backend, not the SDK, links each record into your chain. The SDK sends no chain hash and no time of its own: the backend works both out when the record arrives. The backend also adds keys of its own to the metadata it stores: policy_snapshot and policy_snapshot_hash, your workspace's policy when the record arrived, and client_seq_gap when a record before it is missing or late.

To read your records back, export them: the dashboard's Export page, or GET /v1/logs/export?format=json. That file is what the verifier and foxy explain read.