المصادقة (Authentication)
Homatic تستخدم Laravel Sanctum — Bearer tokens للـ API.
Base URLs
| API | URL |
|---|---|
| Tenant | https://{subdomain}.homatic.io/api/v1 |
| Central | https://api.homatic.io/api/central/v1 |
| Portal | https://api.homatic.io/api |
تسجيل دخول Tenant
POST /api/v1/auth/login
Host: acme.homatic.io
Content-Type: application/json
{
"email": "admin@example.com",
"password": "secret"
}
Response 200:
{
"data": {
"user": { "id": 1, "name": "Admin", "email": "admin@example.com" },
"token": "1|abcdef..."
},
"message": "Logged in."
}
تسجيل دخول Central (Super Admin)
POST /api/central/v1/auth/login
Content-Type: application/json
{
"email": "superadmin@homatic.com",
"password": "secret"
}
Portal Login
POST /api/portal/login
Content-Type: application/json
{
"email": "viewer@example.com",
"password": "secret",
"subdomain": "acme"
}
Headers المطلوبة
Authorization: Bearer {token}
Accept: application/json
Content-Type: application/json
للطلبات عبر نطاق مركزي بدون subdomain:
X-Tenant-Subdomain: acme
المستخدم الحالي
GET /api/v1/auth/me
Authorization: Bearer {token}
تسجيل الخروج
POST /api/v1/auth/logout
Authorization: Bearer {token}
مثال cURL
curl -X POST https://acme.homatic.io/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"admin@example.com","password":"secret"}'
curl https://acme.homatic.io/api/v1/devices \
-H "Authorization: Bearer 1|abcdef..." \
-H "Accept: application/json"
أخطاء شائعة
| Code | المعنى |
|---|---|
| 401 | Token غير صالح أو منتهي |
| 403 | صلاحية غير كافية (role) |
| 422 | بيانات validation خاطئة |