Rulesets API

Rulesets define the scoring factors, weights, and thresholds used to generate underwriting recommendations. Each organization can maintain multiple rulesets and designate one as the default for automatic evaluation.

Factor weights must sum to exactly 1.0. The server validates this constraint and will reject requests where the weights do not sum correctly.

List Rulesets

Returns all rulesets for the authenticated organization, including factor definitions and threshold configuration.

NameTypeRequiredDescription
pageintegerDefault: 1Page number
per_pageintegerDefault: 25Results per page (1-100)
Request
curl https://api.banklyze.com/v1/rulesets \
  -H "Authorization: Bearer bkz_live_abc123"
200 OK
{
  "data": [
    {
      "id": 1,
      "name": "Standard MCA",
      "description": "Default ruleset for merchant cash advance underwriting",
      "is_default": true,
      "factors": [
        { "name": "revenue_stability", "weight": 0.25, "threshold": 60 },
        { "name": "average_daily_balance", "weight": 0.20, "threshold": 50 },
        { "name": "deposit_consistency", "weight": 0.20, "threshold": 55 },
        { "name": "nsf_frequency", "weight": 0.15, "threshold": 40 },
        { "name": "negative_days", "weight": 0.10, "threshold": 30 },
        { "name": "high_risk_transactions", "weight": 0.10, "threshold": 35 }
      ],
      "approval_threshold": 70,
      "decline_threshold": 40,
      "created_at": "2025-09-15T10:00:00Z",
      "updated_at": "2025-09-15T10:00:00Z"
    }
  ],
  "meta": {
    "page": 1,
    "per_page": 25,
    "total": 1,
    "total_pages": 1
  }
}

Create Ruleset

Creates a new underwriting ruleset with the specified scoring factors and decision thresholds. Factor weights must sum to exactly 1.0.

NameTypeRequiredDescription
namestringRequiredUnique name for the ruleset
descriptionstringOptionalHuman-readable description
factorsarrayRequiredArray of factor objects with name, weight (0-1), and threshold (0-100)
factors[].namestringRequiredFactor identifier (e.g. revenue_stability, nsf_frequency)
factors[].weightnumberRequiredRelative weight (all weights must sum to 1.0)
factors[].thresholdintegerRequiredMinimum score threshold for this factor (0-100)
approval_thresholdnumberRequiredComposite score at or above which deals are auto-approved
decline_thresholdnumberRequiredComposite score at or below which deals are auto-declined
Request
curl -X POST https://api.banklyze.com/v1/rulesets \
  -H "Authorization: Bearer bkz_live_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Conservative MCA",
    "description": "Stricter thresholds for high-risk verticals",
    "factors": [
      { "name": "revenue_stability", "weight": 0.30, "threshold": 70 },
      { "name": "average_daily_balance", "weight": 0.20, "threshold": 60 },
      { "name": "deposit_consistency", "weight": 0.20, "threshold": 65 },
      { "name": "nsf_frequency", "weight": 0.15, "threshold": 50 },
      { "name": "negative_days", "weight": 0.10, "threshold": 40 },
      { "name": "high_risk_transactions", "weight": 0.05, "threshold": 45 }
    ],
    "approval_threshold": 75,
    "decline_threshold": 45
  }'
201 Created
{
  "data": {
    "id": 2,
    "name": "Conservative MCA",
    "description": "Stricter thresholds for high-risk verticals",
    "is_default": false,
    "factors": [
      { "name": "revenue_stability", "weight": 0.30, "threshold": 70 },
      { "name": "average_daily_balance", "weight": 0.20, "threshold": 60 },
      { "name": "deposit_consistency", "weight": 0.20, "threshold": 65 },
      { "name": "nsf_frequency", "weight": 0.15, "threshold": 50 },
      { "name": "negative_days", "weight": 0.10, "threshold": 40 },
      { "name": "high_risk_transactions", "weight": 0.05, "threshold": 45 }
    ],
    "approval_threshold": 75,
    "decline_threshold": 45,
    "created_at": "2025-11-01T14:30:00Z",
    "updated_at": "2025-11-01T14:30:00Z"
  }
}

Get Ruleset

Returns the full details of a single ruleset, including all factor definitions and threshold configuration.

NameTypeRequiredDescription
ruleset_idintegerRequiredThe ruleset ID
Request
curl https://api.banklyze.com/v1/rulesets/2 \
  -H "Authorization: Bearer bkz_live_abc123"
200 OK
{
  "data": {
    "id": 2,
    "name": "Conservative MCA",
    "description": "Stricter thresholds for high-risk verticals",
    "is_default": false,
    "factors": [
      { "name": "revenue_stability", "weight": 0.30, "threshold": 70 },
      { "name": "average_daily_balance", "weight": 0.20, "threshold": 60 },
      { "name": "deposit_consistency", "weight": 0.20, "threshold": 65 },
      { "name": "nsf_frequency", "weight": 0.15, "threshold": 50 },
      { "name": "negative_days", "weight": 0.10, "threshold": 40 },
      { "name": "high_risk_transactions", "weight": 0.05, "threshold": 45 }
    ],
    "approval_threshold": 75,
    "decline_threshold": 45,
    "created_at": "2025-11-01T14:30:00Z",
    "updated_at": "2025-11-01T14:30:00Z"
  }
}

Update Ruleset

Partially updates a ruleset. You can update any combination of fields. If you update factors, the new weights must still sum to exactly 1.0.

NameTypeRequiredDescription
ruleset_idintegerRequiredThe ruleset ID
namestringOptionalUpdated ruleset name
descriptionstringOptionalUpdated description
factorsarrayOptionalReplacement factor array (weights must sum to 1.0)
approval_thresholdnumberOptionalUpdated approval threshold
decline_thresholdnumberOptionalUpdated decline threshold
Request
curl -X PATCH https://api.banklyze.com/v1/rulesets/2 \
  -H "Authorization: Bearer bkz_live_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Updated thresholds for Q1 2026",
    "approval_threshold": 72,
    "decline_threshold": 42
  }'
200 OK
{
  "data": {
    "id": 2,
    "name": "Conservative MCA",
    "description": "Updated thresholds for Q1 2026",
    "is_default": false,
    "factors": [
      { "name": "revenue_stability", "weight": 0.30, "threshold": 70 },
      { "name": "average_daily_balance", "weight": 0.20, "threshold": 60 },
      { "name": "deposit_consistency", "weight": 0.20, "threshold": 65 },
      { "name": "nsf_frequency", "weight": 0.15, "threshold": 50 },
      { "name": "negative_days", "weight": 0.10, "threshold": 40 },
      { "name": "high_risk_transactions", "weight": 0.05, "threshold": 45 }
    ],
    "approval_threshold": 72,
    "decline_threshold": 42,
    "created_at": "2025-11-01T14:30:00Z",
    "updated_at": "2025-12-10T09:15:00Z"
  }
}

Delete Ruleset

Permanently deletes a ruleset. The default ruleset cannot be deleted — assign a different default first. Existing recommendations that were generated with this ruleset retain their snapshot and are not affected.

NameTypeRequiredDescription
ruleset_idintegerRequiredThe ruleset ID
Request
curl -X DELETE https://api.banklyze.com/v1/rulesets/2 \
  -H "Authorization: Bearer bkz_live_abc123"
200 OK
{
  "success": true,
  "message": "Ruleset deleted"
}

Set Default Ruleset

Designates this ruleset as the organization's default. The previously default ruleset is automatically unset. New deals will use the default ruleset for automatic underwriting evaluation.

NameTypeRequiredDescription
ruleset_idintegerRequiredThe ruleset ID to set as default
Request
curl -X POST https://api.banklyze.com/v1/rulesets/2/set-default \
  -H "Authorization: Bearer bkz_live_abc123"
200 OK
{
  "data": {
    "id": 2,
    "name": "Conservative MCA",
    "description": "Updated thresholds for Q1 2026",
    "is_default": true,
    "factors": [
      { "name": "revenue_stability", "weight": 0.30, "threshold": 70 },
      { "name": "average_daily_balance", "weight": 0.20, "threshold": 60 },
      { "name": "deposit_consistency", "weight": 0.20, "threshold": 65 },
      { "name": "nsf_frequency", "weight": 0.15, "threshold": 50 },
      { "name": "negative_days", "weight": 0.10, "threshold": 40 },
      { "name": "high_risk_transactions", "weight": 0.05, "threshold": 45 }
    ],
    "approval_threshold": 72,
    "decline_threshold": 42,
    "created_at": "2025-11-01T14:30:00Z",
    "updated_at": "2025-12-10T09:20:00Z"
  }
}