> For the complete documentation index, see [llms.txt](https://ninja-lender.gitbook.io/ninja-lender-v2-api-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ninja-lender.gitbook.io/ninja-lender-v2-api-en/authorization.md).

# Authorization

**Method:** POST

**Url:** <https://test.ninjalender.online/auth&#x20>;

**Headers:**

| header\_key   | content           |
| ------------- | ----------------- |
| Content-Type: | application/json; |

\
&#x20;**Request body:**

| Key      | Type | Required | Decription    |
| -------- | ---- | -------- | ------------- |
| login    | text | +        | User login    |
| password | text | +        | User password |

&#x20;**Response:**

| Ключ               | Тип         | Описание                   |
| ------------------ | ----------- | -------------------------- |
| code               | int         | Response code              |
| message            | string      | Response message           |
| data               | JSON.object | Response data              |
| data.access\_token | string      | Access token               |
| log\_key           | numeric     | ID for current request log |

The received token should be added to the headers in all next requests.

**Request example:**

```
{
  "login": "test",
  "password": "25d55ad282aa400af464c76d713c07ad"
}
```

**Response example:**

**Success:**

```
{
    "code": 0,
    "message": "ok",
    "data": {
        "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODAzOTQxNzIsImV4cCI6MTU4MDQ4MDU3MiwidXNlcl9pZCI6IjEiLCJvcmdhbml6YXRpb25faWQiOiIxIn0.hidUXBWEUzI2NvkfrC2_pDNfXmIpIqd5KxqYNMdJDzQ"
    },
    "log_key": 728
}
```

&#x20;**Error:**

```
{
    "code": -1,
    "message": "error",
    "log_key": 747,
    "errors": [
        {
            "code": -1000003,
            "message": "user not found"
        }
    ]
}
    

```

**Error list:**

| Ключ     | Сообщение              |
| -------- | ---------------------- |
| -96      | invalid key            |
| -97      | invalid token          |
| -98      | expired token          |
| -99      | system error           |
| -100     | access denied          |
| -1000001 | login is blank         |
| -1000002 | invalid password       |
| -1000003 | user not found         |
| -1000004 | user is not active     |
| -1000005 | password did not match |
