Skip to content

Commit bc7cc5f

Browse files
Update OpenAPI spec
1 parent c61ae9e commit bc7cc5f

File tree

1 file changed

+181
-6
lines changed

1 file changed

+181
-6
lines changed

site/static/mattermost-openapi-v4.yaml

Lines changed: 181 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7708,6 +7708,181 @@ paths:
77087708
}
77097709
fmt.Printf("Added user %s to channel %s with roles %s using post %s\n", userId, channelId, cm.Roles, postRootId)
77107710
}
7711+
put:
7712+
tags:
7713+
- channels
7714+
summary: Set channel members
7715+
description: |
7716+
Set the complete membership list for a channel, with optional channel admin designation.
7717+
The server compares the provided list against the current membership and adds or removes
7718+
users as needed. Users already in the channel are left untouched (no-op).
7719+
7720+
When `channel_admins` is provided, a role reconciliation phase runs after membership
7721+
changes: listed users are promoted to channel admin, all other members are demoted.
7722+
When `channel_admins` is omitted (null), existing admin roles are preserved.
7723+
7724+
Results are streamed back as NDJSON (`application/x-ndjson`), one line per batch. Each line
7725+
is a JSON object with `added`, `removed`, `promoted`, `demoted`, and `errors` arrays for
7726+
that batch.
7727+
7728+
Removals are processed before additions, then role changes. Private channels cannot be
7729+
emptied entirely. DM/GM and group-constrained channels are rejected.
7730+
7731+
#### Example: membership only
7732+
7733+
Request (using `batch_size=2` and `batch_delay_ms=200`):
7734+
7735+
```bash
7736+
curl -X PUT \
7737+
'https://mattermost.example.com/api/v4/channels/channel123/members?batch_size=2&batch_delay_ms=200' \
7738+
-H 'Authorization: Bearer <token>' \
7739+
-H 'Content-Type: application/json' \
7740+
-d '{"members": ["user_id_1", "user_id_2", "user_id_3", "user_id_4"]}'
7741+
```
7742+
7743+
Streamed NDJSON response (one JSON object per line, one line per batch):
7744+
7745+
```text
7746+
{"added":[],"removed":["user_id_5","user_id_6"],"errors":[]}
7747+
{"added":["user_id_3","user_id_4"],"removed":[],"errors":[]}
7748+
{"added":[],"removed":[],"errors":[{"user_id":"user_id_7","id":"api.channel.add_members.user_denied","error":"user is not a member of the team"}]}
7749+
```
7750+
7751+
In this example, `user_id_1` and `user_id_2` were already members (no-op), `user_id_5` and
7752+
`user_id_6` were removed, `user_id_3` and `user_id_4` were added, and `user_id_7` could not
7753+
be added because the user is not on the team.
7754+
7755+
#### Example: membership with admin roles
7756+
7757+
```bash
7758+
curl -X PUT \
7759+
'https://mattermost.example.com/api/v4/channels/channel123/members' \
7760+
-H 'Authorization: Bearer <token>' \
7761+
-H 'Content-Type: application/json' \
7762+
-d '{"members": ["user_id_1", "user_id_2", "user_id_3"], "channel_admins": ["user_id_1"]}'
7763+
```
7764+
7765+
Response:
7766+
7767+
```text
7768+
{"added":["user_id_3"],"removed":["user_id_4"]}
7769+
{"promoted":["user_id_1"],"demoted":["user_id_2"]}
7770+
```
7771+
7772+
In this example, `user_id_1` was promoted to channel admin and `user_id_2` was demoted.
7773+
When `channel_admins` is omitted, existing admin roles are preserved.
7774+
7775+
__Minimum server version__: 11.7
7776+
##### Permissions
7777+
Must have `manage_system` permission (system admin only).
7778+
operationId: SetChannelMembers
7779+
parameters:
7780+
- name: channel_id
7781+
in: path
7782+
description: Channel GUID
7783+
required: true
7784+
schema:
7785+
type: string
7786+
- name: batch_size
7787+
in: query
7788+
description: Number of add/remove operations per batch.
7789+
schema:
7790+
type: integer
7791+
default: 100
7792+
minimum: !!float 1
7793+
maximum: !!float 1000
7794+
- name: batch_delay_ms
7795+
in: query
7796+
description: Milliseconds to pause between batches, giving the server time to process websocket events and plugin hooks.
7797+
schema:
7798+
type: integer
7799+
default: 500
7800+
maximum: !!float 10000
7801+
requestBody:
7802+
description: JSON object specifying the complete desired membership and optional channel admin designations. Request body is limited to 12 MB.
7803+
content:
7804+
application/json:
7805+
schema:
7806+
type: object
7807+
required:
7808+
- members
7809+
properties:
7810+
members:
7811+
type: array
7812+
items:
7813+
type: string
7814+
description: User IDs for the desired channel membership. The final membership is the union of `members` and `channel_admins`.
7815+
channel_admins:
7816+
type: array
7817+
nullable: true
7818+
items:
7819+
type: string
7820+
description: User IDs that should have the channel admin role. Users listed here are automatically included in the desired membership (they do not need to also appear in `members`). When null or omitted, existing admin roles are preserved for members who remain in the channel. When present (including empty array), admin roles are set declaratively.
7821+
required: true
7822+
responses:
7823+
"200":
7824+
description: |
7825+
Streamed NDJSON response. Each line is a JSON object representing one batch of results.
7826+
7827+
If the operation is interrupted (e.g. context cancellation), a final NDJSON line
7828+
with an `error` field is emitted so the client can distinguish partial from full
7829+
success: `{"error":"The set channel members operation was cancelled."}`
7830+
content:
7831+
application/x-ndjson:
7832+
schema:
7833+
oneOf:
7834+
- type: object
7835+
description: A batch of results from the set channel members operation.
7836+
properties:
7837+
added:
7838+
type: array
7839+
items:
7840+
type: string
7841+
description: User IDs successfully added to the channel in this batch.
7842+
removed:
7843+
type: array
7844+
items:
7845+
type: string
7846+
description: User IDs successfully removed from the channel in this batch.
7847+
promoted:
7848+
type: array
7849+
items:
7850+
type: string
7851+
description: User IDs promoted to channel admin in this batch.
7852+
demoted:
7853+
type: array
7854+
items:
7855+
type: string
7856+
description: User IDs demoted from channel admin in this batch.
7857+
errors:
7858+
type: array
7859+
items:
7860+
type: object
7861+
properties:
7862+
user_id:
7863+
type: string
7864+
description: The user ID that failed.
7865+
id:
7866+
type: string
7867+
description: Machine-readable error identifier (i18n key).
7868+
error:
7869+
type: string
7870+
description: Human-readable description of the failure.
7871+
description: Per-user failures (not on team, deleted user, cannot remove from default channel, plugin rejection).
7872+
- type: object
7873+
description: Terminal error line emitted when the operation is interrupted.
7874+
required:
7875+
- error
7876+
properties:
7877+
error:
7878+
type: string
7879+
description: Human-readable description of the interruption.
7880+
"400":
7881+
$ref: '#/components/responses/BadRequest'
7882+
"401":
7883+
$ref: '#/components/responses/Unauthorized'
7884+
"403":
7885+
$ref: '#/components/responses/Forbidden'
77117886
/api/v4/channels/{channel_id}/members/ids:
77127887
post:
77137888
tags:
@@ -21940,9 +22115,9 @@ paths:
2194022115
first_page_ascending:
2194122116
summary: First page, ascending order
2194222117
value:
21943-
cursor: ""
21944-
per_page: 100
2194522118
channel_id: 4xp9fdt77pncbef59f4k1qe83o
22119+
per_page: 100
22120+
cursor: ""
2194622121
subsequent_page:
2194722122
summary: Subsequent page using cursor
2194822123
value:
@@ -21953,15 +22128,15 @@ paths:
2195322128
summary: Query with time range starting from specific time
2195422129
value:
2195522130
channel_id: 4xp9fdt77pncbef59f4k1qe83o
21956-
cursor: ""
2195722131
start_time: 1635638400000
2195822132
per_page: 100
22133+
cursor: ""
2195922134
descending_order:
2196022135
summary: Descending order from recent
2196122136
value:
21962-
channel_id: 4xp9fdt77pncbef59f4k1qe83o
2196322137
cursor: ""
2196422138
sort_direction: desc
22139+
channel_id: 4xp9fdt77pncbef59f4k1qe83o
2196522140
per_page: 100
2196622141
responses:
2196722142
"200":
@@ -27402,8 +27577,8 @@ components:
2740227577
description: Additional attributes for the property field (options for select fields, visibility, etc.).
2740327578
additionalProperties: true
2740427579
example:
27405-
sortOrder: 1
2740627580
visibility: when_set
27581+
sortOrder: 1
2740727582
options:
2740827583
- color: '#ff0000'
2740927584
id: opt1
@@ -31671,8 +31846,8 @@ components:
3167131846
Enabled: true
3167231847
ReviewerIds: []
3167331848
u1ujk34a47gfxp856pdczs9gey:
31674-
ReviewerIds: []
3167531849
Enabled: false
31850+
ReviewerIds: []
3167631851
required:
3167731852
- CommonReviewers
3167831853
- SystemAdminsAsReviewers

0 commit comments

Comments
 (0)