Skip to content

Overview ​

Admin APIs provide Super Admin users with full control over platform configuration, companies, users, and system health. All endpoints require authentication with a Super Admin account.

Base URL: https://api.tendsocial.com/api/admin

Authentication: Bearer token with isSuperAdmin: true


Authentication ​

All admin endpoints require:

  1. Valid JWT token in Authorization header
  2. User account with isSuperAdmin: true
bash
Authorization: Bearer YOUR_JWT_TOKEN

403 Response if user is not a Super Admin:

json
{
  "error": "Super admin access required"
}

Configuration Endpoints ​

System Settings ​

Get System Settings ​

http
GET /api/admin/config/system

Response:

json
{
  "id": "default",
  "appName": "TendSocial",
  "appUrl": "https://app.tendsocial.com",
  "supportEmail": "support@tendsocial.com",
  "alertEmail": "alerts@tendsocial.com",
  "allowSignups": true,
  "requireEmailVerification": true,
  "defaultTrialDays": 14,
  "maxTeamMembersDefault": 10,
  "maxSocialAccountsDefault": 5,
  "dailyAIBudgetUSD": "50.00",
  "monthlyAIBudgetUSD": "1000.00",
  "updatedAt": "2025-12-03T10:30:00Z"
}

Update System Settings ​

http
PUT /api/admin/config/system

Request Body:

json
{
  "appName": "Your Brand",
  "appUrl": "https://yourbrand.com",
  "supportEmail": "support@yourbrand.com",
  "defaultTrialDays": 30,
  "dailyAIBudgetUSD": 100.00
}

All fields are optional. Only provided fields will be updated.

Response: Updated settings object


Billing Configuration ​

Get Billing Config ​

http
GET /api/admin/config/billing

Response:

json
{
  "id": "default",
  "provider": "lemonsqueezy",
  "apiKey": "ls_***",
  "storeId": "12345",
  "webhookSecret": "whsec_***",
  "testMode": false,
  "variantMapping": {
    "variant_123": "starter",
    "variant_456": "professional",
    "variant_789": "agency"
  },
  "currency": "USD",
  "taxEnabled": false,
  "updatedAt": "2025-12-03T10:30:00Z"
}

Update Billing Config ​

http
PUT /api/admin/config/billing

Request Body:

json
{
  "apiKey": "ls_new_key",
  "storeId": "12345",
  "webhookSecret": "whsec_secret",
  "variantMapping": {
    "variant_123": "starter",
    "variant_456": "professional"
  },
  "testMode": true
}

Auto-Sync: If GSM_SYNC_ENABLED=true, updates automatically sync to Google Secret Manager.


Email Templates ​

List Email Templates ​

http
GET /api/admin/config/email-templates

Response:

json
[
  {
    "id": "uuid-1",
    "name": "team_invite",
    "description": "Team invitation email",
    "subject": "You're invited to join {{companyName}} on {{appName}}",
    "htmlBody": "<!DOCTYPE html>...",
    "textBody": "Plain text version...",
    "variables": ["companyName", "inviterName", "inviteUrl", "appName"],
    "category": "team",
    "isActive": true,
    "createdAt": "2025-12-01T00:00:00Z",
    "updatedAt": "2025-12-03T10:30:00Z"
  }
]

Get Email Template ​

http
GET /api/admin/config/email-templates/:id

Response: Single template object

Update Email Template ​

http
PUT /api/admin/config/email-templates/:id

Request Body:

json
{
  "subject": "Updated subject with {{variable}}",
  "htmlBody": "<!DOCTYPE html><html>...</html>",
  "textBody": "Plain text version",
  "isActive": true,
  "description": "Updated description"
}

Response: Updated template object


Feature Flags ​

List Feature Flags ​

http
GET /api/admin/config/features

Response:

json
[
  {
    "id": "uuid-1",
    "name": "ai_content_generation",
    "description": "Enable AI-powered content generation features",
    "isEnabled": true,
    "enabledForTiers": ["starter", "professional", "agency", "enterprise"],
    "enabledForCompanyIds": [],
    "metadata": null,
    "createdAt": "2025-12-01T00:00:00Z",
    "updatedAt": "2025-12-03T10:30:00Z"
  },
  {
    "id": "uuid-2",
    "name": "multi_agent_system",
    "description": "Enable multi-agent research system",
    "isEnabled": false,
    "enabledForTiers": ["professional", "agency", "enterprise"],
    "enabledForCompanyIds": ["company-id-1"],
    "metadata": { "maxAgents": 5 },
    "createdAt": "2025-12-01T00:00:00Z",
    "updatedAt": "2025-12-03T10:30:00Z"
  }
]

Update Feature Flag ​

http
PUT /api/admin/config/features/:id

Request Body:

json
{
  "isEnabled": true,
  "enabledForTiers": ["professional", "enterprise"],
  "enabledForCompanyIds": ["company-123", "company-456"],
  "metadata": { "maxAgents": 10 },
  "description": "Updated description"
}

Response: Updated feature flag object


Integration Configs ​

List Integrations ​

http
GET /api/admin/config/integrations

Response:

json
[
  {
    "id": "uuid-1",
    "service": "resend",
    "displayName": "Resend (Email)",
    "isEnabled": true,
    "apiKey": "re_***",
    "apiSecret": null,
    "webhookUrl": null,
    "settings": { "fromEmail": "noreply@tendsocial.com" },
    "rateLimit": 100,
    "updatedAt": "2025-12-03T10:30:00Z"
  },
  {
    "id": "uuid-2",
    "service": "slack",
    "displayName": "Slack",
    "isEnabled": true,
    "apiKey": null,
    "apiSecret": null,
    "webhookUrl": "https://hooks.slack.com/services/***",
    "settings": {},
    "rateLimit": null,
    "updatedAt": "2025-12-03T10:30:00Z"
  }
]

Update Integration ​

http
PUT /api/admin/config/integrations/:id

Request Body:

json
{
  "isEnabled": true,
  "apiKey": "new_api_key",
  "webhookUrl": "https://hooks.slack.com/services/new-webhook",
  "settings": { "fromEmail": "support@yourbrand.com" },
  "rateLimit": 200
}

Auto-Sync: Updates automatically sync to Google Secret Manager if enabled.

Response: Updated integration object


Cache Management ​

Clear Config Cache ​

http
POST /api/admin/config/cache/clear

Clears all cached configuration. Useful after bulk updates.

Response:

json
{
  "success": true,
  "message": "Cache cleared"
}

GSM Sync Status ​

Get GSM Sync Status ​

http
GET /api/admin/config/gsm/status

Check if Google Secret Manager sync is enabled and working.

Response:

json
{
  "enabled": true,
  "connection": {
    "success": true,
    "error": ""
  }
}

Response when disabled:

json
{
  "enabled": false,
  "connection": {
    "success": false,
    "error": "GSM sync is disabled"
  }
}

AI Configuration Endpoints ​

AI Gateway Config ​

List Gateway Configs ​

http
GET /api/admin/gateway

Manage AI gateway routing and fallback configuration.

Update Gateway Config ​

http
PUT /api/admin/gateway/:id

AI Model Config ​

List AI Models ​

http
GET /api/admin/ai-config

Configure available AI models, pricing, and capabilities.

Update AI Model ​

http
PUT /api/admin/ai-config/:id

Company AI Config ​

Get Company AI Settings ​

http
GET /api/admin/companies/:companyId/ai-config

View per-company AI configuration and usage.

Update Company AI Settings ​

http
PUT /api/admin/companies/:companyId/ai-config

Admin Settings Endpoints ​

Global Settings ​

Get Admin Settings ​

http
GET /api/admin/settings

Response:

json
{
  "id": "default",
  "defaultTrialDays": 14
}

Update Admin Settings ​

http
PUT /api/admin/settings

Request Body:

json
{
  "defaultTrialDays": 30
}

Error Responses ​

401 Unauthorized ​

json
{
  "error": "Unauthorized"
}

403 Forbidden ​

json
{
  "error": "Super admin access required"
}

404 Not Found ​

json
{
  "error": "Template not found"
}

400 Bad Request ​

json
{
  "error": "Validation failed",
  "details": {
    "apiKey": "API key is required"
  }
}

500 Internal Server Error ​

json
{
  "error": "Internal server error",
  "message": "Failed to update configuration"
}

Rate Limiting ​

Admin endpoints are subject to rate limiting:

  • Limit: 100 requests per minute per IP
  • Header: X-RateLimit-Remaining

429 Response:

json
{
  "error": "Too many requests",
  "retryAfter": 60
}

Webhooks ​

Admin actions can trigger webhooks (future feature):

  • Configuration changed
  • Feature flag toggled
  • Company created/suspended
  • User role changed

SDKs & Examples ​

cURL Examples ​

Update System Settings:

bash
curl -X PUT https://api.tendsocial.com/api/admin/config/system \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"appName": "Your Brand", "defaultTrialDays": 30}'

Enable Feature Flag:

bash
curl -X PUT https://api.tendsocial.com/api/admin/config/features/uuid \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"isEnabled": true, "enabledForTiers": ["professional", "enterprise"]}'

Update Integration:

bash
curl -X PUT https://api.tendsocial.com/api/admin/config/integrations/uuid \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"apiKey": "new_key", "isEnabled": true}'

JavaScript/TypeScript ​

typescript
const API_URL = 'https://api.tendsocial.com';
const token = 'YOUR_JWT_TOKEN';

// Get system settings
const settings = await fetch(`${API_URL}/api/admin/config/system`, {
  headers: { 'Authorization': `Bearer ${token}` }
}).then(r => r.json());

// Update feature flag
await fetch(`${API_URL}/api/admin/config/features/${flagId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    isEnabled: true,
    enabledForTiers: ['professional', 'enterprise']
  })
});

See Also ​

TendSocial Documentation