# Authentication

## Create a session to use truedat's API

<mark style="color:green;">`POST`</mark> `https://my-organization.truedat.io/api/sessions`

Body needs to be provided as raw json. Example:\
`{`\
&#x20; `"access_method":"alternative_login",`\
&#x20; `"user":`\
&#x20;   `{`\
&#x20;     `"user_name":"usuarioaplicacion",`\
&#x20;     `"password":"passwordusuarioaplicacion"`\
&#x20;   `}`\
&#x20;`}`

#### Request Body

| Name                                             | Type   | Description                                                                               |
| ------------------------------------------------ | ------ | ----------------------------------------------------------------------------------------- |
| user\_name<mark style="color:red;">\*</mark>     | String | Username to access the application.                                                       |
| password<mark style="color:red;">\*</mark>       | String | Password of the user who will access.                                                     |
| access\_method<mark style="color:red;">\*</mark> | String | Provide the type of access to use. For API access "alternative\_login" should be provided |

{% tabs %}
{% tab title="201: Created User/password are valid. You will need to include the provided token in the header as a bearer token to access other APIs  " %}

```javascript
{
    "refresh_token": "footoken",
    "token": "footoken"
}
```

{% endtab %}

{% tab title="401: Unauthorized Your user/password combination is not valid" %}

```javascript
{
    "errors": {
        "detail": "Invalid credentials"
    }
}
```

{% 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.truedat.io/v7.1/api-integrations/authentication.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.
