Skip to content

Auth

Barcha endpointlar Bearer authorization bilan himoyalangan. Barcha ma'lumotlar json formatida almashiniladi.

Barcha requestlar uchun quyidagi header lar majburiy hisoblanadi:

http
Accept: application/json
Content-Type: application/json

Login

Auth uchun tokenni olish

Endpoint

POST /auth/login

Request:

Form

FieldTypeRequiredDescription
emailemailYesUnique user identifier
passwordstringYesPassword

Example

json
{
  "email": "example-email@gmail.com",
  "password": "my-password"
}

Responses:

Status: 200 OK

FieldTypeDescription
statusstringStatussuccess yoki error
codeintResponse http kodi
resultobjectAsosiy ma'lumotlar
result.access_tokenstringAccess token
messagestringUmumiy xabar

Example

json
{
  "status": "success",
  "code": 200,
  "result": {
    "access_token": "1|i5poMifK2y0Sd1Wf8TVKeLVRjJKR8RyPb92YUbKH61170f51"
  },
  "message": "User successfully authenticated"
}

Ehtiyot bo'ling!

access_token avtomatik expire bo'lmaydi (muddati cheklanmagan). Uni faolsizlantirish uchun buni o'qing.

Status: 422 Validation error

Example 1

json
{
  "message": "These credentials do not match our records.",
  "errors": {
    "email": [
      "These credentials do not match our records."
    ]
  }
}

Example 2

json
{
    "message": "The email field must be a valid email address. (and 1 more error)",
    "errors": {
        "email": [
            "The email field must be a valid email address."
        ],
        "password": [
            "The password field is required."
        ]
    }
}

Developer notes:

  • errors obyektidagi kalitlar form field nomlari bilan mos
  • Har bir maydon bir nechta xatolik qaytarishi mumkin
  • Frontend tomonida errors[field][0] ko‘rinishida ishlatish tavsiya etiladi

Me

User ma'lumotlarni olish

Endpoint

GET /auth/me

Responses:

Status: 200 OK

FieldTypeDescription
statusstringStatussuccess yoki error
codeintResponse http kodi
resultobject | AuthUserResourceAuthUserResource
messagestringUmumiy xabar

AuthUserResource

FieldTypeDescription
idint
namestring
emailstring
typeobject
type.numberint1-ADMIN, 2-USER
type.namestringADMIN, USER
created_atstringUser yaratilgan vaqti global time formatida

Example

json
{
  "status": "success",
  "code": 200,
  "result": {
    "id": 1,
    "name": "Root",
    "email": "my@utel.uz",
    "type": {
      "number": 1,
      "name": "ADMIN"
    },
    "created_at": "2025-11-28T07:02:52.000000Z"
  },
  "message": "User successfully retrieved"
}

Change password

User parolini o'zgartirish

Endpoint

POST /auth/change-password

Request:

Form

FieldTypeRequiredDescription
old_passwordstringyesOldingi parol
passwordstringyesmin 6 belgi
password_confirmationstringyespassword ga mos bo'lishi kerak

Example

json
{
    "old_password": "old_password",
    "password": "new_password",
    "password_confirmation": "new_password"
}

Responses:

Status: 200 OK

FieldTypeDescription
statusstringStatussuccess yoki error
codeintResponse http kodi
resultobjectAsosiy ma'lumotlar
result.access_tokenstringAccess token
messagestringUmumiy xabar

Example

json
{
    "status": "success",
    "code": 200,
    "result": {
        "access_token": "2|i5poMifK2y0Sd1Wf8TVKeLVRjJKR8RyPb92YUbKH61170f51"
    },
    "message": "Password successfully updated"
}

Status: 422 Validation error

Example

json
{
    "message": "The old password field is required. (and 2 more errors)",
    "errors": {
        "old_password": [
            "The old password field is required."
        ],
        "password": [
            "The password field is required."
        ],
        "password_confirmation": [
            "The password confirmation field is required."
        ]
    }
}

Logout

access_token ni faolsizlantirish yoki o'chirish

Endpoint

POST /auth/logout

Responses:

Status: 200 OK

Example

json
{
    "status": "success",
    "code": 200,
    "result": [],
    "message": "User unauthenticated"
}