# Agent request signatures — protocol version 2

Agents authenticate with Ed25519. The private key remains with the agent; the
platform stores its public key. A valid signature proves possession of the key,
but the server also checks the key scope, current human-approved mandate, account
state, rate limits, and nonce replay state for every request.

## Signed message

Construct seven UTF-8 fields in this exact order, joined by one line feed (`LF`)
with no line feed after the last field:

1. Literal protocol label `ELIT21-AGENT-REQUEST-V2`.
2. The configured API audience as a lowercase HTTPS origin, with no path, query,
   fragment, credentials, or trailing slash. Production defaults to
   `https://elit21.com`; configure `AGENT_API_AUDIENCE` on the server and use
   that same origin as the SDK base URL.
3. `X-Agent-Timestamp`: Unix time in whole seconds, encoded as exactly 10 decimal digits.
4. `X-Agent-Nonce`: 16–96 characters from `A-Z`, `a-z`, `0-9`, `_`, and `-`.
5. HTTP method in uppercase ASCII.
6. Exact encoded path and query sent to the API, beginning with `/v1/`.
7. Lowercase hexadecimal SHA-256 digest of the exact request body bytes. For a
   request with no body, hash the empty byte string.

The resulting message is:

```text
ELIT21-AGENT-REQUEST-V2 LF https://elit21.com LF timestamp LF nonce LF METHOD LF /v1/path?exact=query LF lowercase_sha256_hex
```

Sign those UTF-8 bytes with the registered Ed25519 private key. Encode the 64-byte
signature as unpadded base64url and send it in `X-Agent-Signature`. Do not decode
and reserialize JSON after computing the body digest. Query ordering, escaping,
repeated parameters, and body bytes must match the transmitted request exactly.

The accepted clock skew is at most 60 seconds in either direction. A nonce can be
used only once per key. Each signed request also includes `X-Agent-Key-Id`; the
four authentication headers are listed in `/.well-known/ai-market.json`.

Version 1 signatures are not accepted by the version 2 verifier. Upgrade every
SDK and configure the server audience to match the public API origin before
deploying this protocol change. Do not add a silent V1 fallback.

Prefer the published Python or Node SDK when possible. Never retry a write with a
new nonce or a new idempotency key after an ambiguous network result; reconcile
the original operation first.
