-
Notifications
You must be signed in to change notification settings - Fork 5
Multi‐Tenant System API Documentation
ybw0014 edited this page Feb 3, 2024
·
7 revisions
This document provides an overview and detailed description of the essential APIs for a multi-tenant system. These APIs cover the management of tenants, users, permissions, and authentication processes, following RESTful principles, secure practices, and clear error handling.
All the standard HTTP API points return the following response:
{
"code": "number",
"message": "string",
"data": "object"
}
-
Endpoint:
/api/v1/tenants -
Method:
POST - Description: Allows a new user to register and create a new tenant.
- Request Body:
{
"tenantName": "string",
"adminEmail": "string",
"businessType": "string"
}
-
Response:
-
Status:
201 Created - Response data object:
-
Status:
{
"tenantId": "number"
}
-
Endpoint:
/api/v1/tenants/{tenantId} -
Method:
GET - Description: Provides detailed information about a specific tenant.
-
Response:
-
Status:
200 OK - Body:
-
Status:
{
"tenantId": "string",
"tenantName": "string",
"createdDate": "datetime",
"adminEmail": "string",
"businessType": "string"
}
-
Endpoint:
/api/v1/tenants/{tenantId} -
Method:
PUT - Description: Updates information of a tenant.
- Request Body:
{
"tenantName": "string",
"businessType": "string"
}
-
Response:
-
Status:
200 OK - Body:
-
Status:
{
"message": "Tenant updated successfully."
}
-
Endpoint:
/api/v1/users -
Method:
POST - Description: Registers a new user in the system.
- Request Body:
{
"email": "string",
"password": "string",
"tenantId": "string"
}
-
Response:
-
Status:
201 Created - Body:
-
Status:
{
"userId": "string",
"message": "User registered successfully."
}
-
Endpoint:
/api/v1/users/login -
Method:
POST - Description: User login to obtain access token.
- Request Body:
{
"email": "string",
"password": "string"
}
-
Response:
-
Status:
200 OK - Body: { "token": "string" }
-
Status:
-
Endpoint:
/api/v1/tenants/{tenantId}/users -
Method:
GET - Description: Retrieves a list of all users within a tenant.
-
Response:
-
Status:
200 OK - Body:
-
Status:
{
"users": [
{
"userId": "string",
"email": "string",
...
},
...
]
}
-
Endpoint:
/api/v1/roles -
Method:
GET - Description: Retrieves a list of all roles defined in the system.
-
Response:
-
Status:
200 OK - Body:
-
Status:
{
"roles": ["role1", "role2", ...]
}
-
Endpoint:
/api/v1/users/{userId}/roles -
Method:
POST - Description: Assigns roles to a specific user.
- Request Body:
{
"roles": ["role1", "role2", ...]
}
-
Response:
-
Status:
200 OK - Body: { "message": "Roles assigned successfully." }
-
Status:
-
Endpoint:
/api/v1/auth/validate -
Method:
POST - Description: Validates a user's access token.
- Request Body:
{
"token": "string"
}
-
Response:
-
Status:
200 OK - Body:
-
Status:
{
"isValid": "boolean",
"userId": "string",
"message": "Token is valid."
}