Skip to content

RBAC API Reference ​

REST API endpoints for managing users, roles, and team membership in MFTPlus. These endpoints live under /api/users/* and are authenticated with the user's Bearer JWT — the same token used to authenticate dashboard requests. They do not accept API-key headers.

Authentication ​

Every request must include the authenticated user's session token in the Authorization header:

bash
Authorization: Bearer <your-user-jwt>

The RBAC endpoints are protected by the user-authentication middleware, not the admin-key or API-key middleware. Use the JWT you receive when logging in to the dashboard (or via mftctl).

List Team Members ​

Returns all members of your team.

http
GET /api/users/team

Response:

json
{
  "members": [
    {
      "id": "user_abc123",
      "email": "alice@example.com",
      "name": "Alice",
      "role": "OWNER",
      "joinedAt": "2025-06-01T00:00:00Z",
      "status": "active"
    },
    {
      "id": "user_def456",
      "email": "bob@example.com",
      "name": "Bob",
      "role": "MEMBER",
      "joinedAt": "2025-06-15T00:00:00Z",
      "status": "active"
    }
  ]
}

Update User Role ​

Changes a team member's role. Requires ADMIN role.

http
POST /api/users/team/:id/role

Request body:

json
{
  "role": "ADMIN"
}

Valid roles: ADMIN, MEMBER.

Constraints:

  • Requires ADMIN role (enforced at server/src/routes/team.ts:423)
  • Assignable roles are ADMIN and MEMBER only (per changeRoleSchema)
  • Demoting the last remaining ADMIN is not allowed (at least one ADMIN must remain)

Invite User ​

Sends an invitation email to a new team member. Invitations are valid for 14 days.

http
POST /api/users/invite

Request body:

json
{
  "email": "newuser@example.com",
  "role": "MEMBER"
}

Response:

json
{
  "invitationId": "inv_xyz789",
  "email": "newuser@example.com",
  "role": "MEMBER",
  "expiresAt": "2025-07-15T00:00:00Z",
  "status": "pending"
}

List Pending Invitations ​

Returns all invitations that have not yet been accepted.

http
GET /api/users/invitations

Response:

json
{
  "invitations": [
    {
      "id": "inv_xyz789",
      "email": "newuser@example.com",
      "role": "MEMBER",
      "expiresAt": "2025-07-15T00:00:00Z",
      "status": "pending"
    }
  ]
}

Revoke Invitation ​

Cancels a pending invitation.

http
DELETE /api/users/invitations/{invitationId}

Response: 204 No Content

Remove Team Member ​

Removes a user from the team. Requires ADMIN or OWNER role.

http
DELETE /api/users/team/{userId}

Response: 204 No Content

Constraints:

  • You cannot remove yourself
  • The last OWNER cannot be removed

Error Responses ​

StatusCodeDescription
400INVALID_ROLEThe specified role is not valid
400LAST_OWNERCannot remove or demote the last OWNER
401UNAUTHORIZEDMissing or invalid authentication
403FORBIDDENInsufficient role permissions
404NOT_FOUNDUser or invitation not found
409ALREADY_INVITEDUser has a pending invitation
429RATE_LIMITEDToo many requests

Next Steps ​