Rule and Rulebook Management APIs

The Rule and Rulebook Management APIs enable the creation, updating, retrieval, and management of rules and rulebooks in the Ledger system. These APIs define logic, triggers, and parameters for automating processes, ensuring flexibility and efficiency in managing business workflows.

Rulebook Management

1. Create or Update Rulebook

This allows grouping related rules into a rulebook for streamlined management and execution. For example, a financial institution can create a rulebook for compliance checks and update it with new regulations.

post

Creates a new rulebook.

Body

Agent supplied information about a rulebook.

@typestring · enumRequiredPossible values:
namestringRequired

The name assigned to the rulebook by the agent.

Responses
200

Response to /api/v1/rulebook/

application/json
post
/api/v1/rulebook/
POST /api/v1/rulebook/ HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 69

{
  "@type": "cac_ledger_schema_info_ledger_rulebook_info",
  "name": "text"
}
{
  "@type": "cac_ledger_schema_element_ledger_rulebook_elem",
  "created_at": "2025-12-06T05:23:21.801Z",
  "id": 1,
  "info": {
    "@type": "cac_ledger_schema_info_ledger_rulebook_info",
    "name": "text"
  },
  "updated_at": "2025-12-06T05:23:21.801Z"
}

2. Retrieve Rulebook

Retrieve a rulebook to review its structure and rules for auditing or analysis. For instance, a compliance officer can fetch a "Fraud Detection" rulebook to evaluate its triggers and logic.

get

Retrieves an existing rulebook and its included data.

Path parameters
namestringRequired
Query parameters
datastringRequired
Responses
200

Response to /api/v1/rulebook/{name:[^*]+}

application/json
get
/api/v1/rulebook/{name:[^*]+}
GET /api/v1/rulebook/{name:[^*]+}?data=text HTTP/1.1
Host: 
Accept: */*
{
  "@type": "cac_ledger_schema_data_ledger_rulebook_data",
  "created_at": "2025-12-06T05:23:21.801Z",
  "id": 1,
  "info": {
    "@type": "cac_ledger_schema_info_ledger_rulebook_info",
    "name": "text"
  },
  "rules": [
    {
      "created_at": "2025-12-06T05:23:21.801Z",
      "id": 1,
      "info": {
        "@type": "cac_ledger_schema_info_ledger_rule_info",
        "name": "text",
        "parameters": [
          "text"
        ],
        "triggers": [
          "INSTRUCTION"
        ]
      },
      "revision": 1,
      "status": "DISABLED",
      "updated_at": "2025-12-06T05:23:21.801Z"
    }
  ],
  "updated_at": "2025-12-06T05:23:21.801Z"
}

3. List Rulebooks

Provides an overview of all rulebooks for tracking and management. For example, an administrator can list all active rulebooks to monitor their usage and update schedules.

get

Queries the recorded rulebooks.

Query parameters
filterstringOptional
page[size]stringOptional
page[number]stringOptional
sortstringOptional
Responses
200

Response to /api/v1/rulebook/

No content

get
/api/v1/rulebook/
GET /api/v1/rulebook/ HTTP/1.1
Host: 
Accept: */*

No content


Rule Management

1. Create or Update Rule

Allows adding or updating rules to automate specific processes. For example, a new rule can be added to trigger a reconciliation process when a balance discrepancy is detected.

post

Adds a rule to a rulebook.

Path parameters
rulebookstringRequired
Body

Agent supplied information about a rule.

@typestring · enumRequiredPossible values:
namestringRequired

The name assigned to the rule

parametersstring[]Required

Parameters that are supplied to the rule's script.

Responses
200

Response to /api/v1/rulebook/{rulebook:[^*]+}

application/json
post
/api/v1/rulebook/{rulebook:[^*]+}
POST /api/v1/rulebook/{rulebook:[^*]+} HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 114

{
  "@type": "cac_ledger_schema_info_ledger_rule_info",
  "name": "text",
  "parameters": [
    "text"
  ],
  "triggers": [
    "INSTRUCTION"
  ]
}
{
  "@type": "cac_ledger_schema_element_ledger_rule_elem",
  "created_at": "2025-12-06T05:23:21.801Z",
  "id": 1,
  "info": {
    "@type": "cac_ledger_schema_info_ledger_rule_info",
    "name": "text",
    "parameters": [
      "text"
    ],
    "triggers": [
      "INSTRUCTION"
    ]
  },
  "revision": 1,
  "rulebook": {
    "@type": "cac_ledger_schema_element_ledger_rulebook_elem",
    "created_at": "2025-12-06T05:23:21.801Z",
    "id": 1,
    "info": {
      "@type": "cac_ledger_schema_info_ledger_rulebook_info",
      "name": "text"
    },
    "updated_at": "2025-12-06T05:23:21.801Z"
  },
  "status": "DISABLED",
  "updated_at": "2025-12-06T05:23:21.801Z"
}

2. Retrieve Rule

Retrieve rule details to review its triggers, logic, and configuration. For instance, an auditor can fetch a "Transaction Threshold" rule to ensure it aligns with organizational policies.

get

Retrieves a rule and its included scripts

Path parameters
rulebookstringRequired
rulestringRequired
Query parameters
datastringRequired
Responses
200

Response to /api/v1/rulebook/{rulebook:[^]+}/{rule:[^]+}

application/json
get
/api/v1/rulebook/{rulebook:[^*]+}/{rule:[^*]+}
GET /api/v1/rulebook/{rulebook:[^*]+}/{rule:[^*]+}?data=text HTTP/1.1
Host: 
Accept: */*
{
  "@type": "cac_ledger_schema_data_ledger_rule_data",
  "created_at": "2025-12-06T05:23:21.801Z",
  "id": 1,
  "info": {
    "@type": "cac_ledger_schema_info_ledger_rule_info",
    "name": "text",
    "parameters": [
      "text"
    ],
    "triggers": [
      "INSTRUCTION"
    ]
  },
  "revision": 1,
  "scripts": [
    {
      "created_at": "2025-12-06T05:23:21.801Z",
      "info": {
        "@type": "cac_ledger_schema_info_ledger_script_info",
        "basis": [
          "text"
        ],
        "language": "INTRINSIC",
        "source": "text"
      },
      "version": 1
    }
  ],
  "status": "DISABLED",
  "updated_at": "2025-12-06T05:23:21.801Z"
}

3. List Rules

Helps analyze and manage all rules in a rulebook. For example, a compliance manager can view all rules in a "Data Validation" rulebook to check for redundancies.

get

Queries the recorded rules.

Query parameters
filterstringOptional
page[size]stringOptional
page[number]stringOptional
sortstringOptional
Responses
200

Response to /api/v1/rulebook/*/

No content

get
/api/v1/rulebook/*/
GET /api/v1/rulebook/*/ HTTP/1.1
Host: 
Accept: */*

No content

4. Transition Rule Status

Enables dynamically enabling or disabling rules as needed. For example, deactivate a rule for seasonal discounts after the promotional period ends.

put

Changes the status of a rule (idempotent)

Path parameters
rulebookstringRequired
rulestringRequired
Query parameters
statusstringRequired
Responses
200

Response to /api/v1/rulebook/{rulebook:[^]+}/{rule:[^]+}

application/json
put
/api/v1/rulebook/{rulebook:[^*]+}/{rule:[^*]+}
PUT /api/v1/rulebook/{rulebook:[^*]+}/{rule:[^*]+}?status=text HTTP/1.1
Host: 
Accept: */*
{
  "address": "text",
  "current_status": "text",
  "previous_status": "text"
}


Example Use Cases

  • Compliance Automation: Use these APIs to create and manage rules that enforce compliance with financial regulations, such as anti-money laundering checks.

  • Fraud Detection: Set up and monitor rules that trigger actions when suspicious activities occur, such as large transactions in high-risk regions.

  • Workflow Management: Organize related rules into rulebooks for easier handling of complex workflows, like automating data validation and reconciliation tasks.

Last updated