Authentication
All endpoints require a valid Bearer token in the Authorization header.Base URL
Endpoints Overview
User Endpoints
Get Current User
Get the authenticated user’s details including all organization memberships.GET /api/users/me
Response:
Returns only active organization memberships. Invited, suspended, or deleted memberships are not included.
List Users in Organization
Get a paginated list of users in an organization, including both active users and pending invitations.GET /api/users/list
Query Parameters:
Response:
This endpoint returns a hybrid list combining:
- Active users (status: “active”)
- Pending invitations (status: “pending” or “expired”)
Invite User to Organization
Send an invitation to a user to join an organization with a specific role.POST /api/users/invite
Query Parameters:
Request Body:
Response:
Invitation Flow:
- User record is pre-created with status “invited”
- Invitation email is sent via Stytch with a magic link
- Organization member record is created with status “invited”
- Invitation expires after 7 days
- When user accepts, their status changes to “active”
Update User Role
Update a user’s role within an organization.PUT /api/users/update
Query Parameters:
Request Body:
Response:
To change a user’s role, the authenticated user must:
- Have
users:writepermission - Be an owner in the organization
users:write operations.Error Responses
Common Error Scenarios
Cannot Update Role - Not an Owner
Cannot Update Role - Not an Owner
Error: 403 Forbidden - “Only users with ‘owner’ role can update user roles”Solution: Only organization owners can update user roles. If you need to change roles, ask an owner to do it.
Cannot Assign Owner Role
Cannot Assign Owner Role
Error: 403 Forbidden - “The ‘owner’ role cannot be assigned to users”Solution: The owner role is reserved for organization creators and cannot be assigned via the API. To transfer ownership, contact support.
User Already Has Role
User Already Has Role
Error: 400 Bad Request - “User already has the ‘admin’ role assigned”Solution: Check the user’s current role before updating. You cannot assign the same role a user already has.
Cannot Update Invited User
Cannot Update Invited User
Error: 400 Bad Request - “Cannot update role for user with status ‘invited’”Solution: Wait for the user to accept the invitation first. Only active members can have their roles updated.
Implementation Notes
User Statuses
Users can have different statuses in an organization:Role Assignment Rules
-
Owner Role Special Case:
- Owner role is automatically assigned when creating an organization
- Cannot be assigned via API
- Cannot be removed (organization must have at least one owner)
-
Role Hierarchy:
- Roles have hierarchy levels (0-100)
- Higher levels generally have more permissions
- Check role hierarchy before assignment
-
Permission Requirements:
- Viewing users:
users:readpermission - Inviting users:
users:writepermission - Updating roles:
users:writepermission AND owner role
- Viewing users:
Pagination
The/api/users/list endpoint uses offset-based pagination:
offset: Page number (0-based)limit: Items per pagetotal: Total count of items
Invitation Expiry
- Invitations expire after 7 days
- Expired invitations show status “expired” in user list
- To resend an expired invitation, create a new invitation
Related Documentation
- Invitation Flow - Complete invitation process
- Roles Service - Managing roles and permissions
- Organization Service - Managing organizations
- RBAC Permissions - Understanding permissions