API Reference
Esta � a refer�ncia completa de todos os endpoints de API dispon�veis.
Authentication
Todos os endpoints requerem o header Authorization:
Authorization: Bearer YOUR_API_TOKEN
Response Format
Todas as respostas seguem esta estrutura:
{
"success": true,
"data": { ... },
"message": "Description of the result"
}
Respostas de erro:
{
"success": false,
"error": "Error description",
"code": 400
}
Tenants
List All Tenants
GET /api/saas/tenants
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | No | N�mero da p�gina para pagina��o |
per_page | integer | No | Resultados por p�gina (padr�o: 25, m�x: 100) |
status | string | No | Filtrar por 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 | Nome da empresa |
email | string | Yes | E-mail de contato principal |
first_name | string | Yes | Nome do contato |
last_name | string | Yes | Sobrenome do contato |
plan_id | integer | Yes | Plano a ser atribu�do |
subdomain | string | Yes | Subdom�nio/slug desejado |
password | string | No | Senha da conta (gerada automaticamente se omitida) |
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 | Nome da empresa atualizado |
plan_id | integer | No | Novo plano a ser atribu�do |
status | string | No | active ou inactive |
Delete Tenant
DELETE /api/saas/tenants/{id}
perigo
Isso exclui permanentemente o tenant e todos os seus dados, incluindo o banco de dados. Esta a��o n�o pode ser desfeita.
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 | Nova ID do plano |
expires_at | datetime | No | Nova data de expira��o |
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 ? verifique seus par�metros |
401 | Unauthorized ? token de API inv�lido ou ausente |
404 | Not found ? o recurso n�o existe |
422 | Validation error ? um ou mais campos s�o inv�lidos |
429 | Rate limit exceeded ? diminua suas requisi��es |
500 | Server error ? contate o suporte se persistir |
Need Help?
Se tiver d�vidas sobre a API ou precisar de endpoints adicionais, entre em contato atrav�s dos nossos canais Support & Community.