Skip to main content

Mattermost Endpoints

Endpoints for managing Mattermost team messaging sessions, configuration, and organization sync.
Source: equa-server/modules/agent/src/mattermost/mattermost-endpoints.ts

POST /api/v1/mattermost/session

Provisions a Mattermost user and team for the current user and organization, then returns a session token for iframe embedding. Authentication: Cookie (Equa session) Request Body:
Response (200):
Error Responses: Behavior:
  1. Validates session cookie and org membership
  2. Calls ensureUser() — creates Mattermost user if not exists, stores mapping
  3. Calls issueSessionToken() — creates personal access token, AES-encrypts and stores
  4. Calls ensureTeam() — creates Mattermost team with default channels if not exists
  5. Calls ensureTeamMembership() — adds user to team if not already a member
  6. Returns token and connection details
Source: equa-server/modules/agent/src/mattermost/mattermost-endpoints.ts, Line: 34

GET /api/v1/mattermost/config

Returns Mattermost configuration status for the frontend. Authentication: Cookie (Equa session) Response (200):
When Mattermost is not configured:
Source: equa-server/modules/agent/src/mattermost/mattermost-endpoints.ts, Line: 110

GET /api/v1/mattermost/team-mapping/:teamId

Maps a Mattermost team ID to an Equa organization ID. Used by equabot-gateway to resolve org context for agent interactions. Authentication: Bearer token (gateway auth token) Path Parameters: Response (200):
Error Responses:
Source: equa-server/modules/agent/src/mattermost/mattermost-endpoints.ts, Line: 127

POST /api/v1/mattermost/sync-org/:orgId

Triggers a full synchronization of Equa organization members to the corresponding Mattermost team. Adds missing members and removes members no longer in the org. Authentication: Cookie (Equa session, must have org admin permissions) Path Parameters: Response (200):
Error Responses:
Source: equa-server/modules/agent/src/mattermost/mattermost-endpoints.ts, Line: 150

GET /api/v1/mattermost/token-health

Validates the authenticated user’s stored Mattermost personal access token by checking it against the Mattermost server. Used by the frontend for periodic session health monitoring. Authentication: Cookie (Equa session) Response (200):
When the token is invalid or missing:
Error Responses:
Source: equa-server/modules/agent/src/mattermost/mattermost-endpoints.ts

GET /api/v1/mattermost/user-mapping/:mmUserId

Maps a Mattermost user ID to an Equa user ID. Used by equabot-gateway to resolve sender identity for org-scoped agent interactions. Authentication: Bearer token (gateway auth token via EQUA_GATEWAY_TOKEN) Path Parameters: Response (200):
When no mapping exists:
Error Responses:
Source: equa-server/modules/agent/src/mattermost/mattermost-endpoints.ts