Send a Channel Message
Prerequisites
- Delegated login.
- Team and channel IDs.
ChannelMessage.Sendconsent.
teams message send --team "$TEAM_ID" --channel "$CHANNEL_ID" --body "Hello from teams-cli" --output json
Give the post a subject line — the bold title Teams renders above the body, the same field the client offers behind "Add a subject":
teams message send --team "$TEAM_ID" --channel "$CHANNEL_ID" --subject "Release plan" --body "Details inside." --output json
Only channel root messages carry a subject. Chat messages have none, so --subject with --chat
is rejected as invalid input (exit 2) before anything is sent. The subject comes back on
message list and message get; human-readable lists show it in a Subject column, and JSON omits
it for messages that have none.
Send an inline image:
teams message send --team "$TEAM_ID" --channel "$CHANNEL_ID" --image ./screenshot.png --output json
Attach a file. Channel attachments upload to the team's SharePoint-backed file store and require Files.ReadWrite.All.
teams message send \
--team "$TEAM_ID" \
--channel "$CHANNEL_ID" \
--body "Logs attached" \
--attach ./logs.zip \
--output json
Verify with:
teams message list --team "$TEAM_ID" --channel "$CHANNEL_ID" --page-size 1 --output json
That listing returns thread roots only. To read the replies under a post, pass its ID with
--message-id; see Read and Watch Channels.
To take a post back, soft-delete it, and restore it with message undelete. Add --reply REPLY_ID
to target a reply in the thread, with the root post as the message ID:
teams message delete --team "$TEAM_ID" --channel "$CHANNEL_ID" --message "$MESSAGE_ID" --yes --output json
teams message undelete --team "$TEAM_ID" --channel "$CHANNEL_ID" --message "$MESSAGE_ID" --output json
Channel deletion needs the delegated ChannelMessage.ReadWrite scope. It is not in the default
set because Microsoft marks it admin-consent required, so an administrator grants it first
(teams auth consent-url --scopes ...) and you then sign in with it. A PERMISSION_DENIED on a
channel target says so unless your token already carries the scope.
Inline images are capped at 3 MB each and 4 MB combined after base64 encoding. File attachments use Microsoft Graph's 250 MB simple-upload limit. See Message Attachments for storage, scope, and download details.