# First integration test

This page is for builders who want to verify Do Not Act in minutes, not read the whole site first.

Do Not Act is a pre-action Risk Gateway. Before an agent moves capital, it asks whether the intended action is admissible now, at this size. The response is a machine-readable decision: `READY`, `CAUTION`, `DO_NOT_ACT`, or `INSUFFICIENT_EVIDENCE`.

## 1. Verify the stop signal with no account

The public proof-set accepts `X-API-Key: demo` on selected market ids. Start with a known UMA-disputed market:

```bash
curl -fsS https://donotact.com/v1/dispute/polymarket/580810 \
  -H "X-API-Key: demo"
```

Expected shape:

```json
{
  "schema_version": "donotact_dispute_v1",
  "venue": "polymarket",
  "market_id": "580810",
  "verdict": "DO_NOT_ACT",
  "no_trade_reasons": [
    {
      "class": "R8_RESOLUTION_AMBIGUITY",
      "code": "UMA_DISPUTE_DETECTED"
    }
  ],
  "not_advice": true
}
```

Then compare against a clean proof-set market:

```bash
curl -fsS https://donotact.com/v1/dispute/polymarket/541000 \
  -H "X-API-Key: demo"
```

The point of this test is discrimination: disputed markets block; clean markets do not inherit the same stop reason.

## 2. Test the action-aware Risk Gateway

Use `/v1/preflight` when your agent has an intended action and size:

```bash
curl -fsS "https://donotact.com/v1/preflight/polymarket/580810?intent=enter&side=buy_yes&notional_usd=25&max_slippage_bps=200&policy=conservative" \
  -H "X-API-Key: demo"
```

Preserve these fields in your agent log:

- `decision`
- `risk_score`
- `component_scores`
- `risk_factors`
- `blocking_reasons`
- `warning_reasons`
- `safe_operating_limits`
- `evidence_set`
- `not_advice`

Do not collapse the response to one number. The value is the enforceable stop/go object plus the reasons your agent can audit later.

## 3. Drop-in guard for a Python agent

Put this directly between signal generation and execution. Replace `demo` with your own key when you move beyond the public proof-set.

```python
import os
import requests

DONOTACT_API_KEY = os.getenv("DONOTACT_API_KEY", "demo")


def donotact_guard(
    market_id: str,
    *,
    side: str,
    notional_usd: float,
    max_slippage_bps: int = 200,
    policy: str = "conservative",
) -> dict:
    url = f"https://donotact.com/v1/preflight/polymarket/{market_id}"
    response = requests.get(
        url,
        headers={"X-API-Key": DONOTACT_API_KEY},
        params={
            "intent": "enter",
            "side": side,
            "notional_usd": notional_usd,
            "max_slippage_bps": max_slippage_bps,
            "policy": policy,
        },
        timeout=3,
    )
    response.raise_for_status()
    payload = response.json()
    decision = payload.get("decision") or payload.get("verdict")
    if decision in {"DO_NOT_ACT", "INSUFFICIENT_EVIDENCE"}:
        raise RuntimeError(
            {
                "decision": decision,
                "blocking_reasons": payload.get("blocking_reasons"),
                "no_trade_reasons": payload.get("no_trade_reasons"),
                "safe_operating_limits": payload.get("safe_operating_limits"),
                "receipt": payload.get("receipt"),
            }
        )
    return payload


# Example:
# diagnostic = donotact_guard("580810", side="buy_yes", notional_usd=25)
# execute_trade_only_after_this_line(diagnostic)
```

Operational rule: `CAUTION` must branch to an explicit local policy. `DO_NOT_ACT` and `INSUFFICIENT_EVIDENCE` should block unattended execution.

## 4. Decide if it belongs in your agent

After the two demo calls, the decision is simple:

- If your agent only needs a one-off check, use the x402 path below.
- If your agent runs continuously, create a free key and test your own markets.
- If your agent needs watchlists, webhooks, live streams, exports, receipts and higher quota, use Builder access.

Tracked next steps:

- Create a free key: `/go/docs-start`
- View Builder access: `/go/docs-pricing`
- Read x402 machine payment docs: `/go/docs-x402`
- Send your repo or trade flow for a placement review: `/go/docs-integration-help`

Free keys can call dispute, resolution-risk and action-aware preflight diagnostics inside quota. Paid access is for recurring operations: watchlists, webhooks, live streams, receipts, dispute-history export, account-managed keys and higher quota.

## 5. Agent-paid path

If your agent should pay per request instead of using an API key, use the canonical x402 route:

```bash
curl -i https://donotact.com/x402/v1/dispute/polymarket/580810
```

The server returns a payment challenge. A standard x402 client should retry with `PAYMENT-SIGNATURE`. Custom agents that can pay Polygon USDC but cannot yet build an x402 payload may retry with:

```bash
curl -fsS https://donotact.com/x402/v1/dispute/polymarket/580810 \
  -H "X-402-Tx-Hash: 0x..."
```

The transaction must match the challenge exactly: network, asset, amount and receiver. Hashes are consumed once.

## 6. The integration rule

Put Do Not Act between signal and execution:

```text
signal fires
  -> call Do Not Act with market + intended action + size
  -> if READY: continue under local policy
  -> if CAUTION: branch to explicit local policy
  -> if DO_NOT_ACT: block unattended execution
  -> if INSUFFICIENT_EVIDENCE: fail closed
```

Do Not Act does not execute trades, hold funds, sign orders, custody wallets or promise outcomes. It gives your agent a stop/go contract before an irreversible action.

## Useful next links

- Access and rate limits: `/docs/access`
- Why paid access exists: `/docs/why-pay`
- Default safety check: `/docs/default-safety-check`
- Machine payments: `/go/docs-x402`
- OpenAPI: `/openapi.json`
- MCP: `/docs/mcp`
