# smartInvoice

Optimize your data extraction process with the smartInvoice Application, a robust solution for invoice data extraction. The application allows for seamless extraction of important information such as the receiver and sender names and addresses, tax numbers, IBAN and BIC codes, invoice date, and invoice numbers and amounts with customizable percentage calculations. Trained on German and English data and with a range of file layouts and templates, the smartInvoice Application offers a highly effective and efficient means of streamlining your data extraction process.

### 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/smartInvoice`

#### Query Parameters

| Name          | Type   | Description                                                 |
| ------------- | ------ | ----------------------------------------------------------- |
| threshold     | String | Set minimum probability to be reached by model              |
| outputFormats | String | Define output format(s) like PDF, TXT, JSON. Default is PDF |
| 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" %}

```javascript
curl -X POST "https://use.laigo.io/api/FileUpload/v1/Upload/smartInvoice" \
     -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/smartInvoice?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/smartInvoice"
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/smartInvoice");
        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/smartInvoice";
$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 smartInvoice. 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="https://1698119796-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnvGf9sv8CkPYJeH3XSuP%2Fuploads%2FmUUlBDbZzefCdJ26Sr6o%2FsmartInvoice.png?alt=media&#x26;token=333a2665-283f-4ed0-9300-ff22ef307c00" alt=""><figcaption></figcaption></figure>

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

###
