# smartClassify

Streamline your document classification process with SmartClassify, a cutting-edge machine learning tool. Utilizing a combination of text and layout information, the software accurately classifies documents into various categories, including advertisements, delivery notes, emails, forms, handwritten documents, and invoices. With its training on a diverse range of German language documents, including invoices, receipts, emails, and letters, SmartClassify offers a reliable solution for information extraction from scanned documents. Elevate your document understanding capabilities with smartClassify.

### 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 smartClassify

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

#### Query Parameters

| Name          | Type   | Description                                    |
| ------------- | ------ | ---------------------------------------------- |
| threshold     | String | Set minimum probability to be reached by model |
| email         | String | Define receiver email address                  |
| outputFormats | String | Define output format(s) like JSON.             |

#### 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" %}

```javascript
curl -X POST "https://use.laigo.io/api/FileUpload/v1/Upload/smartClassify" \
     -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/smartClassify?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/smartClassify"
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/smartClassify");
        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/File
Upload/v1/Upload/smartClassify";
$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 smartClassify. It can be any document type such as: invoice, receipt, letter, email etc. For e.g you can use the invoice **letter** below:

<figure><img src="/files/tvf7N9Ovx3DJWdiPThsE" alt=""><figcaption></figcaption></figure>

2. Inorder to use our smartClassify 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 smartClassify in 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      |

###


---

# 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://docs.laigo.ai/smarttools-api/smartclassify.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.
