إنتقل إلى المحتوى الرئيسي

???? API

??? ?? ?????? ?????? ????? ???? ????? API ???????.

????????

???? ???? ??????? ????? ??? Authorization:

Authorization: Bearer YOUR_API_TOKEN

????? ?????????

???? ?????????? ???? ??? ??????:

{
"success": true,
"data": { ... },
"message": "Description of the result"
}

???????? ?????:

{
"success": false,
"error": "Error description",
"code": 400
}

??????????

??? ???? ??????????

GET /api/saas/tenants

?????????:

??????????????????????
pageinteger????? ?????? ???????
per_pageinteger????????? ??? ???? (???????: 25? ????: 100)
statusstring????????? ??? ??????: active, inactive, trial

???? ??? ?????????:

{
"success": true,
"data": {
"tenants": [
{
"id": 1,
"company_name": "Acme Corp",
"domain": "acme.yoursite.com",
"plan": "Professional",
"status": "active",
"created_at": "2024-01-15T10:30:00Z"
}
],
"total": 42,
"page": 1,
"per_page": 25
}
}

?????? ??? ?????? ????

GET /api/saas/tenants/{id}

???? ??? ?????????:

{
"success": true,
"data": {
"id": 1,
"company_name": "Acme Corp",
"domain": "acme.yoursite.com",
"plan_id": 2,
"plan_name": "Professional",
"status": "active",
"created_at": "2024-01-15T10:30:00Z",
"expires_at": "2024-02-15T10:30:00Z",
"usage": {
"customers": { "used": 24, "limit": 500 },
"invoices": { "used": 89, "limit": 1000 },
"projects": { "used": 5, "limit": 50 },
"staff": { "used": 3, "limit": 10 }
}
}
}

????? ??????

POST /api/saas/tenants

??????? ????:

??????????????????????
company_namestring?????? ??????
emailstring????????? ?????????? ??????? ???????
first_namestring???????? ????? ???????
last_namestring?????? ??????? ???????
plan_idinteger???????? ?????? ???????
subdomainstring????????? ??????/??????? ???????
passwordstring?????? ???? ?????? (????? ???????? ??? ?? ?????)

????:

curl -X POST https://yoursite.com/api/saas/tenants \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"company_name": "Acme Corp",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"plan_id": 2,
"subdomain": "acme"
}'

????? ??????

PUT /api/saas/tenants/{id}

??????? ????:

??????????????????????
company_namestring????? ?????? ??????
plan_idinteger??????? ??????? ?????? ???????
statusstring??active ?? inactive

??? ??????

DELETE /api/saas/tenants/{id}
خطر

??? ???? ???????? ????? ??????? ???????? ??? ?? ??? ????? ???????. ?? ???? ??????? ?? ??? ???????.


?????

??? ???? ?????

GET /api/saas/plans

???? ??? ?????????:

{
"success": true,
"data": {
"plans": [
{
"id": 1,
"name": "Starter",
"price_monthly": 10.00,
"price_yearly": 100.00,
"billing_cycle": "monthly",
"is_popular": false,
"trial_enabled": true,
"limits": {
"customers": 50,
"invoices": 100,
"projects": 5,
"staff": 2
}
}
]
}
}

?????? ??? ??? ?????

GET /api/saas/plans/{id}

????? ???

POST /api/saas/plans

????? ???

PUT /api/saas/plans/{id}

??? ???

DELETE /api/saas/plans/{id}

??????????

?????? ??? ?????? ????????

GET /api/saas/tenants/{id}/subscription

???? ??? ?????????:

{
"success": true,
"data": {
"tenant_id": 1,
"plan_id": 2,
"plan_name": "Professional",
"status": "active",
"started_at": "2024-01-15T10:30:00Z",
"expires_at": "2024-02-15T10:30:00Z",
"next_invoice_at": "2024-02-15T10:30:00Z",
"billing_cycle": "monthly"
}
}

????? ????????

PUT /api/saas/tenants/{id}/subscription

??????? ????:

??????????????????????
plan_idinteger?????? ????? ???????
expires_atdatetime??????? ?????? ???????? ??????

?????????

?????? ??? ??????? ????????

GET /api/saas/tenants/{id}/usage

???? ??? ?????????:

{
"success": true,
"data": {
"customers": { "used": 24, "limit": 500, "percentage": 4.8 },
"invoices": { "used": 89, "limit": 1000, "percentage": 8.9 },
"projects": { "used": 5, "limit": 50, "percentage": 10.0 },
"staff": { "used": 3, "limit": 10, "percentage": 30.0 },
"estimates": { "used": 12, "limit": 200, "percentage": 6.0 },
"contracts": { "used": 2, "limit": 50, "percentage": 4.0 },
"tasks": { "used": 67, "limit": 500, "percentage": 13.4 }
}
}

???? ???? HTTP

???????????
200????
201?? ??????? ?????
400??? ???? - ???? ?? ????????
401??? ???? - ??? API ??? ???? ?? ?????
404??? ????? - ?????? ??? ?????
422??? ?? ?????? - ??? ???? ?? ???? ??? ????
429????? ?? ?????? - ???? ??????
500??? ?? ?????? - ???? ?????? ??? ?????

????? ???????

??? ???? ???? ????? ??? API ?? ????? ??? ???? ????? ??????? ????? ???? ??? ????? Support & Community ?????? ???.