API Reference
This is the complete reference for all available API endpoints.
Authenticationโ
All endpoints require the Authorization header:
Authorization: Bearer YOUR_API_TOKEN
Response Formatโ
All responses follow this structure:
{
"success": true,
"data": { ... },
"message": "Description of the result"
}
Error responses:
{
"success": false,
"error": "Error description",
"code": 400
}
Tenantsโ
List All Tenantsโ
GET /api/saas/tenants
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | No | Page number for pagination |
per_page | integer | No | Results per page (default: 25, max: 100) |
status | string | No | Filter by status: active, inactive, trial |
Example Response:
{
"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 Single Tenantโ
GET /api/saas/tenants/{id}
Example Response:
{
"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 }
}
}
}
Create Tenantโ
POST /api/saas/tenants
Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
company_name | string | Yes | Company name |
email | string | Yes | Primary contact email |
first_name | string | Yes | Contact first name |
last_name | string | Yes | Contact last name |
plan_id | integer | Yes | The plan to assign |
subdomain | string | Yes | Desired subdomain/slug |
password | string | No | Account password (auto-generated if omitted) |
Example:
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"
}'
Update Tenantโ
PUT /api/saas/tenants/{id}
Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
company_name | string | No | Updated company name |
plan_id | integer | No | New plan to assign |
status | string | No | active or inactive |
Delete Tenantโ
DELETE /api/saas/tenants/{id}
danger
This permanently deletes the tenant and all their data, including their database. This action cannot be undone.
Plansโ
List All Plansโ
GET /api/saas/plans
Example Response:
{
"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 Single Planโ
GET /api/saas/plans/{id}
Create Planโ
POST /api/saas/plans
Update Planโ
PUT /api/saas/plans/{id}
Delete Planโ
DELETE /api/saas/plans/{id}
Subscriptionsโ
Get Tenant Subscriptionโ
GET /api/saas/tenants/{id}/subscription
Example Response:
{
"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"
}
}
Update Subscriptionโ
PUT /api/saas/tenants/{id}/subscription
Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
plan_id | integer | No | New plan ID |
expires_at | datetime | No | New expiration date |
Usageโ
Get Tenant Usageโ
GET /api/saas/tenants/{id}/usage
Example Response:
{
"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 Status Codesโ
| Code | Meaning |
|---|---|
200 | Success |
201 | Created successfully |
400 | Bad request โ check your parameters |
401 | Unauthorized โ invalid or missing API token |
404 | Not found โ the resource doesn't exist |
422 | Validation error โ one or more fields are invalid |
429 | Rate limit exceeded โ slow down your requests |
500 | Server error โ contact support if this persists |
Need Help?โ
If you have questions about the API or need additional endpoints, contact us through our Support & Community channels.