Skip to main content

Overview

The Tenant Management API provides endpoints for managing tenant accounts, including tenant creation, configuration, and status management. Tenants represent separate organizations or instances within the multi-tenant jshERP system. Base Path: /tenant
Tenant management endpoints typically require administrator-level permissions.

CRUD Operations

Get Tenant Information

GET /tenant/info?id={id}
Retrieves detailed information for a specific tenant.
id
long
required
Tenant record ID
code
integer
Response status code (200 for success)
info
object
Tenant entity object
curl -X GET "http://localhost:9999/jshERP-boot/tenant/info?id=1" \
  -H "Authorization: Bearer {token}"

Get Tenant List

GET /tenant/list?search={search}
Retrieves a paginated list of tenants with optional filtering.
JSON string containing search filters:
  • loginName: Filter by login name
  • type: Filter by tenant type
  • enabled: Filter by enabled status
  • remark: Filter by remark text
rows
array
Array of TenantEx objects with extended information
total
integer
Total number of records matching the search criteria
curl -X GET "http://localhost:9999/jshERP-boot/tenant/list?search={\"type\":\"1\"}" \
  -H "Authorization: Bearer {token}"

Create Tenant

POST /tenant/add
Creates a new tenant account.
tenantId
long
required
Unique tenant business ID
loginName
string
required
Associated login name
userNumLimit
integer
required
Maximum number of users allowed
type
string
required
Tenant type:
  • 0: Free tenant
  • 1: Paid tenant
enabled
boolean
default:"true"
Tenant enabled status
expireTime
date
Expiration date (format: yyyy-MM-dd HH:mm:ss)
remark
string
Additional remarks or notes
{
  "tenantId": 63336699809321,
  "loginName": "company_admin",
  "userNumLimit": 50,
  "type": "1",
  "enabled": true,
  "expireTime": "2025-12-31 23:59:59",
  "remark": "Enterprise tenant account"
}

Update Tenant

PUT /tenant/update
Updates an existing tenant’s configuration.
id
long
required
Tenant record ID
loginName
string
Associated login name
userNumLimit
integer
Maximum number of users allowed
type
string
Tenant type (0: free, 1: paid)
enabled
boolean
Tenant enabled status
expireTime
date
Expiration date
remark
string
Additional remarks
{
  "id": 1,
  "userNumLimit": 100,
  "expireTime": "2026-12-31 23:59:59",
  "remark": "Upgraded to premium plan"
}

Delete Tenant

DELETE /tenant/delete?id={id}
Deletes a tenant account (soft delete).
Deleting a tenant will affect all associated users and data. This operation should be performed with caution.
id
long
required
Tenant record ID to delete
code
integer
Response status code

Batch Delete Tenants

DELETE /tenant/deleteBatch?ids={ids}
Deletes multiple tenants in a single operation.
ids
string
required
Comma-separated tenant IDs (e.g., “1,2,3”)
code
integer
Response status code

Tenant Management

Check Tenant Name Exists

GET /tenant/checkIsNameExist?id={id}&name={name}
Checks if a tenant login name is already in use.
id
long
required
Tenant record ID (0 for new tenant)
name
string
Login name to check
status
boolean
true if name exists, false otherwise
curl -X GET "http://localhost:9999/jshERP-boot/tenant/checkIsNameExist?id=0&name=test_tenant" \
  -H "Authorization: Bearer {token}"

Batch Set Tenant Status

POST /tenant/batchSetStatus
Enables or disables multiple tenants at once.
status
boolean
required
Status to set:
  • true: Enable tenants
  • false: Disable tenants
ids
string
required
Comma-separated tenant IDs
code
integer
Response status code
{
  "status": false,
  "ids": "1,2,3"
}

Data Models

Tenant Entity

id
long
Unique tenant record identifier
tenantId
long
Tenant business identifier (used throughout the system)
loginName
string
Associated login name for the tenant account
userNumLimit
integer
Maximum number of users allowed for this tenant
type
string
Tenant type:
  • 0: Free tenant (limited features)
  • 1: Paid tenant (full features)
enabled
boolean
Tenant enabled status:
  • true: Tenant is active
  • false: Tenant is disabled
createTime
date
Timestamp when the tenant was created
expireTime
date
Expiration timestamp for the tenant subscription
remark
string
Additional remarks or notes about the tenant
deleteFlag
string
Soft delete flag (used internally)

Tenant Types

Free Tenant (Type: 0)

  • Limited number of users
  • Basic features only
  • May have restricted functionality
  • No expiration date required
  • Higher user limits
  • Full feature access
  • Requires expiration date
  • Premium support

Common Use Cases

Creating a New Tenant

  1. Check if the tenant name exists using /tenant/checkIsNameExist
  2. Create the tenant using /tenant/add with appropriate limits
  3. Configure the expiration date for paid tenants
  4. Set the user limit based on subscription plan

Managing Tenant Expiration

  1. Retrieve tenant information using /tenant/info
  2. Check the expireTime field
  3. Update the expiration date using /tenant/update when renewing
  4. Monitor tenant status - expired tenants are automatically disabled

Disabling Multiple Tenants

  1. Collect tenant IDs to disable
  2. Use /tenant/batchSetStatus with status: false
  3. Verify changes using /tenant/list

Best Practices

User Limit Management: Always set realistic user limits based on the tenant’s subscription plan. The system will prevent user creation when the limit is reached.
Expiration Handling: For paid tenants, always set an appropriate expiration date. The system automatically checks expiration and disables access when expired.
Tenant Deletion: Deleting a tenant is a serious operation that affects all associated data. Always backup data before deletion and consider disabling instead of deleting.

Error Codes

CodeDescription
200Success
500Internal server error
All endpoints return a standard response format with code and data fields. Check the code field to determine success or failure.

Build docs developers (and LLMs) love