Skip to content

Add documentation for bulk set channel members API#8876

Open
wiggin77 wants to merge 2 commits intomasterfrom
MM-68269_set_channel_membership_api_docs
Open

Add documentation for bulk set channel members API#8876
wiggin77 wants to merge 2 commits intomasterfrom
MM-68269_set_channel_membership_api_docs

Conversation

@wiggin77
Copy link
Copy Markdown
Member

Summary

  • Add setChannelMembers audit event to the embedded JSON audit log schema table

  • Document the new PUT /api/v4/channels/{channel_id}/members bulk membership API in the team and channel members admin guide

Accompanies mattermost/mattermost#36031 which adds the endpoint in Mattermost v11.7.

Ticket Link

https://mattermost.atlassian.net/browse/MM-68269

  Add setChannelMembers audit event to the audit log schema and document
  the new PUT /api/v4/channels/{channel_id}/members endpoint in the
  team and channel members admin guide. Introduced in Mattermost v11.7.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8172b861-bd0d-4773-b1ea-8828c905d360

📥 Commits

Reviewing files that changed from the base of the PR and between 57adbed and f4b4dbc.

📒 Files selected for processing (1)
  • source/administration-guide/manage/team-channel-members.rst
✅ Files skipped from review due to trivial changes (1)
  • source/administration-guide/manage/team-channel-members.rst

📝 Walkthrough

Walkthrough

Documentation additions describing a new API endpoint and audit event type for bulk channel membership operations. Two documentation files updated: one adding the setChannelMembers audit event type to the schema reference, and another documenting the PUT /api/v4/channels/{channel_id}/members endpoint with operational details and restrictions.

Changes

Cohort / File(s) Summary
Audit Event Schema Reference
source/administration-guide/comply/embedded-json-audit-log-schema.rst
Added setChannelMembers event type entry to the "Channel Management Events" audit event types table.
API Documentation
source/administration-guide/manage/team-channel-members.rst
Added new section documenting the PUT /api/v4/channels/{channel_id}/members bulk-set-members API: request/response format (JSON array request, NDJSON streamed responses), batch parameters (batch_size, batch_delay_ms), permission and channel-type restrictions, 12 MB request-body limit, and example curl/NDJSON output.

Sequence Diagram(s)

sequenceDiagram
  participant AdminClient as Admin Client
  participant API as API Server
  participant DB as Database
  participant Audit as Audit Log

  AdminClient->>API: PUT /api/v4/channels/{channel_id}/members (JSON array)
  API->>DB: Read current channel members
  DB-->>API: Current members
  API->>API: Compute diff (adds/removes) and paginate into batches
  loop per batch
    API->>DB: Apply add/remove operations (batch)
    DB-->>API: Operation results
    API->>AdminClient: Stream NDJSON line (added, removed, errors)
  end
  API->>Audit: Emit `setChannelMembers` audit event
  Audit-->>API: Acknowledgement
  API-->>AdminClient: Final NDJSON line (summary/complete)
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely summarizes the main changes: documenting a new bulk set channel members API endpoint.
Description check ✅ Passed The description is directly related to the changeset, detailing both the audit event schema update and the API documentation, with supporting context about the accompanying code change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MM-68269_set_channel_membership_api_docs

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
source/administration-guide/manage/team-channel-members.rst (1)

162-165: Consider adding a minimal request + NDJSON response example.

A tiny concrete example would make integration/testing faster, especially for clients unfamiliar with streaming NDJSON.

Example doc snippet
 System admins can set the complete membership of a channel in a single API call using ``PUT /api/v4/channels/{channel_id}/members``. The request body is a JSON array of user IDs representing the desired membership. The server computes the diff against the current membership and adds or removes users as needed, leaving existing members untouched.
 
 Results are streamed back as NDJSON (``application/x-ndjson``), one line per batch. Each line contains ``added``, ``removed``, and ``errors`` arrays for that batch. Query parameters ``batch_size`` (default 100) and ``batch_delay_ms`` (default 500) control the processing rate.
+
+Example request body::
+
+  ["user_id_1", "user_id_2", "user_id_3"]
+
+Example NDJSON line::
+
+  {"added":["user_id_3"],"removed":["user_id_4"],"errors":[]}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/administration-guide/manage/team-channel-members.rst` around lines 162
- 165, Add a minimal concrete example showing a sample JSON request body and a
few NDJSON response lines for the PUT /api/v4/channels/{channel_id}/members
endpoint so readers can see the exact shape of input and streaming output;
include the endpoint path and show a tiny request array of user IDs and then 2–3
NDJSON lines demonstrating the batch objects with "added", "removed", and
"errors" arrays and note the query parameters batch_size and batch_delay_ms used
to produce the example.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@source/administration-guide/manage/team-channel-members.rst`:
- Around line 162-165: Add a minimal concrete example showing a sample JSON
request body and a few NDJSON response lines for the PUT
/api/v4/channels/{channel_id}/members endpoint so readers can see the exact
shape of input and streaming output; include the endpoint path and show a tiny
request array of user IDs and then 2–3 NDJSON lines demonstrating the batch
objects with "added", "removed", and "errors" arrays and note the query
parameters batch_size and batch_delay_ms used to produce the example.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c22fa3db-4086-4a78-88c5-cf773f73af10

📥 Commits

Reviewing files that changed from the base of the PR and between b888ded and 57adbed.

📒 Files selected for processing (2)
  • source/administration-guide/comply/embedded-json-audit-log-schema.rst
  • source/administration-guide/manage/team-channel-members.rst

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 57adbed

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA f4b4dbc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1: Dev Review Requires review by a core commiter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant