> For the complete documentation index, see [llms.txt](https://klearstack.gitbook.io/klearstack-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://klearstack.gitbook.io/klearstack-api-documentation/dynamic-audit-rules/get-dynamic-audit-rules-generated.md).

# Get Dynamic Audit Rules Generated

Endpoint Name: `URL/access/klearstack/get_dynamic_audit_rules_generated`

Request type : `POST`

Authorization: Bearer token as header

Endpoint Details: The `get_dynamic_audit_rules_generated` endpoint will be used to fetch the dymanic rules generated for the given anchor document.

<table data-header-hidden><thead><tr><th width="119"></th><th></th></tr></thead><tbody><tr><td>Method</td><td>URL</td></tr><tr><td>POST</td><td><code>URL/access/klearstack/get_dynamic_audit_rules_generated</code></td></tr></tbody></table>

### Request Body

<table data-header-hidden><thead><tr><th width="187"></th><th width="84"></th><th width="101.181884765625"></th><th></th></tr></thead><tbody><tr><td>Params</td><td>Values</td><td>Required</td><td>Description</td></tr><tr><td>company_name</td><td>string</td><td>Yes</td><td>Name of the company for which the user is logging in</td></tr><tr><td>anchor_document_id</td><td>string</td><td>Yes</td><td>document_id received from 'getbatchdocuments' api response</td></tr></tbody></table>

### Shell (cURL)

* Request Body

```sh
curl --location "URL/access/klearstack/get_dynamic_audit_rules_generated" \
  --header "Authorization: Bearer your_token_here" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "anchor_document_id=Replace_anchor_document_id_Here" \
  
```

### Python

* Request Body

```python
import requests

url = "URL/access/klearstack/get_dynamic_audit_rules_generated"

payload = {'company_name': 'Replace_Company_Name_Here',
'anchor_document_id': 'Replace_anchor_document_id_Here'}
files=[

]
headers = {
  'Authorization': 'Bearer your_token_here'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
```

### Java (OkHttp)

* Request Body

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("company_name","Replace_Company_Name_Here")
  .addFormDataPart("anchor_document_id","Replace_anchor_document_id_Here")
  .build();
Request request = new Request.Builder()
  .url("URL/access/klearstack/get_dynamic_audit_rules_generated")
  .method("POST", body)
  .addHeader("Authorization", "Bearer your_token_here")
  .build();
Response response = client.newCall(request).execute();
```

### Node.js (Axios)

* Request Body

```javascript
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();
data.append('company_name', 'Replace_Company_Name_Here');
data.append('anchor_document_id', 'Replace_anchor_document_id_Here');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'URL/access/klearstack/get_dynamic_audit_rules_generated',
  headers: { 
    'Authorization': 'Bearer your_token_here', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

### JavaScript (XHR)

* Request Body

```javascript
// WARNING: For POST requests, body is set to null by browsers.
var data = new FormData();
data.append("company_name", "Replace_Company_Name_Here");
data.append("anchor_document_id", "Replace_anchor_document_id_Here");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "URL/access/klearstack/get_dynamic_audit_rules_generated");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");

xhr.send(data);
```

### API Response

<table data-header-hidden><thead><tr><th width="147"></th><th></th></tr></thead><tbody><tr><td>Status code</td><td>Example Response</td></tr><tr><td>200</td><td><p></p><pre class="language-json"><code class="lang-json">{
    "success": true,
    "total": 2,
    "rules": [
        {
            "rule_name": "letter_of_credit_custom.currency equal_to Invoices.currency",
            "description": "LC currency must match invoice currency",
            "enable": "false",
            "event_type": "processed",
            "rule_type": "data_reconciliation_rule",
            "action": "",
            "rule_precondition": {
                "rule_name": "letter_of_credit_custom.currency equal_to Invoices.currency",
                "document_type": "",
                "event_type": "processed",
                "condition_type": "",
                "condition_list": []
            },
            "anchor_document_id": "6a390b22d2037a1f172004b4",
            "anchor_file_name": "MT700.pdf",
            "justification": "F32B: USD — mismatch causes payment rejection",
            "rule_id": "6a390b3cd2037a1f172004b6"
        },
        {
            "rule_name": "letter_of_credit_custom.doc_date_of_shipment_value date_less_than_eq_to Invoices.due_date",
            "description": "doc_date_of_shipment_value on letter_of_credit_custom should match due_date on Invoices",
            "enable": "false",
            "event_type": "processed",
            "rule_type": "data_reconciliation_rule",
            "action": "",
            "rule_precondition": {
                "rule_name": "letter_of_credit_custom.doc_date_of_shipment_value date_less_than_eq_to Invoices.due_date",
                "document_type": "",
                "event_type": "processed",
                "condition_type": "",
                "condition_list": []
            },
            "anchor_document_id": "6a390b22d2037a1f172004b4",
            "anchor_file_name": "MT700.pdf",
            "justification": "Required by letter_of_credit_custom for downstream document consistency",
            "rule_id": "6a390b3cd2037a1f172004b7"
        }
        ]
}
</code></pre></td></tr><tr><td>400</td><td><code>{'status': 'fail', 'description': 'No dynamic audit rules found for the provided company and document id'}</code></td></tr><tr><td>500</td><td><code>{'error': error}</code></td></tr></tbody></table>
