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