API

User

This section presents all requests related to user account operations.

Register

Allows you to register a new account.

Endpoint

POST /api/register

Request

{
    "login": "email@example.com",
    "password": "Pa$$w0rd!",
    "nickname": "nickname"
}

Answer 201

{
    "id": "66c9f1b2e4b0a1c2d3e4f5a6",
    "login": "email@example.com",
    "nickname": "nickname"
}

Errors

| Status | error | |—|—| | 400 | Login, password and nickname required. / validation messages | | 409 | Login already exists. / Nickname already exists. |

Login

Allows you to log in to your account and create a session.

Endpoint

POST /api/login

Request

{
    "login": "email@example.com",
    "password": "Pa$$w0rd!"
}

Answer 200

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "user": {
        "id": "66c9f1b2e4b0a1c2d3e4f5a6",
        "login": "email@example.com",
        "nickname": "nickname"
    }
}

The token is valid for 7 days. Send it in the Authorization: Bearer <token> header.

Errors

| Status | error | |—|—| | 400 | Login and password required | | 401 | Invalid credentials |

Change password

Endpoint

POST /api/change-password
Authorization: Bearer <token>

Request

{
    "oldPassword": "Pa$$w0rd!",
    "newPassword": "N3wPa$$w0rd!"
}

Answer 200

{ "success": true }

Errors

| Status | error | |—|—| | 400 | Old and new password required / Password must be at least 6 characters. | | 401 | No token provided / Invalid token | | 403 | Old password incorrect |