Answers

How do I stop an AI agent from paying a duplicate invoice?

How do I stop an AI agent from paying a duplicate invoice?

Put one check between the agent and the payment: before it pays, the agent sends the invoice to POST https://screwtape.ai/v1/duplicate (MCP tool check_duplicate_invoice). Screwtape.ai compares it with the invoices your key recorded earlier and returns duplicate.status. Pay only when next_step.action is pass; on escalate, do not pay and hand it to a person.

Example

curl -s https://screwtape.ai/v1/duplicate \
  -H "Authorization: Bearer $SCREWTAPE_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: pay-acme-inv-42-attempt-1" \
  -d '{
    "task": "Decide whether to pay this invoice.",
    "agent_output": "{\"vendor\":\"Acme Supplies Ltd\",\"invoice_id\":\"INV 42\",\"total\":1250,\"currency\":\"USD\",\"date\":\"2026-10-03\"}",
    "duplicate": {"vendor_path": "vendor", "invoice_id_path": "invoice_id", "amount_path": "total",
                  "currency_path": "currency", "date_path": "date", "store": true}
  }' | jq '{status: .duplicate.status, action: .next_step.action, hint: .next_step.hint}'

What the statuses mean

Only keyed HMAC fingerprints of vendor, invoice number, amount and date are stored, per key, and only when store is true (kept retain_days, default 180).

Without a key

Try the response shape first with the free MCP tool try_check (fixed demo invoice, no key). A free key gives 10 calls per UTC day: POST https://screwtape.ai/v1/signup or the MCP tool get_api_key. An agent with no key can also pay per call with x402: an unpaid call returns HTTP 402 with the terms, and its next_action field says exactly what to send.

FAQ

Which status means do not pay?

duplicate and possible_duplicate. Both set next_step.action to escalate. Pay only when next_step.action is pass.

Does Screwtape store my invoices?

No. With store true it keeps keyed HMAC fingerprints of the vendor, invoice number, amount and date, per API key, for retain_days (default 180). Without store, nothing is recorded.

What does a duplicate check cost?

One call, the same as POST /v1/judge: a free key covers 10 per UTC day, or pay $0.005 USDC per call with x402. Agents pay per call automatically beyond the free tier.

Related

Screwtape.ai is an agent validation API. Facts checked against the API source on 2026-11-02.