# PUSH API Structure

Endpoint Name: \<Your end point goes here>

Request type : `POST`

Authorization: Bearer token as header

Endpoint Details: The \<your endpoint> endpoint will be used to get a result JSON of documents.

<table data-header-hidden><thead><tr><th width="123"></th><th></th></tr></thead><tbody><tr><td>Method</td><td>URL</td></tr><tr><td>POST</td><td>&#x3C;Pls share your API endpoint></td></tr></tbody></table>

### Request Body

<table data-header-hidden><thead><tr><th width="177"></th><th width="112"></th><th></th></tr></thead><tbody><tr><td>Params</td><td>Values</td><td>Description</td></tr><tr><td>company_name</td><td>string</td><td>Name of the company for which the user is logging in</td></tr><tr><td><br></td><td><br></td><td><br></td></tr><tr><td>username</td><td>string</td><td>&#x3C;your endpoint credentials></td></tr><tr><td><br></td><td><br></td><td><br></td></tr><tr><td>password</td><td>string</td><td>&#x3C;your endpoint credentials></td></tr><tr><td><br></td><td><br></td><td><br></td></tr><tr><td>document_type</td><td>string </td><td>Name of document type</td></tr><tr><td>batch_id</td><td>string</td><td>ID of document or Batch</td></tr><tr><td>Document_id</td><td><br></td><td><br></td></tr><tr><td>file_name</td><td><br></td><td><br></td></tr><tr><td>data</td><td><br></td><td>&#x3C;entire result JSON will go here></td></tr></tbody></table>

### Shell (cURL)

* Request Body

```sh
curl --location POST "<Your API Endpoint>" \
  --header "Authorization: Bearer your_token_here" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "username=Replace_Username_Here" \
  --form "password=Replace_Password_Here" \
  --form "document_type=Replace_Document_Type_Here" \
  --form "batch_id=Replace_Batch_ID_Here" \
  --form "document_id=Replace_Document_ID_Here" \
  --form "file_name=Replace_File_Name_Here" \
  --form 'data=<Replace_JSON_Data_Here>'
```

### Python

* Request Body

```python
import requests

# API URL
url = "<Your API Endpoint>"

# Request payload
data = {
    "company_name": "Replace_Company_Name_Here",
    "username": "Replace_Username_Here",
    "password": "Replace_Password_Here",
    "document_type": "Replace_Document_Type_Here",
    "batch_id": "Replace_Batch_ID_Here",
    "document_id": "Replace_Document_ID_Here",
    "file_name": "Replace_File_Name_Here",
    "data": "<Replace_JSON_Data_Here>"
}

# Headers
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer your_token_here"
}

# Make the POST request
response = requests.post(url, json=data, headers=headers)

# Print the response
if response.status_code == 200:
    print(response.json())
else:
    print("Error:", response.text)
```

### Java

* Request Body

```java
import okhttp3.*;

import java.io.IOException;

public class PostDocumentAPI {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        // JSON payload
        String jsonPayload = "{ \"company_name\": \"Replace_Company_Name_Here\", " +
                "\"username\": \"Replace_Username_Here\", " +
                "\"password\": \"Replace_Password_Here\", " +
                "\"document_type\": \"Replace_Document_Type_Here\", " +
                "\"batch_id\": \"Replace_Batch_ID_Here\", " +
                "\"document_id\": \"Replace_Document_ID_Here\", " +
                "\"file_name\": \"Replace_File_Name_Here\", " +
                "\"data\": \"Replace_JSON_Data_Here\" }";

        RequestBody body = RequestBody.create(
            jsonPayload, MediaType.parse("application/json"));

        Request request = new Request.Builder()
            .url("<Your API Endpoint>")
            .post(body)
            .addHeader("Content-Type", "application/json")
            .addHeader("Authorization", "Bearer your_token_here")
            .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                System.out.println("Response: " + response.body().string());
            } else {
                System.out.println("Error: " + response.body().string());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```

### Node.js

* Request Body

```javascript
var request = require('request');

const form_data = {
  'company_name': 'Replace_Company_Name_Here',
  'username': 'Replace_Username_Here',
  'password': 'Replace_Password_Here',
  'document_type': 'Replace_Document_Type_Here',
  'batch_id': 'Replace_Batch_ID_Here',
  'document_id': 'Replace_Document_ID_Here',
  'file_name': 'Replace_File_Name_Here',
  'data': 'Replace_JSON_Data_Here'
};

const options = {
  url: '<Your API Endpoint>',
  formData: form_data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Authorization': 'Bearer your_token_here'
  }
};

request.post(options, function(err, httpResponse, body) {
  if (err) {
    console.error('Request failed:', err);
    return;
  }

  console.log('Response:', body);
});
```

### JavaScript (XMLHttpRequest)

* Request Body

```javascript
var payload = JSON.stringify({
    company_name: "Replace_Company_Name_Here",
    username: "Replace_Username_Here",
    password: "Replace_Password_Here",
    document_type: "Replace_Document_Type_Here",
    batch_id: "Replace_Batch_ID_Here",
    document_id: "Replace_Document_ID_Here",
    file_name: "Replace_File_Name_Here",
    data: "Replace_JSON_Data_Here"
});

var xhr = new XMLHttpRequest();
xhr.open("POST", "<Your API Endpoint>", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");

// Handle response
xhr.onreadystatechange = function () {
    if (xhr.readyState === XMLHttpRequest.DONE) {
        if (xhr.status === 200) {
            console.log("Response:", xhr.responseText);
        } else {
            console.error("Error:", xhr.responseText);
        }
    }
};
```

### Sample JSON Result (added to the data attribute in the request)

<table data-header-hidden><thead><tr><th width="138"></th><th></th></tr></thead><tbody><tr><td>Status code</td><td>Example Request</td></tr><tr><td><p>200</p><p><br><br></p></td><td><p>{</p><p>    "result": [</p><p>        {</p><p>            "Document_id": "65269c006a8da8763b51c217",</p><p>            "is_approved": 0,</p><p>            "file_name": "Invoice 231799.pdf",</p><p>            "overall_confidence": 0.8545232920427561,</p><p>            "document_type": "Invoice",</p><p>            "upload_time": "2023-10-11T18:28:40.322",</p><p>            "finished_time": "2023-10-11T18:30:21.875",</p><p>            "Inv_Number": {</p><p>                "value": "231799",</p><p>                "confidence": 0.9967719905645758,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1297,</p><p>                    70,</p><p>                    1408,</p><p>                    98</p><p>                ]</p><p>            },</p><p>            "Inv_Date": {</p><p>                "value": "15-Sep-2023",</p><p>                "confidence": 0.9999483208203647,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1297,</p><p>                    139,</p><p>                    1450,</p><p>                    164</p><p>                ]</p><p>            },</p><p>            "Total_VAT": {</p><p>                "value": "2.37",</p><p>                "confidence": 0.8846402077955501,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1140,</p><p>                    1045,</p><p>                    1193,</p><p>                    1066</p><p>                ]</p><p>            },</p><p>            "Due_Date": {</p><p>                "value": "16-Sep-2023",</p><p>                "confidence": 0.874903804263095,</p><p>                "page_index": 1</p><p>            },</p><p>            "PO_Number": {</p><p>                "value": "369-1111-1111",</p><p>                "confidence": 0.777240328679722,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1297,</p><p>                    432,</p><p>                    1485,</p><p>                    455</p><p>                ]</p><p>            },</p><p>            "Total": {</p><p>                "value": "80.4",</p><p>                "confidence": 0.987641462429209,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1556,</p><p>                    1095,</p><p>                    1641,</p><p>                    1121</p><p>                ]</p><p>            },</p><p>            "VAT_Percentage": {</p><p>                "value": "0",</p><p>                "confidence": 0.924382186378707,</p><p>                "page_index": 1</p><p>            },</p><p>            "Sub-Total": {</p><p>                "value": "80.40",</p><p>                "confidence": 0.910711264124983,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1554,</p><p>                    998,</p><p>                    1638,</p><p>                    1025</p><p>                ]</p><p>            },</p><p>            "CGST_Value": {</p><p>                "value": "1",</p><p>                "confidence": 0.99999,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1093,</p><p>                    889,</p><p>                    1103,</p><p>                    910</p><p>                ]</p><p>            },</p><p>            "SGST_Value": {</p><p>                "value": "1",</p><p>                "confidence": 0.99999,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1093,</p><p>                    889,</p><p>                    1103,</p><p>                    910</p><p>                ]</p><p>            },</p><p>            "CGST_%": {</p><p>                "value": "2.5",</p><p>                "confidence": 0.99999,</p><p>                "page_index": 1</p><p>            },</p><p>            "SGST_%": {</p><p>                "value": "2.5",</p><p>                "confidence": 0.99999,</p><p>                "page_index": 1</p><p>            },</p><p>            "Total_Pieces": {</p><p>                "value": "2",</p><p>                "confidence": 0.8,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1179,</p><p>                    998,</p><p>                    1194,</p><p>                    1019</p><p>                ]</p><p>            },</p><p>            "Full_Box_Equivalent": {</p><p>                "value": "0.5",</p><p>                "confidence": 0.8,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Supplier": {</p><p>                "value": "Farm Direct",</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    59,</p><p>                    312,</p><p>                    218,</p><p>                    336</p><p>                ],</p><p>                "confidence": 0.6</p><p>            },</p><p>            "Customer_Name": {</p><p>                "value": "winds Llc",</p><p>                "confidence": 0.6,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    55,</p><p>                    608,</p><p>                    367,</p><p>                    633</p><p>                ]</p><p>            },</p><p>            "Ship-to_Party_Name": {</p><p>                "value": "WINDS LLC",</p><p>                "confidence": 0.9,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    55,</p><p>                    608,</p><p>                    367,</p><p>                    633</p><p>                ]</p><p>            },</p><p>            "Supplier_Contact_Reference_Name": {</p><p>                "value": "Mike johansson",</p><p>                "confidence": 0.959998239582176,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1298,</p><p>                    347,</p><p>                    1495,</p><p>                    372</p><p>                ]</p><p>            },</p><p>            "Currency": {</p><p>                "value": "USD",</p><p>                "confidence": 0.9432,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1155,</p><p>                    608,</p><p>                    367,</p><p>                    633</p><p>                ]</p><p>            },</p><p>            "Inv_Type": {</p><p>                "value": "Tax Invoice",</p><p>                "confidence": 0.907526923369042,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    55,</p><p>                    608,</p><p>                    367,</p><p>                    633</p><p>                ]</p><p>            },</p><p>            "Suppllier_Email_Address": {</p><p>                "value": "mike@KlearStack.com",</p><p>                "confidence": 0.925903840309437,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                   1179,</p><p>                    998,</p><p>                    1194,</p><p>                    1019</p><p>                ]</p><p>            },</p><p>            "line_items": [</p><p>                {</p><p>                    "row": {</p><p>                        "Description": "Spray Roses Red Rubicon 50 cm X 60 Stem (1.19 cubes)",</p><p>                        "Mark Code": "",</p><p>                        "Pieces": "1",</p><p>                        "Total Units": "60",</p><p>                        "Unit Price": "$ 0.590",</p><p>                        "Line_Item_Total": "$ 35.40",</p><p>                        "table_index": "1",</p><p>                        "Box Type": "QB",</p><p>                        "Units Per Box": "60.0",</p><p>                        "Total Bunches": "",</p><p>                        "Item Code": ""</p><p>                    },</p><p>                    "page_index": 1,</p><p>                    "coordinate": [</p><p>                        61,</p><p>                        886,</p><p>                        909.5,</p><p>                        919</p><p>                    ],</p><p>                    "confidence": 0.516886749822407</p><p>                },</p><p>                {</p><p>                    "row": {</p><p>                        "Description": "Spray Roses White Snow Flake 50 cm X 100 Stem (1.19 cubes)",</p><p>                        "Mark Code": "MAU",</p><p>                        "Pieces": "1",</p><p>                        "Total Units": "100",</p><p>                        "Unit Price": "$ 0.450",</p><p>                        "Line_Item_Total": "$ 45.00",</p><p>                        "table_index": "1",</p><p>                        "Box Type": "QB",</p><p>                        "Units Per Box": "100.0",</p><p>                        "Total Bunches": "",</p><p>                        "Item Code": "100"</p><p>                    },</p><p>                    "page_index": 1,</p><p>                    "coordinate": [</p><p>                        36,</p><p>                        930,</p><p>                        1644,</p><p>                        963</p><p>                    ],</p><p>                    "confidence": 0.510797353494844</p><p>                }</p><p>            ],</p><p>            "Customer_Address": {</p><p>                "value": "WINDS LLC 1111 Pioneer Ave Vista, CA 92111 760-734-1111 Tax Id: 844307411",</p><p>                "confidence": 0.8,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    54,</p><p>                    608,</p><p>                    367,</p><p>                    782</p><p>                ]</p><p>            },</p><p>            "Supplier_Address": {</p><p>                "value": "Farm Direct, 1111 NW 11th Ct, Miami, Florida 33111, Phone 305611111, Email mike@KlearStack.com,",</p><p>                "confidence": 0.8,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    59,</p><p>                    312,</p><p>                    218,</p><p>                    336</p><p>                ]</p><p>            },</p><p>            "Supplier_State_name": {</p><p>                "value": "florida",</p><p>                "confidence": 0.557732443688379,</p><p>                "page_index": 1</p><p>            },</p><p>            "Customer_State_Name": {</p><p>                "value": "ca",</p><p>                "confidence": 0.610590142645783,</p><p>                "page_index": 1</p><p>            },</p><p>            "Invoice_Lessor_Address_Value": {</p><p>                "value": "WINDS LLC WINDS LLC 1111 Pioneer Ave 1111 Pioneer Ave",</p><p>                "confidence": 0.9,</p><p>                "page_index": 1</p><p>            },</p><p>            "Ship-to_Party_Address": {</p><p>                "value": "EWINDS LLC 1111 Pioneer Ave 1111",</p><p>                "confidence": 0.9,</p><p>                "page_index": 1</p><p>            },</p><p>            "PDF_Creator": {</p><p>                "value": "JasperReports (Komet Sales Standard Invoice)",</p><p>                "confidence": 1.0,</p><p>                "page_index": 1</p><p>            },</p><p>            "PDF_Modified_Date": {</p><p>                "value": false,</p><p>                "confidence": 1.0,</p><p>                "page_index": 1</p><p>            },</p><p>            "PDF_Producer": {</p><p>                "value": "iText 2.1.0 (by lowagie.com)",</p><p>                "confidence": 1.0,</p><p>                "page_index": 1</p><p>            },</p><p>            "Carrier": {</p><p>                "value": "FARM DIRECT",</p><p>                "confidence": 0.85,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1254,</p><p>                    611,</p><p>                    1413,</p><p>                    635</p><p>                ]</p><p>            },</p><p>            "Airway_Bill_Number": {</p><p>                "value": "3698781111",</p><p>                "confidence": 0.95,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1297,</p><p>                    432,</p><p>                    1485,</p><p>                    455</p><p>                ]</p><p>            },</p><p>            "Supplier_Contact_Number": {</p><p>                "value": "30511111",</p><p>                "confidence": 0.8,</p><p>                "page_index": 1</p><p>            },</p><p>            "Ship_To_Party_Address": {</p><p>                "value": "Ship To ,WINDS LLC , 1111 Pioneer Ave , Vista, CA 11111 ,",</p><p>                "confidence": 0.92,</p><p>                "page_index": 1</p><p>            },</p><p>            "Description_of_Goods": {</p><p>                "value": "Spray Roses Red Rubicon 50 cm X 60 Stem (1.19 cubes)",</p><p>                "confidence": 0.9,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    61,</p><p>                    886,</p><p>                    909.5,</p><p>                    919</p><p>                ]</p><p>            },</p><p>            "Concise_Description_of_Goods": {</p><p>                "value": "Roses Red Rubicon 50 cm X 60 Stem",</p><p>                "confidence": 0.9,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    61,</p><p>                    886,</p><p>                    909.5,</p><p>                    919</p><p>              ]</p><p>            }</p><p>        }</p><p>    ],</p><p>    "Status": "complete",</p><p>   "Application_No" : "41828193545",</p><p>    "OCR_Ref_No":"e967f4c1-ca76-4d78-b8db-41828193545e",</p><p>    "User_Name":"Admin",</p><p>    "Company_Name":"KlearStack",</p><p>    "Source_Name":"API",</p><p>    "Image_list":["https://wfh.klearstack.com/document/details/KlearStack/Invoices/e967f4c1-ca76-4d78-b8db-41828193545e/e967f4c1-ca76-4d78-b8db-41828193545e/general-tab?selectedTab=0&#x26;pageNumber=1&#x26;documentPageIndex=1&#x26;sidebar=0"] ,</p><p>“release_version”:”7.8.9”</p><p>}</p></td></tr></tbody></table>

KlearStack will provide downloadable image links in a list format, KlearStack will also share access token with which URL’s can be accessible. For multipage pdf file image lists will contain the same number of URL’s as the number of pages in the document.
