Hayon includes a built-in admin layer that lets privileged users manage accounts, override subscription plans, and control user access. All admin operations are protected by two layers of middleware:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/devxtra-community/hayon/llms.txt
Use this file to discover all available pages before exploring further.
authenticate and isAdmin.
Admin role
Users in Hayon have arole field that is either user (default) or admin. The role is stored on the user document in MongoDB:
role field directly in the database. There is no self-serve promotion flow — admin access must be granted by a database operator or another admin via a direct update.
How admin access is enforced
Every route under/api/admin applies two middleware functions in order:
isAdmin middleware:
Admin login
Admins authenticate through the standard auth endpoint with admin credentials:Bearer token in the Authorization header for all subsequent admin API calls.
The admin login endpoint performs the same authentication as the regular login but is intended for admin-facing tooling and scripts. The returned JWT contains the user’s
role, which the isAdmin middleware reads.Listing all users
Retrieve a list of every registered user on the platform:Updating a user’s plan
Override a user’s subscription plan directly, bypassing Stripe. This is useful for granting Pro access to team members, resolving billing issues, or resetting a user to Free.plan query parameter must be either free or pro. Any other value returns a 400 error.
Successful response:
Updating a plan via this endpoint changes the user’s
subscription.plan and updates their limits accordingly (maxPosts and maxCaptionGenerations). It does not create or modify any Stripe subscription — it is a direct database override.Activating and deactivating accounts
You can disable or re-enable a user account. Disabled accounts (isDisabled: true) are blocked from logging in and using the platform.
activity field in the request body must be a boolean. Any other type returns a 400 error.
Successful response:
Admin routes summary
| Method | Path | Description |
|---|---|---|
GET | /api/admin/get-all-users | List all users |
PATCH | /api/admin/update-user-plan/:id | Override a user’s subscription plan |
PATCH | /api/admin/update-user-activity/:id | Enable or disable a user account |
GET | /api/admin/analytics | Retrieve platform-wide analytics |
authenticate + isAdmin middleware.