Account Administration
Account Administration provides comprehensive account lifecycle management including plan overrides, account status management, and administrative account modifications.
API Endpoints Overview
| Method | Endpoint | Description |
|---|---|---|
PUT | /v1/admin/accounts/:id | Update account ban status |
PUT | /v1/admin/accounts/:id/plan-override | Enable/disable plan override |
Service Methods & Business Logic
Account Ban Management Services
updateAcc({ accountId, ban }) - Account ban/unban operations
- Service Method:
accountService.updateAcc({ accountId, ban }) - Controller:
accountController.updateAccount - Route:
PUT /v1/admin/accounts/:id - Parameters:
accountId- Account ID to ban/unbanban- Boolean indicating ban status (true = ban, false = unban)
- Process Flow:
- Account Update: Updates account
bannedfield - Session Cleanup: If banning, deletes all API sessions for the account
- Audit Logging: Logs ban/unban action with account ID
- Account Update: Updates account
- MongoDB Collections:
_accounts,_api-sessions - Returns: Updated account object
Plan Override Management
planOverride({ accountId, overrideEnabled }) - Plan override enable/disable operations
- Service Method:
accountService.planOverride({ accountId, overrideEnabled }) - Controller:
accountController.planOverride - Route:
PUT /v1/admin/accounts/:id/plan-override - Parameters:
accountId- Account ID from URL parameteroverrideEnabled- Boolean to enable/disable plan override
- Validation Logic:
- Account must exist (throws 404 if not found)
- Account must be a main account (sub-accounts not supported)
- Account must not have tier_override disabled
- Process Flow:
- Enable Override: Creates/updates TierOverride record with active store price
- Disable Override: Deletes existing TierOverride record
- Price Selection: Finds active software price matching account's pricing type
- MongoDB Collections:
_accounts,_tier-overrides,_store.prices - Returns: Success confirmation (no data returned)
Technical Implementation Details
Account Ban Implementation
const updateAcc = async ({ accountId, ban }) => {
const account = await Account.findByIdAndUpdate(accountId, { banned: ban });
if (ban == true) {
await APISession.deleteMany({ account_id: accountId });
logger.log({
initiator: 'internal/admin/updateAcc',
message: 'Account banned:' + accountId,
});
} else {
logger.log({
initiator: 'internal/admin/updateAcc',
message: 'Account unbanned:' + accountId,
});
}
return account;
};
Plan Override Implementation
const planOverride = async ({ accountId, overrideEnabled }) => {
const account = await Account.findById(accountId);
if (!account) throw notFound('Account not found.');
if (!account._doc?.main) throw forbidden('Tier Override is disabled for sub-accounts.');
if (account._doc?.tier_override === false)
throw forbidden('Tier Override is disabled for this account.');
if (overrideEnabled) {
const pricingType = account._doc.pricing_type || DEFAULT_PRICING_TYPE;
const price = await StorePrice.findOne({
active: true,
'metadata.product_type': 'software',
'metadata.account_pricing_type': pricingType,
'metadata.show_in_dashboard': 'true',
});
await TierOverride.updateOne(
{ account: accountId },
{ account: accountId, status: 'active', price: price._id },
{ upsert: true },
);
} else {
await TierOverride.deleteOne({ account: accountId });
}
};
API Response Formats
Account Ban Response
{
"success": true,
"message": "SUCCESS"
}
Plan Override Response
{
"success": true,
"message": "SUCCESS"
}
Request Parameters
Account Ban Parameters
{
"id": "507f1f77bcf86cd799439011",
"ban": true
}
Plan Override Parameters
{
"override_enabled": true
}
Error Handling
Account Administration Error Scenarios
- 404 Not Found: Account not found (plan override only)
- 403 Forbidden:
- Tier Override is disabled for sub-accounts
- Tier Override is disabled for this account
- 500 Internal Server Error: Database operation failures
Usage Examples
Ban/Unban Account
PUT /v1/admin/accounts/507f1f77bcf86cd799439011
Content-Type: application/json
X-Session-Id: MongoDB ObjectId
{
"id": "507f1f77bcf86cd799439011",
"ban": true
}
Enable Plan Override
PUT /v1/admin/accounts/507f1f77bcf86cd799439011/plan-override
Content-Type: application/json
X-Session-Id: MongoDB ObjectId
{
"override_enabled": true
}
Disable Plan Override
PUT /v1/admin/accounts/507f1f77bcf86cd799439011/plan-override
Content-Type: application/json
X-Session-Id: MongoDB ObjectId
{
"override_enabled": false
}