# smartPaperFlow

Introducing our smartPaperFlow, which automates the task of splitting the documents between lot of joined pages within a big document, providing users with a more efficient and accurate way to process documents. Our model is capable of handling any document type, and provides extracted documents with their exact location where they begin and end. This means that you can save time and reduce the risk of errors that can occur with manual processing.

By utilizing our AI solution, you can experience faster and more accurate processing of documents, freeing up valuable time and resources that can be used elsewhere. With our model, we offer a valuable tool for anyone who regularly works with document processing, providing a more streamlined and effective solution for the Page Stream Segmentation problem. Try our smartPaperFlow solution for this problem today and see how it can help improve your document processing efficiency and accuracy.

### Limitations

Max File Size is **10 MB**\
Max requests per second: **1**\
Processing Time: **Up to the number of characters in an image**

### Licenses

All rights reserved by Laigo

### API Call<br>

## Upload file to smartInvoice

<mark style="color:green;">`POST`</mark> `https://use.laigo.io/api/FileUpload/v1/Upload/`smartPaperFlow

#### Query Parameters

| Name      | Type   | Description                                    |
| --------- | ------ | ---------------------------------------------- |
| threshold | String | Set minimum probability to be reached by model |
| email     | String | Define receiver email address                  |

#### Headers

| Name                                          | Type   | Description                                                      |
| --------------------------------------------- | ------ | ---------------------------------------------------------------- |
| accessToken<mark style="color:red;">\*</mark> | String | A JWT issued to your application by the Laigo identity provider. |

#### Request Body

| Name                                   | Type   | Description            |
| -------------------------------------- | ------ | ---------------------- |
| file<mark style="color:red;">\*</mark> | String | The file for uploading |

{% tabs %}
{% tab title="201: Created Returns Job Id" %}

{% endtab %}

{% tab title="400: Bad Request Incomplete request or insufficient Laigos" %}

{% endtab %}

{% tab title="401: Unauthorized Unauthorized call" %}

{% endtab %}
{% endtabs %}

### Code snippets

{% tabs %}
{% tab title="cURL" %}

```markup
curl -X POST "https://use.laigo.io/api/FileUpload/v1/Upload/smartPaperFlow" \
     -H "Authorization: Bearer my-accessToken-here" \
     -F "email=my-email-here" \
     -F "outputFormats=JSON" \
     -F "file=@my-file-location-here"
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();

var email = "my-email-here";
var outputFormats = "JSON";

var url = $"https://use.laigo.io/api/FileUpload/v1/Upload/smartDocSplit?email={Uri.EscapeDataString(email)}&outputFormats={Uri.EscapeDataString(outputFormats)}";

var request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", "Bearer my-accessToken-here");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("my-file-location-here")), "file", "my-file-location-here");
request.Content = content;

var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://use.laigo.io/api/FileUpload/v1/Upload/smartDocSplit"
headers = {
    "Authorization": "Bearer my-accessToken-here"
}

files = {
    "email": (None, "my-email-here"),
    "outputFormats": (None, "JSON"),
    "file": ("sample.pdf", open("my-file-location-here", "rb"))
}

response = requests.post(url, headers=headers, files=files)
print(response.text)
```

{% endtab %}

{% tab title="HTML & JavaScript" %}

```html
<input type="file" id="fileInput">
<button onclick="uploadFile()">Upload</button>
<script>
    function uploadFile() {
        var fileInput = document.getElementById('fileInput');
        var file = fileInput.files[0];
        var formData = new FormData();

        formData.append("email", "my-email-here");
        formData.append("outputFormats", "JSON");
        formData.append("file", file);

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

        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    console.log(xhr.responseText);
                } else {
                    console.error("Error:", xhr.statusText);
                }
            }
        };

        xhr.open("POST", "https://use.laigo.io/api/FileUpload/v1/Upload/smartDocSplit");
        xhr.setRequestHeader("Authorization", "Bearer my-accessToken-here");
        xhr.send(formData);
    }
</script>
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();

$url = "https://use.laigo.io/api/FileUpload/v1/Upload/smartDocSplit";
$headers = array(
    "Authorization: Bearer my-accessToken-here"
);

$data = array(
    "email" => "my-email-here",
    "outputFormats" => "JSON",
    "file" => new CurlFile("my-file-location-here", "application/pdf", "sample.pdf")
);

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

if ($response === false) {
    echo 'Curl error: ' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
```

{% endtab %}
{% endtabs %}

### Example (Step by step)

1. First you need to have a document sample that you want to use with smartPaperFlow. It can be any document type such as: invoice, receipt, letter, email etc. For e.g you can use the receipt below:

<figure><img src="https://1698119796-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnvGf9sv8CkPYJeH3XSuP%2Fuploads%2FRTIwzQG89HLtw8r9IWMy%2FsmartDocSpli.png?alt=media&#x26;token=e3b178b5-74af-4fae-8385-2db00ac4a7b2" alt=""><figcaption></figcaption></figure>

2. Inorder to use our smartPaperFlow tool you need to have an API key which can be generated from [here](https://laigo.ai/make-your-first-request/).&#x20;

{% hint style="info" %}
If you don’t have an account, first you need to set up your account then you can generate the API key. [Create an account here.](https://laigo.ai/setup-your-account/)
{% endhint %}

3. After you have generated your API key, then you can use smartPaperFlow any popular programming language, where you can find the code snippets [here](https://laigo.ai/smartclassify/).
4. Run your code. You will receive a JSON response with the invoice details.

### Credits (Laigo)

The calculation of processing a page:

| Page | Laigos |
| ---- | ------ |
| 1    | 1      |

###
