> 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/documents-set/get-documents-of-a-set.md).

# Get Documents of a Set

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

Request type : `POST`

Authorization: Bearer token as header

Endpoint Details: The `getdocumentsforset`endpoint will be used to fetch all the documents belonging to a certain set based on the Set Reference Number.

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

### Request Body

<table data-header-hidden><thead><tr><th width="188.81817626953125"></th><th width="97"></th><th></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>set_reference_number</td><td>string </td><td>Yes</td><td>set_reference_number for which documents are required.</td></tr><tr><td>userid</td><td>string</td><td>No</td><td>User ID</td></tr><tr><td>role</td><td>string</td><td>No</td><td>user role, e.g:Approver</td></tr></tbody></table>

### Shell (cURL)

* Request Body

```sh
curl --location "URL/access/klearstack/getdocumentsforset" \
  --header "Authorization: Bearer your_token_here" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "username=Replace_Username_Here" \
  --form "set_reference_number=Replace_Set_Reference_Number_Here" \
  --form "role=Replace_Role_Here"
```

### Python

* Request Body

```python
import requests

url = "URL/access/klearstack/getdocumentsforset"

payload = {'company_name': 'Replace_Company_Name_Here',
'username': 'Replace_Username_Here',
'set_reference_number': 'Replace_Set_Reference_Number_Here',
'role': 'Replace_Role_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_Your_Company_Name_Here")
  .addFormDataPart("username", "Replace_Your_Username_Here")
  .addFormDataPart("set_reference_number", "Replace_Your_Set_Reference_Number_Here")
  .addFormDataPart("role", "Replace_Your_Role_Here")
  .build();
Request request = new Request.Builder()
  .url("URL/access/klearstack/getdocumentsforset")
  .method("POST", body)
  .addHeader("Authorization", "Bearer Replace_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 formData = new FormData();
formData.append('company_name', 'Replace_Your_Company_Name_Here');
formData.append('username', 'Replace_Your_Username_Here');
formData.append('set_reference_number', 'Replace_Your_Set_Reference_Number_Here');
formData.append('role', 'Replace_Your_Role_Here');

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

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 formData = new FormData();
formData.append("company_name", "Replace_Your_Company_Name_Here");
formData.append("username", "Replace_Your_Username_Here");
formData.append("set_reference_number", "Replace_Your_Set_Reference_Number_Here");
formData.append("role", "Replace_Your_Role_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/getdocumentsforset");
xhr.setRequestHeader("Authorization", "Bearer Replace_Your_Token_Here");

xhr.send(formData);
```

### API Response

<table data-header-hidden><thead><tr><th width="146"></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">{
    "all_result": [
        {
            "batch_id": "f383919b-8efe-4014-a725",
            "status": "complete",
            "file_name": "test.pdf",
            "ondisk_encrypted_file_name": "",
            "result": []
            }
   ]
}
</code></pre></td></tr></tbody></table>
