# Make your first Request

\
Get your token

1. Before you can use any of the APIs, you need to log in to your Laigo account or, if you don’t have one, [create a new one.](https://app.laigo.io/register/HxB4EQdYUxJYEAcKUQFUAgNSTlFUVgcVVVYIAhgHBVAESAFUUVMAVVNXAFIEUhsfQHFGBFgKE1xjEUJcVxdHYwAED11AbBg=)
2. For creating the token, please visit our [platform](https://app.laigo.io/) and go to Administration- API Keys page to create and copy your client credentials.

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

3. Once you logged in, then you can start to create your client secret and client id by selecting the API page on the left sidebar of the dashboard.

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

3. For generating your client\_id and client\_secret you must fill the 'API Client Friendly Name' then click on the button ‘Generate’. The credentials that you can use for creating a token are now available.

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

5. Create an access token. To request access tokens, an application must make a POST request with the following multipart form data to the token URI: **grant\_type=client\_credentials**.

The application must pass basic HTTP auth credentials using the **client\_id** as the user and **client\_secret** as the password access tokens are obtained by calling the **<https://account.laigo.io/realms/SmartTools/protocol/openid-connect/token>** endpoint, and the required secrets are available in the API tab for your need.

**Create an access token**

***

<mark style="color:green;">`POST`</mark> `https://account.laigo.io/realms/SmartTools/protocol/openid-connect/token`

#### Query Parameters

| Name                                             | Type   | Description                                                 |
| ------------------------------------------------ | ------ | ----------------------------------------------------------- |
| client\_id<mark style="color:red;">\*</mark>     | String | The ClientId that has been generated for this function.     |
| client\_secret<mark style="color:red;">\*</mark> | String | The ClientSecret that has been generated for this function. |
| grant\_type<mark style="color:red;">\*</mark>    | String | Here you put your client credentials                        |

{% tabs %}
{% tab title="200: OK OK" %}

{% endtab %}

{% tab title="400: Bad Request Bad Request" %}

{% endtab %}

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

{% endtab %}

{% tab title="404: Not Found Not Found" %}

{% endtab %}
{% endtabs %}

***

**Get your sample code**

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

```
curl -X POST "https://account.laigo.io/realms/SmartTools/protocol/openid-connect/token" \
     -d "client_id=<clientId>" \
     -d "client_secret=<clientSecret>" \
     -d "grant_type=client_credentials"
```

{% endtab %}

{% tab title="C#" %}

```csharp
string tokenUrl = "https://account.laigo.io/realms/SmartTools/protocol/openid-connect/token";
using (HttpClient client = new HttpClient())
{
    var formData = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("client_id", "<client_id>"),
                new KeyValuePair<string, string>("client_secret", "<client_secret>"),
                new KeyValuePair<string, string>("grant_type", "client_credentials")
            };

    var response = await client.PostAsync(tokenUrl, new FormUrlEncodedContent(formData));
    string responseContent = await response.Content.ReadAsStringAsync();

    Console.WriteLine(responseContent);
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

token_url = 'https://account.laigo.io/realms/SmartTools/protocol/openid-connect/token'
data = {'client_id': '<clientId>', 'client_secret': '<clientSecret>', 'grant_type': 'client_credentials'}

result = requests.post(token_url, data = data)
print(result.text)
```

{% endtab %}
{% endtabs %}

### Expected response

```
{
   "access_token":"USVb1nGO9kwQlhNRRnI4iWVy2UV5j7M6h7",
   "expires_in":300,
   "refresh_expires_in":0,
   "token_type":"Bearer",
   "not-before-policy":0,
   "scope":"smarttools:accounting smarttools:consumption"
}
```

## Uploading a new document

Once your access tokens are obtained by following the steps shown above the required secrets are available in the API tab for your task.\
**In our example we will show how to use the API call to the smartICR tool.** \
First you have to make a POST request to the following route, since you are uploading a new document.

## Upload file to smartICR

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

#### Query Parameters

| Name                                            | Type   | Description                                                                                                                                                                 |
| ----------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| email<mark style="color:red;">\*</mark>         | String | If you want to sent the result to your email, you can define the destination email with this parameter                                                                      |
| outputFormats<mark style="color:red;">\*</mark> | String | As output format you can choose PDF and/ TEXT (e.g. outputFormats=PDF,TEXT)                                                                                                 |
| languageHint                                    | String | If you prefer the detection in a special language, you can force to use a language. Default Language is English. For choosing a Language, use the ISO-Langauge Code – 639-1 |

#### 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 Response result will be the job id" %}

{% endtab %}
{% endtabs %}


---

# 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/get-started/make-your-first-request.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.
