Policy gate with a signed receipt: your JsonLogic rules vs a proposed tool call or payment

$0.005 USDC per call · Agent infrastructure · POST /api/v1/policy-gate · Id policy-gate

Evaluates your own policy (JsonLogic rules, each allow or deny, deny-overrides or first-match, default deny) against a proposed tool call, payment or action, and returns allow or deny, the rule id that decided, and a receipt signed by the hub over the hashes of the policy, the request and the decision. The receipt is the product: another agent or an auditor can verify offline which rule allowed the action. A rule that errors fails closed (deny, status unknown). Cedar and Rego answer unsupported.

What you get

An auditable allow/deny for every consequential tool call at $0.005, verifiable by anyone with the hub's public key.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/policy-gate. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/policy-gate \
  -H 'content-type: application/json' \
  -d '{"policy":{"rules":[{"id":"deny-new-payee","effect":"deny","when":{"!":{"in":[{"var":"payee"},["0x7a16fF8270133F063aAb6C9977183D9e72835428"]]}}},{"id":"allow-small","effect":"allow","when":{"<=":[{"var":"amountUsd"},25]}}]},"request":{"tool":"pay","payee":"0x7a16fF8270133F063aAb6C9977183D9e72835428","amountUsd":12.5}}'

Input

FieldTypeRequiredDescription
languagestring; one of "jsonlogic", "cedar", "rego"noDefault jsonlogic. cedar and rego return unsupported.
policyanyyesJsonLogic: { rules: [{ id, effect: allow|deny, when: <JsonLogic>, description? }] (at most 100), combining?: deny-overrides|first-match, defaultEffect?: deny|allow }. A string for cedar/rego.
requestanyyesThe proposed action as JSON (at most 65536 bytes), e.g. { tool, args, amountUsd, payee }. Rules read it with { "var": "args.amountUsd" }.

Example request body

{
  "policy": {
    "rules": [
      {
        "id": "deny-new-payee",
        "effect": "deny",
        "when": {
          "!": {
            "in": [
              {
                "var": "payee"
              },
              [
                "0x7a16fF8270133F063aAb6C9977183D9e72835428"
              ]
            ]
          }
        }
      },
      {
        "id": "allow-small",
        "effect": "allow",
        "when": {
          "<=": [
            {
              "var": "amountUsd"
            },
            25
          ]
        }
      }
    ]
  },
  "request": {
    "tool": "pay",
    "payee": "0x7a16fF8270133F063aAb6C9977183D9e72835428",
    "amountUsd": 12.5
  }
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
decisionstring; one of "allow", "deny"no
ruleIdone ofnoThe rule that decided; null when the default effect applied.
matchedRulesarray<string>no
policyHashstringnosha256 of the JCS policy.
requestHashstringnosha256 of the JCS request.
receiptBodyobjectnoExactly what the receipt digest covers.
receiptobjectnoStandalone receipt: recompute digest from `receiptBody`, then recover the EIP-191 signer and compare with the DID document's attestation key. signature is null when the hub has no attestation key configured.
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the agent-coordination-kit package.

Machine-readable