> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trustgated.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Protocol Guard

> Check a wallet against a context. Register channels only if you want saved rules. Free.

## When to use this

Use Protocol Guard when you want a **context-aware check** (borrow, vote, treasury) and optional alerts, and you do not need a signed attestation. If you need something a contract can verify, use [gating](/integrate/gating) instead.

## Anonymous check

Works with no registration. **No CORS** — call from your backend. On testnet, an unpaid/unavailable oracle falls back to score **50**. Mainnet fails closed. Registrations and alerts are in-process memory.

```bash theme={null}
curl -X POST https://www.trustgated.xyz/api/protocol-guard/check \
  -H "Content-Type: application/json" \
  -d "{
    \"wallet\": \"0x…\",
    \"context\": \"borrow\",
    \"amount\": 50000,
    \"economicReachUsd\": 50000
  }"
```

`context`: `borrow | vote | governance_vote | dex_swap | api_execution | treasury_control | generic`. Unknown values fall back to `generic`.

Optional overrides: `minScore`, `minConfidence`, `voteClusterThreshold`, `proposalId`, `recentVoters`, `capitalAccess`, `subscriptionId`, `protocolName`.

Response includes:

```json theme={null}
{
  "allowed": false,
  "walletScore": 32,
  "walletTier": "LOW",
  "confidence": 45,
  "flags": [],
  "contextualThreshold": {
    "action": "borrow",
    "minTier": "HIGH",
    "minScore": 60,
    "minConfidence": 50,
    "description": "Borrowing: HIGH or above with minimum confidence"
  },
  "trustSurfaceArea": {
    "surfaceArea": 41,
    "priority": "review",
    "factors": {}
  },
  "alerts": [],
  "reasons": [],
  "pricing": "free",
  "disclaimer": "TrustGate provides a behavioral trust signal free for protocol integrations. The protocol owns access policy. Not a credit decision."
}
```

Recommended default floors live on the [product page](/products/protocol-guard). They are defaults. You own policy.

## Register (optional)

```json theme={null}
POST /api/protocol-guard/subscribe
{
  "protocolName": "my-dao",
  "contactEmail": "risk@example.com",
  "channels": {
    "discordWebhookUrl": "https://discord.com/api/webhooks/…",
    "emailTo": "risk@example.com",
    "onchainEvent": false
  },
  "rules": [
    {
      "id": "low-borrow",
      "type": "lending_low_trust_borrow",
      "enabled": true,
      "minScore": 60,
      "minConfidence": 50
    }
  ]
}
```

Rule types: `lending_low_trust_borrow`, `dao_coordinated_vote`, `wallet_score_floor`, `token_flag_watch`.

`201` returns the subscription including `manageToken` **once**. Store it. You need it to GET-by-id or PATCH via `/api/protocol-guard/subscriptions` (`Authorization: Bearer <token>`, or `?token=`).

Omit `subscriptionId` on later checks and they still work (anonymous free config).

<Warning>
  Registrations live in process memory. They vanish on restart and do not span Vercel isolates. Fine for a pilot. Not a production pager.
</Warning>

## Next

<CardGroup cols={2}>
  <Card title="Protocol Guard product" icon="bell" href="/products/protocol-guard">
    Contexts, surface area, and status.
  </Card>

  <Card title="Attestations" icon="file-signature" href="/integrate/gating">
    When you need a signature, not an alert.
  </Card>
</CardGroup>
