> For the complete documentation index, see [llms.txt](https://40factory.gitbook.io/wilson/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://40factory.gitbook.io/wilson/3.12/rest-api/authentication/get-access-token.md).

# Get access token

This endpoint allows the client to obtain an access token by providing the necessary credentials.

## Request

### Url

```
POST 
https://wilson.40mat.com/apif/v2/auth/token
```

### Headers

```
No header is required for this endpoint.
```

### Parameters

```
No parameters are required for this endpoint.
```

#### Body

```json
{
  "app_name": "company-9d5e82680b7b9d...",
  "client_id": "19cd83c2-5137-47d7-905f-...",
  "client_secret": "S-ae305302a441bd4268~8fc..."
}
```

The request body is in JSON format contain following properties:

* `app_name` (string, required): The name of the application.
* `client_id` (string, required): The client ID for authentication.
* `client_secret` (string, required): The client secret for authentication.

***

## Response

```json
{
    "access_token": "eyJ0eXAiOiJKV1QiLCJub25jZSI6IlZFLXQxZTJUX2Y1...",
    "expires_at": 1747933502,
    "expires_in": 3599,
    "ext_expires_in": 3599,
    "token_type": "Bearer"
}
```

The response is in JSON format contain following properties:

* `access_token` (string): The obtained access token.
* `expires_at` (number): Timestamp indicating when the token expires.
* `expires_in` (number): Duration until the token expires.
* `ext_expires_in` (number): Extended duration until the token expires.
* `token_type` (string): Type of the token.

{% hint style="info" %}
The token must be entered in all other requests, in the Auth section as Bearer Token in the string format prefixed with "Bearer" followed by the access token.

i.e. "Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IndUZXphSTNjdTNVYj..."
{% endhint %}

***

## Code example

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

```python
import requests
import json

url = "https://wilson.40mat.com/apif/v2/auth/token"

payload = json.dumps({
  "app_name": "company-9d5e82680b7b9d...",
  "client_id": "19cd83c2-5137-47d7-905f-...",
  "client_secret": "S-ae305302a441bd4268~8fc..."
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="cURL" %}

```powershell
curl --location 'https://wilson.40mat.com/apif/v2/auth/token' \
--header 'Content-Type: application/json' \
--data '{
    "app_name": "company-9d5e82680b7b9d...",
    "client_id": "19cd83c2-5137-47d7-905f-...",
    "client_secret": "S-ae305302a441bd4268~8fc..."
}'
```

{% endtab %}
{% endtabs %}
