Skip to main content
The Users Service provides endpoints for viewing user information, inviting users to organizations, and managing user roles within organizations.

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.
Endpoint: 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.
Endpoint: GET /api/users/list Query Parameters: Response:
This endpoint returns a hybrid list combining:
  • Active users (status: “active”)
  • Pending invitations (status: “pending” or “expired”)
Results are sorted with active users first, then by creation date (newest first).

Invite User to Organization

Send an invitation to a user to join an organization with a specific role.
Endpoint: POST /api/users/invite Query Parameters: Request Body: Response:
Invitation Flow:
  1. User record is pre-created with status “invited”
  2. Invitation email is sent via Stytch with a magic link
  3. Organization member record is created with status “invited”
  4. Invitation expires after 7 days
  5. When user accepts, their status changes to “active”
See Invitation Flow for complete details.

Update User Role

Update a user’s role within an organization.
Endpoint: PUT /api/users/update Query Parameters: Request Body: Response:
Restrictions:
  • Only users with owner role can update user roles
  • The owner role cannot be assigned via this endpoint (reserved for organization creators)
  • Only active members can have their roles updated
  • Cannot assign the same role a user already has
  • Requires both users:write permission AND owner role
To change a user’s role, the authenticated user must:
  1. Have users:write permission
  2. Be an owner in the organization
This is more restrictive than other users:write operations.

Error Responses

Common Error Scenarios

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.
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.
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.
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

  1. 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)
  2. Role Hierarchy:
    • Roles have hierarchy levels (0-100)
    • Higher levels generally have more permissions
    • Check role hierarchy before assignment
  3. Permission Requirements:
    • Viewing users: users:read permission
    • Inviting users: users:write permission
    • Updating roles: users:write permission AND owner role

Pagination

The /api/users/list endpoint uses offset-based pagination:
  • offset: Page number (0-based)
  • limit: Items per page
  • total: Total count of items
Example for page 3 with 10 items per page:

Invitation Expiry

  • Invitations expire after 7 days
  • Expired invitations show status “expired” in user list
  • To resend an expired invitation, create a new invitation