# Authentication

## 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 %}


---

# 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.telm.ai/telmai/api-reference/authentication-api.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.
