Staff & Admin API Reference
Complete admin API reference for Emberly staff. Manage users, moderate content, handle reports, configure products, and monitor system health.
The Admin API provides staff and administrators with access to user management, moderation, billing, product configuration, and system monitoring tools.
Authentication
Admin Token
All admin endpoints require either:
- Admin session (via browser login with admin role)
- Admin API key (for backend services)
Admin users have role: "ADMIN" or role: "SUPERADMIN" in the database.
Authorization Levels
| Level | Description | Can Access |
|---|---|---|
| USER | Regular user | Only own data via user API |
| ADMIN | Staff/moderator | Moderation, reports, basic user data |
| SUPERADMIN | Owner/lead admin | Everything, including system config |
User Management
List All Users
GET /api/admin/users
List all users with filtering and search.
Authentication: ADMIN+
Query Parameters:
page(default: 1) — Page numberlimit(default: 50) — Users per pagesearch— Search by name, email, or urlIdrole— Filter byUSER,ADMIN,SUPERADMINstatus— Filter byactive,banned,suspendedcreatedAfter— ISO date (created after this date)sort—recent,active,storage-usage
Response (200):
Get User Details
GET /api/admin/users/[userId]
Get detailed information about a specific user.
Authentication: ADMIN+
Response (200):
Ban/Suspend User
POST /api/admin/users/[userId]/ban
Ban or suspend a user account.
Authentication: ADMIN+
Request Body:
Response (200):
Unban User
DELETE /api/admin/users/[userId]/ban
Remove a ban or suspension.
Authentication: ADMIN+
Request Body:
Response (200):
Modify User Role
PATCH /api/admin/users/[userId]/role
Change a user's role (USER, ADMIN, SUPERADMIN).
Authentication: SUPERADMIN only
Request Body:
Response (200):
Reset User Password (Force)
POST /api/admin/users/[userId]/reset-password
Force a password reset for a user.
Authentication: ADMIN+
Request Body:
Response (200):
Delete User (GDPR)
DELETE /api/admin/users/[userId]
Permanently delete a user and all their data.
Authentication: SUPERADMIN only
Request Body:
Response (200):
User Sessions & Login History
Get User Sessions
GET /api/admin/users/[userId]/sessions
List active sessions for a user.
Authentication: ADMIN+
Response (200):
Revoke User Session
POST /api/admin/users/[userId]/sessions/[sessionId]/revoke
Log out a specific session.
Authentication: ADMIN+
Response (200):
Get Login History
GET /api/admin/users/[userId]/login-history
View user's login history.
Authentication: ADMIN+
Query Parameters:
page(default: 1)limit(default: 50)
Response (200):
Moderation & Reports
List Content Reports
GET /api/admin/reports
List all user reports of content or users.
Authentication: ADMIN+
Query Parameters:
type—contentoruserstatus—open,investigating,resolved,dismissedseverity—low,medium,highpage(default: 1)limit(default: 50)
Response (200):
Get Report Details
GET /api/admin/reports/[reportId]
Get full details of a report.
Authentication: ADMIN+
Response (200): Report object with full context
Update Report Status
PATCH /api/admin/reports/[reportId]
Update report status and add resolution notes.
Authentication: ADMIN+
Request Body:
Response (200):
Delete Content (Reported)
DELETE /api/admin/content/[fileId]
Remove reported content from the platform.
Authentication: ADMIN+
Request Body:
Response (200):
File Auditing
Flag File for Review
POST /api/admin/files/[fileId]/flag
Mark a file for internal review.
Authentication: ADMIN+
Request Body:
Response (200):
Get Flagged Files
GET /api/admin/files/flagged
List all flagged files.
Authentication: ADMIN+
Query Parameters:
page(default: 1)limit(default: 50)reason— Filter by flag reason
Response (200):
Unflag File
POST /api/admin/files/[fileId]/unflag
Remove a flag from a file.
Authentication: ADMIN+
Request Body:
Response (200):
Products & Billing
List Products
GET /api/admin/products
List all available plans and products.
Authentication: ADMIN+
Response (200):
Create Product
POST /api/admin/products
Create a new plan or add-on product.
Authentication: SUPERADMIN only
Request Body:
Response (201):
Edit Product
PATCH /api/admin/products/[productId]
Update product details, price, or features.
Authentication: SUPERADMIN only
Request Body:
Response (200):
Financial & Subscriptions
Get User Subscription
GET /api/admin/users/[userId]/subscription
View a user's active subscription.
Authentication: ADMIN+
Response (200):
View Revenue
GET /api/admin/revenue
Get revenue metrics and statistics.
Authentication: ADMIN+
Query Parameters:
period—day,month,yearstartDate— ISO dateendDate— ISO date
Response (200):
Email & Notifications
Send Bulk Email
POST /api/admin/emails/broadcast
Send an email to multiple users.
Authentication: SUPERADMIN only
Request Body:
Response (200):
Get Email Template
GET /api/admin/emails/templates
List available email templates.
Authentication: ADMIN+
Response (200):
Audit Logs
Get Audit Log
GET /api/admin/audit-logs
View all system activity and admin actions.
Authentication: ADMIN+
Query Parameters:
action— Filter by action typeadmin— Filter by admin user IDtarget— Filter by affected resourcepage(default: 1)limit(default: 50)
Response (200):
System Health & Monitoring
System Status
GET /api/admin/status
Get system health and performance metrics.
Authentication: ADMIN+
Response (200):
Analytics
GET /api/admin/analytics
Get platform-wide analytics.
Authentication: ADMIN+
Query Parameters:
period—day,week,month,yearstartDate— ISO dateendDate— ISO date
Response (200):
Error Handling
Admin endpoints follow the same error format as user endpoints:
Admin-Specific Error Codes:
| Code | Meaning |
|---|---|
ADMIN_REQUIRED | User must be ADMIN+ |
SUPERADMIN_REQUIRED | User must be SUPERADMIN |
INVALID_USER_ID | User not found |
CANNOT_MODIFY_SELF | Can't modify own account |
INVALID_ACTION | Action not allowed |
Best Practices
- Always log actions — Document why you took action
- Use dry-run first — Preview bulk operations before executing
- Require 2FA — All admin accounts should have 2FA enabled
- Monitor audit logs — Regularly review admin activity
- Least privilege — Don't promote users to SUPERADMIN unless necessary
- Document policies — Keep clear rules for moderation decisions
Support
For admin support:
- Email: [email protected]
- Discord: #staff channel
Additional Admin Endpoints
The following endpoints are documented from the live API and supplement the sections above.
User Verification
POST /api/admin/users/[id]/verify — Mark user as verified (isVerified = true)
DELETE /api/admin/users/[id]/verify — Unverify a user
User Grants
Awards that grant extra storage, domains, or other benefits.
GET /api/admin/users/[id]/grants — List grants for a user
POST /api/admin/users/[id]/grants — Award a grant
DELETE /api/admin/users/[id]/grants — Revoke a grant (?grantId=)
User Storage Assignment
PUT /api/admin/users/[id]/storage
Assign a specific storage bucket to a user. Sends bucket credentials email to the user.
Pass { "bucketId": null } to clear the assignment and return user to the default bucket.
Revoke User Sessions
DELETE /api/users/[id]/sessions
Immediately invalidates all active sessions for a user (increments their session version). The user is forced to log in again on all devices.
Remove User Avatar
DELETE /api/users/[id]/avatar
Remove a user's avatar from storage and clear it from their profile. Admin only.
Content Flagging
POST /api/admin/content/flag
Flag or unflag a file or URL for content review.
contentType must be "FILE" or "URL". Set flagged: false to unflag.
Applications Management
GET /api/admin/applications
Paginated list of all submitted applications (staff, partner, verification, ban appeals).
Query Parameters:
type—staff,partner,verification,ban_appealstatus—pending,reviewing,approved,rejectedpage,limit
PATCH /api/admin/applications/[id]
Review an application.
status values: APPROVED, REJECTED, REVIEWING
Audit Logs
GET /api/admin/audit/logs
Paginated audit log of all admin and system events.
Query Parameters:
action— Filter by event action typeresourceType— Filter by resource (user,file,domain, etc.)from— ISO date startto— ISO date endsuccess—trueorfalsepage,limit
Response (200):
Email Operations
POST /api/admin/emails/broadcast
Broadcast an email to a filtered set of users.
recipientFilter values: "all", "verified", "unverified", "admin"
Set dryRun: true to see recipient count without sending.
POST /api/admin/email/send
Send a transactional email to specific recipients.
GET /api/admin/email/stats
Email delivery statistics for the past 30 days.
Response (200):
GET /api/admin/email/logs — SuperAdmin only
Paginated email event logs with filtering by status and date.
Promo Codes
GET /api/admin/promo-codes — List Stripe promo codes and coupons
POST /api/admin/promo-codes — Create a new promo code
DELETE /api/admin/promo-codes/[id] — Deactivate (archive) a promo code
Products
DELETE /api/admin/products/[id]
Soft-delete a product (deletedAt set, isActive = false). Does not affect existing subscribers.
POST /api/admin/products/[id]/sync
Sync product to Stripe — creates or updates the Stripe product and its prices, then writes back Stripe IDs to the database.
Storage Buckets
GET /api/admin/storage/buckets — List all S3 storage bucket configurations (secrets masked)
POST /api/admin/storage/buckets — Add a new S3 bucket
GET /api/admin/storage/buckets/[id] — Get bucket details (secrets masked)
PUT /api/admin/storage/buckets/[id] — Update bucket configuration
DELETE /api/admin/storage/buckets/[id] — Remove bucket configuration
POST /api/admin/storage/buckets/[id]/test — Test S3 connectivity using HeadBucketCommand
POST /api/admin/storage/test — Test S3 connectivity with provided credentials (not persisted)
PUT /api/admin/storage/squads/[id] — Assign/clear a storage bucket for a squad
System API Key
GET /api/admin/system-key — SuperAdmin only. Get system API key metadata (prefix and creation date). The full key is never returned after initial creation.
POST /api/admin/system-key — SuperAdmin only. Generate or rotate the system API key. Returns the full key once as esk_.... Store it immediately.
Integration Tests
POST /api/admin/integrations/test
Test third-party service connectivity.
Valid values: "stripe", "resend", "cloudflare", "discord", "github", "kener", "smtp"
Returns { success, latencyMs, message }.
System Update Check
GET /api/updates/check
Compare the running version against the latest GitHub release.
Response (200):