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/jsonLogin
Auth uchun tokenni olish
Endpoint
POST /auth/login
Request:
Form
| Field | Type | Required | Description |
|---|---|---|---|
email | Yes | Unique user identifier | |
password | string | Yes | Password |
Example
json
{
"email": "example-email@gmail.com",
"password": "my-password"
}Responses:
Status: 200 OK
| Field | Type | Description |
|---|---|---|
status | string | Statussuccess yoki error |
code | int | Response http kodi |
result | object | Asosiy ma'lumotlar |
result.access_token | string | Access token |
message | string | Umumiy 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:
errorsobyektidagi 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
| Field | Type | Description |
|---|---|---|
status | string | Statussuccess yoki error |
code | int | Response http kodi |
result | object | AuthUserResource | AuthUserResource |
message | string | Umumiy xabar |
AuthUserResource
| Field | Type | Description |
|---|---|---|
id | int | |
name | string | |
email | string | |
type | object | |
type.number | int | 1-ADMIN, 2-USER |
type.name | string | ADMIN, USER |
created_at | string | User 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
| Field | Type | Required | Description |
|---|---|---|---|
old_password | string | yes | Oldingi parol |
password | string | yes | min 6 belgi |
password_confirmation | string | yes | password ga mos bo'lishi kerak |
Example
json
{
"old_password": "old_password",
"password": "new_password",
"password_confirmation": "new_password"
}Responses:
Status: 200 OK
| Field | Type | Description |
|---|---|---|
status | string | Statussuccess yoki error |
code | int | Response http kodi |
result | object | Asosiy ma'lumotlar |
result.access_token | string | Access token |
message | string | Umumiy 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"
}