Recipe · HTTP (any language)
HTTP (any language): guard customer data with CAIN
Step by step, for an agent that exports records: install, wrap the tool, see the live decision, write and test a rule, handle approvals.
Last reviewed 2026-10-02
1 Get a key
No key yet? Create a free account (every new account starts with a 7-day trial), then copy the key from the console. Requests go from your browser straight to this site.
Give each agent its own key in production (console → Agent keys): decisions, trust history and revocation are then per agent.
2 Install
Nothing to install: one HTTP request per action.
3 Put CAIN in front of your own call site
One POST per action. Run the action only on an ALLOWED verdict that is not blocked.
curl -sS -X POST https://cainstudio.online/fabric/decisions \
-H "X-API-Key: $CAIN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"path": "/tools/export_customers", "payload": {"segment": "all", "fields": ["email", "ssn"]}, "agent_id": "customer-data-agent", "record": false}'
# run the action only when .verdict starts with ALLOWED and .blocked is false;
# a timeout or an error is a refusal, never a permitOn a refusal the agent gets the JSON decision. The tool body never runs: not on a refusal, not on a hold, not when CAIN cannot be reached.
4 See what CAIN decides for this exact call
This is the request the integration sends when the model calls export_customers with these arguments. record: false evaluates it without writing an evidence record. A new agent has no trust history, so expect REQUIRE_APPROVAL at first; destinations outside your egress allowlist are refused by the egress stage.
5 Write the rule, and test it before you save it
An export that includes social security numbers is refused; other fields export. On a list, contains means one of the items equals the value.
The panel sends the draft rule to the rule tester: it says which rule would decide the call and saves nothing. Swap in the safe arguments below to see it pass through. matches is a case-insensitive glob (*, ?), not a regular expression; conditions on one rule must all hold; the first matching rule by priority wins.
Safe arguments: {"segment": "all", "fields": ["email", "plan"]}
When it does what you want, save it from the console or with POST /fabric/tool-rules:
curl -sS -X POST https://cainstudio.online/fabric/tool-rules \
-H "X-API-Key: $CAIN_API_KEY" -H 'Content-Type: application/json' \
-d '{"name": "customer-data-guard", "effect": "deny", "priority": 10, "match_path": "/tools/export_customers", "conditions": [{"field": "fields", "op": "contains", "value": "ssn"}]}'6 Handle the calls that wait for a person
A held call is not executed. It appears in the approval queue with its exact arguments; an approval lets that one call run once. Adapters can wait instead of returning: wait_for_approval=120.
GET /fabric/approvals
7 Check it before you ship
cainstudio redteam --agent customer-data-agent # dry-runs dangerous calls; exit 2 if any would run
cainstudio decisions # what was decided, and why
cainstudio explain <decision_id>Every recorded decision is signed; Cain().verify(decision) checks its quorum certificate on your machine (Python SDK).
More
HTTP (any language), other tool types
Try CAIN-42 on your own agents
Create a free account and every new account starts with a 7-day trial of the full platform. Or try the sandbox first, with no account at all.
Create a free account → · Try the sandbox · See the whole ecosystem