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

# Create Hook

> Create a new hook for a lending market

Creates a risk monitor, pre-liquidation check, or post-liquidation action hook.

## Path Parameters

<ParamField path="marketId" type="string" required>Market ID.</ParamField>

## Body Parameters

<ParamField body="hookType" type="string" required>
  One of `monitorRisk`, `beforeLiquidation`, or `afterLiquidation`.
</ParamField>

<ParamField body="name" type="string">
  Display name (max 128 chars). Defaults to a name based on the hook type.
</ParamField>

<ParamField body="riskUri" type="string">
  URL to poll for risk data. Required for `monitorRisk` hooks.
</ParamField>

<ParamField body="riskFields" type="array">
  Array of field checks applied to the risk URI response. Each object has `path` (dot-notation), optional `operator` (`>`, `>=`, `<`, `<=`, `==`, `!=`), and optional `threshold`.
</ParamField>

<ParamField body="checkFrequency" type="string">
  Polling interval for `monitorRisk` hooks. One of `1m`, `5m`, `15m`, `30m`, `1h`, `6h`, `12h`, `24h`.
</ParamField>

<ParamField body="parameterChecks" type="array">
  Array of on-chain parameter checks for `beforeLiquidation` hooks. Each object has `parameter` (`healthFactor`, `collateralValue`, `debtValue`, `collateralRatio`, `interestAccrued`), `operator`, and `threshold`.
</ParamField>

<ParamField body="actionType" type="string">
  Required for `afterLiquidation` hooks. `buy` (auto-bid on auctions) or `inform` (send webhook).
</ParamField>

<ParamField body="maxBuyPrice" type="string">
  Maximum price per token for `buy` action hooks.
</ParamField>

<ParamField body="webhookUrl" type="string">
  Webhook URL for `inform` action hooks.
</ParamField>

<ParamField body="webhookPayload" type="object">
  Additional fields merged into webhook payloads.
</ParamField>

<ParamField body="triggerHookIds" type="array">
  Array of hook IDs whose failure triggers this hook. Max 10.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-stocks/api/hooks/{marketId}" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "hookType": "monitorRisk",
      "name": "External Risk Feed",
      "riskUri": "https://risk.example.com/api/score",
      "riskFields": [{"path": "score", "operator": "<", "threshold": 50}],
      "checkFrequency": "5m"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "id": "hook_002",
      "marketId": "clx_market_001",
      "hookType": "monitorRisk",
      "name": "External Risk Feed",
      "riskUri": "https://risk.example.com/api/score",
      "riskFields": [{"path": "score", "operator": "<", "threshold": 50}],
      "checkFrequency": "5m",
      "active": true,
      "executionCount": 0
    }
  }
  ```
</ResponseExample>
