guard and guardIdentity return a deny decision that carries the exact Response to return. The lower-level verifyRequest returns { ok: false, reason, response }. Business denials (allowed: false from the allowance API) are deny decisions too. Malformed inputs, ZeroClick API failures, signing-secret resolution failures, and encryption failures throw ZCError.
ZCError
ZCError extends Error with a machine-readable code and a sanitized context:
context contains only sanitized operational fields: the operation, status, reason, key id, and validation issue paths. It never includes API keys, signing secrets, or request body bytes, so it is safe to log and is what onAllowanceUnavailable receives.
Narrowing with isZCError
UseisZCError to narrow an unknown error, optionally to one error code:
isZCError(error) narrows to ZCError; passing a code narrows further, at runtime and in types: inside the branch, error is ZCError & { code: "api_status_error" }.
Error codes
Sixteen codes cover the SDK. The first seven come from the core package; only the@zeroclickai/sellers/encryption subpath throws the nine JWE codes.
Core codes
JWE codes
What throws where
A duplicate usage report is not an error:
reportUsage resolves with duplicate: true and replays the stored event. Only denials and infrastructure failures throw.api_status_error.