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

# Rule Settings

> Update a bucket by its ID.

In order to change the configurable parameters for a rule in a bucket, two parameters will be required: **rule\_id** as used previously to detail the rule that will be updated, and **rule\_setting**.

**rule\_setting** is a JSON object that will be specific to each given rule id. Thus, it should be aligned with the rule id to be updated.

### Example

You may also change the **activation** and the **settings** of a rule at the same time by providing the necessary fields that you wish to update. For instance, you can use the following response body to change part of a rule’s parameter and turn on the rule at the same time.

```bash theme={null}
{
     "rule_id": 3,
     "rule_setting": {
         "beneficiary_count_exceeds": 5,
         "lookback_days": 3
     },
     "activate_rule":"True"
}
```

### List of rule\_setting

The list of **rule\_setting** based on each rules are as follows:

```bash theme={null}
Rule 1: Parameters
{
     "transaction_count_exceeds": 2,
     "amount_less_than": 2000,
     "lookback_days": 3
}
```

```bash theme={null}
Rule 2: Parameters
{
     "transaction_count_exceeds": 2,
     "lookback_days": 3
}
```

```bash theme={null}
Rule 3: Parameters
{
     "beneficiary_count_exceeds": 2,
     "lookback_days": 3
}
```

```bash theme={null}
Rule 4: Parameters
{
     "sender_count_exceeds": 2,
     "lookback_days": 3
}
```

```bash theme={null}
Rule 5: Parameters
{
     "aggregated_amount_exceeds": 3000,
     "lookback_days": 30
}
```

```bash theme={null}
Rule 6: Parameters
{
     "lookback_days": 3,
     "lookback_months_to_determine_baseline": 12,
     "amount_exceed_baseline_by_number_of_times": 10
}
```

```bash theme={null}
Rule 7 & 8 have no rule parameters!
```

```bash theme={null}
Rule 9: Parameters
{
     "aggregated_withdrawal_exceeds": 1000,
     "lookback_days": 30
}
```

```bash theme={null}
Rule 10: Parameters
{
     "aggregated_deposit_exceeds": 1000,
     "lookback_days": 30
}
```

```bash theme={null}
Rule 11 has no rule parameters!
```

```bash theme={null}
Rule 12: Parameters
{
    "aggregated_amount_exceeds": 3000
}
```

```bash theme={null}
Rule 13: Parameters
{
     "lookback_days": 3,
     "lookback_months_to_determine_baseline": 12,
     "amount_exceed_baseline_by_number_of_times": 10
}
```

```bash theme={null}
Rule 14: Parameters
{
     "aggregated_amount_exceeds": 5000,
     "minimum_transaction_count": 10,
     "lookback_days": 5
}
```

```bash theme={null}
Rule 15: Parameters
{
     "aggregated_amount_exceeds": 5000,
     "minimum_transaction_count": 10,
     "lookback_days": 5
}
```

```bash theme={null}
Rule 16: Parameters
{
    "lookback_days": 3,
    "lookback_months_to_determine_baseline": 1,
    "transaction_count_exceed_baseline_by_number_of_times": 20
}
```

```bash theme={null}
Rule 17 has no rule parameters!
```

**Sample HTTP Request (All Rule 6 Parameters)**

```bash theme={null}
HTTP Method: PATCH
URL: {{base_url}}/api/buckets/{bucket_id}
Request Body:
e.g

{
     "rule_id": 6,
     "rule_setting": {
         "lookback_days": 3,
         "lookback_months_to_determine_baseline": 12,
         "amount_exceed_baseline_by_number_of_times": 10
     }
}
```

**Note**: The keys used as part of the “rule\_setting” JSON will need to be aligned with those highlighted above in respect to each Rule. Otherwise, the following response will be provided with status code 400.

```bash theme={null}
Expected Response Code: 400
Response Body: JSON Object
e.g

{
     "Input Key [aggregated_amount_exceedss] used to set variables for Rule 12 is incorrect. Please check again."
}
```

You can also update a part of the rule’s parameters by providing the relevant keys that you would like to use to update the rule. For instance, to update only the **aggregated\_amount\_exceeds**. You can provide the following request body.

Sample HTTP Request (Partial Rule 12 Parameters)

```bash theme={null}
{
     "rule_id":12,
     "rule_setting": {
         "aggregated_amount_exceeds": 10000
     }
}
```

By doing so, only the **aggregated amount exceeds** parameter for Rule 12 will be updated for the given bucket. The other fields “variance percent” and “lookback days” will remain unchanged.


## OpenAPI

````yaml patch /api/buckets/{id}
openapi: 3.0.3
info:
  title: Athena API
  version: v3
  x-logo:
    url: https://cynopsis.co/wp-content/uploads/2021/03/logo-2.png
    altText: Cynopsis Solutions
  description: >-
    ATHENA is an advanced real-time transaction monitoring solution designed to
    detect and prevent money laundering, fraud, and terrorism financing. Powered
    by proprietary AML rules, ATHENA analyzes transactions in real time,
    providing clear, intuitive visual insights to streamline compliance
    processes.
        
        ✅ Real-Time Monitoring – Instantly analyzes transaction data to detect anomalies and potential compliance risks.
        ✅ Visualized Insights – Converts complex data into easy-to-understand charts, aiding faster decision-making.
        ✅ Seamless Integration – Easily integrates with existing financial and compliance systems.
        
        Ideal for financial institutions, fintech companies, and regulated businesses, ATHENA enhances risk management and ensures regulatory compliance with ease.
  contact:
    email: tech@cynopsis.co
servers:
  - url: http://localhost/api
    description: Local development server
security: []
paths:
  /api/buckets/{id}:
    patch:
      tags:
        - Buckets
      summary: Update a bucket
      description: Update a bucket by its ID.
      operationId: bucket_partial_update
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          description: A unique integer value identifying this bucket.
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchedBucketRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/PatchedBucketRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/PatchedBucketRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  bucket_rules:
                    type: array
                    items:
                      type: object
                      description: Rule object
                    description: List of bucket rules.
                  rule_id:
                    type: integer
                    description: Rule ID.
                  rule_setting:
                    type: object
                    description: Rule settings.
                  activate_rule:
                    type: boolean
                    description: Activate rule.
                  last_timestamp:
                    type: string
                    description: Last timestamp.
                  modified_by:
                    type: object
                    properties:
                      id:
                        type: integer
                  created_by:
                    type: object
                    properties:
                      id:
                        type: integer
          description: Bucket updated successfully.
      security:
        - CustomAuthentication: []
        - cookieAuth: []
        - BearerAuth: []
components:
  schemas:
    PatchedBucketRequest:
      type: object
      description: |-
        A ModelSerializer that takes an additional `fields` argument that
        controls which fields should be displayed.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
        active_indicator:
          type: boolean
        description:
          type: string
        rule_id:
          type: integer
          writeOnly: true
        rule_setting:
          type: object
          additionalProperties: {}
          writeOnly: true
        activate_rule:
          type: boolean
          writeOnly: true
  securitySchemes:
    CustomAuthentication:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token obtained from AWS Cognito or custom authentication service
    cookieAuth:
      type: apiKey
      in: cookie
      name: sessionid

````