> For the complete documentation index, see [llms.txt](https://docs.xyb.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xyb.co/xyb-platform-1/xyb-ledger/api-reference-guides/operational-and-rule-management-apis/rule-and-rulebook-management-apis.md).

# 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.

{% openapi src="/files/5af2rdQ5h4ZxHvDZfiyJ" path="/api/v1/rulebook/" method="post" %}
[openapi-ledger.json](https://content.gitbook.com/content/akJn6TxWIBAbZwLlYoVP/blobs/S917VQZQHm6OZGrj1mf5/openapi-ledger.json)
{% endopenapi %}

### 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.

{% openapi src="/files/5af2rdQ5h4ZxHvDZfiyJ" path="/api/v1/rulebook/{name:\[^\*]+}" method="get" %}
[openapi-ledger.json](https://content.gitbook.com/content/akJn6TxWIBAbZwLlYoVP/blobs/S917VQZQHm6OZGrj1mf5/openapi-ledger.json)
{% endopenapi %}

### 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.

{% openapi src="/files/5af2rdQ5h4ZxHvDZfiyJ" path="/api/v1/rulebook/" method="get" %}
[openapi-ledger.json](https://content.gitbook.com/content/akJn6TxWIBAbZwLlYoVP/blobs/S917VQZQHm6OZGrj1mf5/openapi-ledger.json)
{% endopenapi %}

***

## 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.

{% openapi src="/files/5af2rdQ5h4ZxHvDZfiyJ" path="/api/v1/rulebook/{rulebook:\[^\*]+}" method="post" %}
[openapi-ledger.json](https://content.gitbook.com/content/akJn6TxWIBAbZwLlYoVP/blobs/S917VQZQHm6OZGrj1mf5/openapi-ledger.json)
{% endopenapi %}

### 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.

{% openapi src="/files/5af2rdQ5h4ZxHvDZfiyJ" path="/api/v1/rulebook/{rulebook:\[^*]+}/{rule:\[^*]+}" method="get" %}
[openapi-ledger.json](https://content.gitbook.com/content/akJn6TxWIBAbZwLlYoVP/blobs/S917VQZQHm6OZGrj1mf5/openapi-ledger.json)
{% endopenapi %}

### 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.

{% openapi src="/files/5af2rdQ5h4ZxHvDZfiyJ" path="/api/v1/rulebook/\*/" method="get" %}
[openapi-ledger.json](https://content.gitbook.com/content/akJn6TxWIBAbZwLlYoVP/blobs/S917VQZQHm6OZGrj1mf5/openapi-ledger.json)
{% endopenapi %}

### 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.

{% openapi src="/files/5af2rdQ5h4ZxHvDZfiyJ" path="/api/v1/rulebook/{rulebook:\[^*]+}/{rule:\[^*]+}" method="put" %}
[openapi-ledger.json](https://content.gitbook.com/content/akJn6TxWIBAbZwLlYoVP/blobs/S917VQZQHm6OZGrj1mf5/openapi-ledger.json)
{% endopenapi %}

***

#### **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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xyb.co/xyb-platform-1/xyb-ledger/api-reference-guides/operational-and-rule-management-apis/rule-and-rulebook-management-apis.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
