> For the complete documentation index, see [llms.txt](https://docs.maibmerchants.md/mia-qr-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maibmerchants.md/mia-qr-api/en/endpoints/authentication/obtain-authentication-token.md).

# Obtain Authentication Token

**POST** `/v2/auth/token`

This endpoint allows obtaining an Access Token required to authorize all subsequent requests to the QR MIA API.

***

#### Request parameters (body)

| Parameter      | Type          | Required | Description                                   |
| -------------- | ------------- | -------- | --------------------------------------------- |
| `clientId`     | string (guid) | Yes      | Client code provided by **maib**              |
| `clientSecret` | string (guid) | Yes      | The client’s secret key, provided by **maib** |

**Example request (body)**

```json
{
  "clientId": "749c564f-1a65-48e3-a4bf-b7932b6ae3db",
  "clientSecret": "0d922db8-9a2f-4c66-a60d-76a762c9bb04"
}
```

***

####

#### Response parameters

| Field                | Type    | Description                                             |
| -------------------- | ------- | ------------------------------------------------------- |
| `result.accessToken` | string  | The access token to be used in the Authorization header |
| `result.expiresIn`   | integer | The token's lifespan, in seconds                        |
| `result.tokenType`   | string  | The token type (Bearer)                                 |
| `ok`                 | boolean | `true` if the request was successfully processed        |
| `errors`             | array   | List of errors, if `ok = false`                         |

**Example response**

```json
{
  "result": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "expiresIn": 300,
    "tokenType": "Bearer"
  },
  "ok": true
}
```

***

**Using the Access Token**\
After obtaining the token, it must be included in the header of every request to the QR MIA API in the form:\
**Example usage (curl)**

```bash
curl -X POST https://api.example.com/v2/mia/qr \
  -H "Authorization: Bearer {{access_token}}" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "Dynamic",
    "expiresAt": "2029-10-22T10:32:28+03:00",
    "amountType": "Fixed",
    "amount": 50.00,
    "currency": "MDL",
    "description": "Order description",
    "callbackUrl": "https://example.com/callback"
  }'
```
