# Authentication API

## Authenticate with Telmai

This API authenticates user credentials and returns an access token

<mark style="color:green;">`POST`</mark> `{auth_endpoint}/auth/token`

#### **Parameters**

| **Name**        | **Type** | **Description**                                                   |
| --------------- | -------- | ----------------------------------------------------------------- |
| `clientId`      | string   | Client identifier for the application                             |
| `grantType`     | string   | Type of authentication. Use `"password"` or `"refresh_token"`.    |
| `username`      | string   | Username for the user                                             |
| `password`      | string   | Password for the user. Required if grant\_type is "password"      |
| `refreshToken`  | string   | Refresh token string. Required if grant\_type is "refresh\_token" |
| `code`          | string   | Authorization code (used for `authorization_code` grant type)     |
| `redirectUrl`   | string   | URL to redirect to after authorization                            |
| `transactionId` | string   | Unique ID for tracking the request                                |
| `tenant`        | string   | Identifier for the tenant                                         |

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-type<mark style="color:red;">\*</mark> | string | application/x-www-form-urlencoded |

{% tabs %}
{% tab title="curl" %}
`curl -X 'POST'`\
`'{auth_endpoint}/auth/token?clientId=string&grantType=password&username=string&password=string&refreshToken=string&code=string&redirectUri=string&transactionId=string&tenant=string'`\
`-H 'accept: */*'`\
`-d ''`
{% endtab %}
{% endtabs %}

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

```json
{
  "expires": 3600,
  "access_token": "string",
  "refresh_token": "string",
  "token_type": "string"
}
```

{% endtab %}

{% tab title="401" %}

```
{"description": "Unauthorized"}
```

{% endtab %}

{% tab title="403" %}

<pre><code><strong>{"description": "Forbidden"}
</strong></code></pre>

{% endtab %}

{% tab title="404" %}

```
{"description": "Not Found"}
```

{% endtab %}
{% endtabs %}
