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

# External Vendor Rules

> Register and manage rules from third-party vendors — Chainalysis, TRM Labs, Sardine — as named rules in Corsa's transaction monitoring engine.

External rules let you register rule identifiers from third-party vendors (Chainalysis, TRM Labs, Sardine, etc.) as named entities within Corsa. When an alert arrives from a vendor integration, Corsa matches it against your registered external rules to surface rule names and descriptions in the compliance UI.

Full API endpoint details are available in the [API Reference](https://api.corsa.finance/api-spec.json) (requires API credentials).

<Note>
  All SDK examples assume you have initialized the Corsa client as shown in the [Node.js SDK Configuration](/sdk/configuration) or [Python SDK Configuration](/sdk/python-configuration) guide.
</Note>

***

## Overview

When a third-party vendor (such as Chainalysis or TRM Labs) fires an alert, it includes a vendor-specific rule ID. Without external rules configured, analysts see a raw ID. By registering your external rules in Corsa, alerts from your vendors display human-readable names and descriptions instead.

External rules have the same lifecycle as internal rules — `draft`, `active`, `disabled` — and appear alongside internal rules in the Corsa UI.

<Note>
  The `vendorName` field cannot be set to `Corsa` — that value is reserved for rules authored inside the platform.
</Note>

***

## Create an External Rule

**Endpoint:** `POST /v1/external-rules`

<CodeGroup>
  ```json REST API theme={null}
  POST /v1/external-rules
  Content-Type: application/json

  {
    "name": "High-Risk Wallet Exposure",
    "description": "Flags transactions involving wallets with high-risk exposure scores from Chainalysis",
    "vendorName": "Chainalysis",
    "externalRuleId": "rule_chainalysis_high_risk_001"
  }
  ```

  ```typescript Javascript theme={null}
  const rule = await corsa.externalRules.createExternalRule({
    name: "High-Risk Wallet Exposure",
    description: "Flags transactions involving wallets with high-risk exposure scores from Chainalysis",
    vendorName: "Chainalysis",
    externalRuleId: "rule_chainalysis_high_risk_001",
  });
  ```

  ```python Python theme={null}
  from corsa_sdk.api.external_rules.create_external_rule import _get_kwargs
  from corsa_sdk.models.create_external_rule_dto import CreateExternalRuleDto

  resp = http.request(**_get_kwargs(
      body=CreateExternalRuleDto(
          name="High-Risk Wallet Exposure",
          description="Flags transactions involving wallets with high-risk exposure scores from Chainalysis",
          vendor_name="Chainalysis",
          external_rule_id="rule_chainalysis_high_risk_001",
      ),
  ))
  rule = resp.json()
  ```
</CodeGroup>

### Request Fields

| Field            | Required | Description                                                                  |
| ---------------- | -------- | ---------------------------------------------------------------------------- |
| `name`           | Yes      | Human-readable rule name shown in the Corsa UI                               |
| `vendorName`     | Yes      | Name of the vendor providing this rule (e.g. `Chainalysis`, `TRM Labs`)      |
| `description`    | No       | Explanation of what the rule detects                                         |
| `externalRuleId` | No       | The rule's identifier in the vendor's system — used to match incoming alerts |

***

## List External Rules

**Endpoint:** `GET /v1/external-rules`

Returns a paginated list of all external rules for the platform.

<CodeGroup>
  ```json REST API theme={null}
  GET /v1/external-rules?page=1&limit=20
  ```

  ```typescript Javascript theme={null}
  const rules = await corsa.externalRules.listExternalRules({ page: 1, limit: 20 });
  ```

  ```python Python theme={null}
  from corsa_sdk.api.external_rules.list_external_rules import _get_kwargs

  resp = http.request(**_get_kwargs(page=1, limit=20))
  rules = resp.json()
  ```
</CodeGroup>

### Filter by Vendor

Use the `GET /v1/external-rules/vendors` endpoint to retrieve the distinct vendor names in use — useful for building filter UIs or auditing which vendors have rules registered.

```json REST API theme={null}
GET /v1/external-rules/vendors
```

***

## Get an External Rule

**Endpoint:** `GET /v1/external-rules/{id}`

<CodeGroup>
  ```json REST API theme={null}
  GET /v1/external-rules/rule_abc123
  ```

  ```typescript Javascript theme={null}
  const rule = await corsa.externalRules.getExternalRule("rule_abc123");
  ```

  ```python Python theme={null}
  from corsa_sdk.api.external_rules.get_external_rule import _get_kwargs

  resp = http.request(**_get_kwargs(id="rule_abc123"))
  rule = resp.json()
  ```
</CodeGroup>

***

## Update an External Rule

**Endpoint:** `PUT /v1/external-rules/{id}`

All fields are optional — only include the fields you want to change.

<CodeGroup>
  ```json REST API theme={null}
  PUT /v1/external-rules/rule_abc123
  Content-Type: application/json

  {
    "name": "High-Risk Wallet Exposure (Updated)",
    "description": "Updated description after Chainalysis rule definition change"
  }
  ```

  ```typescript Javascript theme={null}
  const updated = await corsa.externalRules.updateExternalRule("rule_abc123", {
    name: "High-Risk Wallet Exposure (Updated)",
    description: "Updated description after Chainalysis rule definition change",
  });
  ```

  ```python Python theme={null}
  from corsa_sdk.api.external_rules.update_external_rule import _get_kwargs
  from corsa_sdk.models.update_external_rule_dto import UpdateExternalRuleDto

  resp = http.request(**_get_kwargs(
      id="rule_abc123",
      body=UpdateExternalRuleDto(
          name="High-Risk Wallet Exposure (Updated)",
          description="Updated description after Chainalysis rule definition change",
      ),
  ))
  updated = resp.json()
  ```
</CodeGroup>

***

## Delete an External Rule

**Endpoint:** `DELETE /v1/external-rules/{id}`

Soft-deletes the rule. The rule is removed from active matching but its history is preserved for audit purposes.

<CodeGroup>
  ```json REST API theme={null}
  DELETE /v1/external-rules/rule_abc123
  ```

  ```typescript Javascript theme={null}
  await corsa.externalRules.deleteExternalRule("rule_abc123");
  ```

  ```python Python theme={null}
  from corsa_sdk.api.external_rules.delete_external_rule import _get_kwargs

  http.request(**_get_kwargs(id="rule_abc123"))
  ```
</CodeGroup>

***

## Rule Response Object

```json theme={null}
{
  "id": "rule_abc123",
  "version": 1,
  "status": "active",
  "isExternalRule": true,
  "name": "High-Risk Wallet Exposure",
  "description": "Flags transactions involving wallets with high-risk exposure scores from Chainalysis",
  "vendorName": "Chainalysis",
  "externalRuleId": "rule_chainalysis_high_risk_001",
  "createdBy": "user_xyz",
  "createdAt": "2024-01-15T10:00:00Z"
}
```
