Manage users and roles
You decide what people can do in your product. Your customers' admins decide who on their team can do it — without a ticket to you, and without you building a user-management backend.
How it fits together
Each customer company is an environment (tenant) in your account.
| Defined by | Applies to | Can change it | |
|---|---|---|---|
| Permissions | You | One catalog for your whole product | Only you |
| Admin role | AuthJet (built in) | Every environment | Nobody |
| Standard roles | You | Every environment | Only you |
| Custom roles | A customer's Admins | That one environment | Its Admins (and you) |
- Availability: each permission is available in every environment, or only selected ones — ship a new permission to dev first, then promote it; or keep an internal one to your own staff environment.
- Admin automatically has every permission available in its environment, including ones you add later.
- Tokens carry the result:
app_role,app_permissionsandtenant_admin— see verifying tokens.
Set it up (once)
- In the dashboard, open App Roles & Permissions and add your permissions, e.g.
bookings:read. - Add standard roles your product offers everyone, e.g. Staff and Manager.
- Optional: in Settings → Invite emails, set your own invite page (
https://yourapp.com/join?token={token}). Leave it blank to use our hosted page. - For each new customer, create their environment and invite their first person as Admin. From there, they run their own team.
What your customers' Admins can do
Can
- See their company's users
- Add people — email invite, or set a password so they can sign in straight away
- Change roles (including making someone else an Admin), deactivate, reactivate and remove users
- Create custom roles from any permission available to them
Can't
- Create permissions or edit your standard roles
- Change their own role or status, or remove themselves
- Leave their company without an active Admin
- Choose where invite emails link to — that’s your invite link setting
Seat limits apply to their invites. Everyone else in the company can only see their own profile.
Build a "Team" page in your app
With the JavaScript SDK, your frontend calls these endpoints directly with the signed-in Admin's token — no backend of your own needed.
TeamPage.tsx
import { useEffect, useState } from 'react'
import { useAuthFetch } from '@authjet/react'
const API = 'https://api.authjet.dev/api/v1'
type Member = { id: string; email: string; app_role: string | null; status: string }
type Role = { id: string; name: string; kind: 'admin' | 'standard' | 'custom' }
// A company Admin's "Team" page. Only users with the built-in Admin role get tenant_admin: true;
// everyone else gets 403 from these endpoints, so hide the page for them.
export function TeamPage() {
const authFetch = useAuthFetch()
const [isAdmin, setIsAdmin] = useState(false)
const [members, setMembers] = useState<Member[]>([])
const [roles, setRoles] = useState<Role[]>([])
const [email, setEmail] = useState('')
async function load() {
setMembers((await (await authFetch(`${API}/users`)).json()).items)
setRoles(await (await authFetch(`${API}/app-roles`)).json())
}
useEffect(() => {
authFetch(`${API}/users/me`)
.then((res) => res.json())
.then((me) => {
setIsAdmin(me.tenant_admin)
if (me.tenant_admin) load()
})
}, [authFetch])
async function invite(roleId: string) {
// The email links to the invite page you set in AuthJet; they choose their own password.
await authFetch(`${API}/users/invite`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, app_role_id: roleId }),
})
setEmail('')
await load()
}
async function changeRole(userId: string, roleId: string) {
await authFetch(`${API}/users/${userId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ app_role_id: roleId }),
})
await load()
}
if (!isAdmin) return null
return (
<div>
<input value={email} onChange={(e) => setEmail(e.target.value)} placeholder="[email protected]" />
{roles.map((r) => (
<button key={r.id} onClick={() => invite(r.id)}>Invite as {r.name}</button>
))}
<ul>
{members.map((m) => (
<li key={m.id}>
{m.email} ({m.status})
<select value={roles.find((r) => r.name === m.app_role)?.id ?? ''} onChange={(e) => changeRole(m.id, e.target.value)}>
{roles.map((r) => (
<option key={r.id} value={r.id}>{r.name}</option>
))}
</select>
</li>
))}
</ul>
</div>
)
}Endpoints (Admin only)
| GET | /api/v1/users | List users |
| POST | /api/v1/users/invite | Invite by email (optional app_role_id) |
| POST | /api/v1/users | Create with a password (optional app_role_id) |
| PATCH | /api/v1/users/{id} | Change role (app_role_id), status or name |
| POST | /api/v1/users/{id}/reactivate | Reactivate |
| DELETE | /api/v1/users/{id} | Remove |
| GET | /api/v1/app-roles | Roles usable in this environment |
| POST · PATCH · DELETE | /api/v1/app-roles | Manage custom roles |
Good to know
- Role and permission changes reach tokens at the next refresh (within 30 minutes). Deactivating someone signs them out within the same window.
- A role that users still hold can't be deleted — move them first.
- Permission names can't be changed once created, because your backend and users' tokens match on them.
AuthJet