# Get Extracted Results For Invoices In a Batch Id

Endpoint Name: `getbatchdocuments`

Request type : `POST`

Authorization : Bearer token as header

Endpoint Details: API is used to get the extracted data/results for invoices that belong to a specific batch id.

## Request Type

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

## Request Body

<table data-header-hidden><thead><tr><th width="167"></th><th width="114"></th><th width="118"></th><th></th></tr></thead><tbody><tr><td>Params</td><td>Values</td><td>Required</td><td>Description</td></tr><tr><td>username</td><td>string</td><td>Yes</td><td>Username for a particular user of a company</td></tr><tr><td>password</td><td>string</td><td>Yes</td><td>Password for a particular user of a company</td></tr><tr><td>company_name</td><td>string</td><td>Yes</td><td>Name of the company</td></tr><tr><td>batch_id</td><td>string</td><td>Yes</td><td>Batch ID of a specific batch.</td></tr><tr><td>document_type</td><td>string</td><td>Yes</td><td>Type of document to be processed - “Invoices”,“Receipts”,“PurchaseOrders”,“NACH”,“LoanAgreement” or “Insurances”.</td></tr></tbody></table>

## Request Code Samples

### Shell

* Request Body

```sh
curl --location "URL/access/klearstack/getbatchdocuments" \
  -H "Authorization: Bearer your_token_here" \
  --form "document_type=Invoices" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "username=Replace_User_Name_Here" \
  --form "password=Replace_Password_Here" \
  --form "batch_id=Replace_Batch_ID_Here" 
```

### Python

* Request Body

```python
import requests

url = "URL/access/klearstack/getbatchdocuments"

payload = {'document_type': 'Invoices',
'company_name': 'Replace_Company_Name_Here',
'username': 'Replace_User_Name_Here',
'password': 'Replace_Password_Here',
'batch_id': 'Replace_Batch_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("document_type","Invoices")
  .addFormDataPart("company_name","Replace_Company_Name_Here")
  .addFormDataPart("username","Replace_User_Name_Here")
  .addFormDataPart("password","Replace_Password_Here")
  .addFormDataPart("batch_id","Replace_Batch_ID_Here")
  .build();
Request request = new Request.Builder()
  .url("URL/access/klearstack/getbatchdocuments")
  .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('document_type', 'Invoices');
data.append('company_name', 'Replace_Company_Name_Here');
data.append('username', 'Replace_User_Name_Here');
data.append('password', 'Replace_Password_Here');
data.append('batch_id', 'Replace_Batch_ID_Here');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'URL/access/klearstack/getbatchdocuments',
  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("document_type", "Invoices");
data.append("company_name", "Replace_Company_Name_Here");
data.append("username", "Replace_User_Name_Here");
data.append("password", "Replace_Password_Here");
data.append("batch_id", "Replace_Batch_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/getbatchdocuments");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");

xhr.send(data);
```

### API Response

<table><thead><tr><th>Status Code</th><th>Response</th></tr></thead><tbody><tr><td>200</td><td><p></p><pre class="language-json"><code class="lang-json">{
    "result": [
        {
            "file_name": "24101020953_Invoice Copy_Invoice Copy_1.pdf",
            "status": "in_progress"
        }
    ],
    "status": "in_progress"
}
</code></pre></td></tr><tr><td>403</td><td>Forbidden: Client Error</td></tr><tr><td>501</td><td>Server Error</td></tr></tbody></table>


---

# Agent Instructions: 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:

```
GET https://klearstack.gitbook.io/klearstack-api-documentation/fetch-documents/get-extracted-results-for-invoices-in-a-batch-id.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
