# Channel messages and replies

Posts and replies in a team's channels: send, edit, react, soft delete and undo, with each change read back through the thread.

Channel messages are a team's threaded posts, each with its own replies. Load the `teams_launch_hub` scenario, post to its General channel and read the thread back:

```bash
H='Authorization: Bearer placeholder-token'
J='Content-Type: application/json'
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$RYSTIC_URL/_rystic/scenario" -d '{"name":"teams_launch_hub"}'
# -> 204
CH="$RYSTIC_URL/v1.0/teams/3dd52548-ef0b-41b9-896b-e62254b098ed/channels/19:945d6093233e5bf6a9eed190df738bf3@thread.tacv2"
curl -s "$CH/messages" -H "$H" -H "$J" -d '{"body":{"content":"Nightly build 812 is green."}}' | jq -c '{id, body, from: .from.user.displayName}'
# -> {"id":"1772409600001","body":{"content":"Nightly build 812 is green.","contentType":"text"},"from":"Priya Nair"}
curl -s "$CH/messages" -H "$H" | jq -c '[.value[].body.content]'
# -> ["Nightly build 812 is green.","<p>New onboarding mockups are ready for review.</p><p><img src=\".../v1.0/teams/3dd52548-ef0b-41b9-896b-e62254b098ed/channels/19:945d6093233e5bf6a9eed190df738bf3@thread.tacv2/messages/1771256429915/hostedContents/aWQ9eF8wLXd1cy1kNC0xY2E0NWY3MmRlMjU1MGI0YjU1OWQzZjQ0ODIyNjczZix0eXBlPTE=/$value\" alt=\"Onboarding welcome screen\" width=\"16\" height=\"9\"></p>","<p>Atlas ships on March 17. The checklist lives in Release Readiness.</p>"]
```

Every request runs as Priya Nair, the scenario's signed-in member. An image in a seeded post points at the simulator's own address, so following it stays on the simulator.

### Reply to a post

A reply sits under its post, and `replyToId` names the post:

```bash
M=1772409600001
curl -s "$CH/messages/$M/replies" -H "$H" -H "$J" -d '{"body":{"content":"Thanks for the heads-up."}}' | jq -c '{id, replyToId}'
# -> {"id":"1772409600002","replyToId":"1772409600001"}
curl -s "$CH/messages/$M/replies" -H "$H" | jq -c '[.value[].body.content]'
# -> ["Thanks for the heads-up."]
```

### Edit, react to and delete a reply

A reply takes the same actions as a post, at its own path under `replies/<reply id>`:

```bash
R="$CH/messages/$M/replies/1772409600002"
curl -s -o /dev/null -w '%{http_code}\n' -X PATCH "$R" -H "$H" -H "$J" -d '{"body":{"content":"Thanks, signing now."}}'
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' "$R/setReaction" -H "$H" -H "$J" -d '{"reactionType":"👍"}'
# -> 204
curl -s "$R" -H "$H" | jq -c '{content: .body.content, reactions: [.reactions[].reactionType]}'
# -> {"content":"Thanks, signing now.","reactions":["👍"]}
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$R/softDelete" -H "$H"
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' "$R" -H "$H"
# -> 404
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$R/undoSoftDelete" -H "$H"
# -> 204
```

### Edit a post

Editing a post the caller sent returns 204, and the next read shows the new body and a `lastEditedDateTime`:

```bash
curl -s -o /dev/null -w '%{http_code}\n' -X PATCH "$CH/messages/$M" -H "$H" -H "$J" -d '{"body":{"content":"Nightly build 812 is green and signed."}}'
# -> 204
curl -s "$CH/messages/$M" -H "$H" | jq -c '{content: .body.content, edited: (.lastEditedDateTime != null)}'
# -> {"content":"Nightly build 812 is green and signed.","edited":true}
```

### React to a post

`setReaction` adds the caller's reaction and `unsetReaction` removes it; each returns 204:

```bash
curl -s -o /dev/null -w '%{http_code}\n' "$CH/messages/$M/setReaction" -H "$H" -H "$J" -d '{"reactionType":"👍"}'
# -> 204
curl -s "$CH/messages/$M" -H "$H" | jq -c '[.reactions[] | {reactionType, user: .user.displayName}]'
# -> [{"reactionType":"👍","user":"Priya Nair"}]
curl -s -o /dev/null -w '%{http_code}\n' "$CH/messages/$M/unsetReaction" -H "$H" -H "$J" -d '{"reactionType":"👍"}'
# -> 204
curl -s "$CH/messages/$M" -H "$H" | jq -c '.reactions'
# -> []
```

### Soft delete a post and undo it

`softDelete` hides a post: reading it returns 404 until `undoSoftDelete` brings back a post the caller sent, with its body:

```bash
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$CH/messages/$M/softDelete" -H "$H"
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' "$CH/messages/$M" -H "$H"
# -> 404
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$CH/messages/$M/undoSoftDelete" -H "$H"
# -> 204
curl -s "$CH/messages/$M" -H "$H" | jq -c '{content: .body.content, deletedDateTime}'
# -> {"content":"Nightly build 812 is green and signed.","deletedDateTime":null}
```

A chat message behaves differently once deleted: reading it still returns 200, with `deletedDateTime` set (see [Chats](https://www.rystic.ai/docs/simulators/teams/features/chats.md)).

### Test another member's post

Editing another member's post, or undoing its soft delete, returns 403. Aiko Tanaka sent the seeded post `1771256429915`:

**Differs from Microsoft Graph:** Microsoft Graph returns 204 to both.

```bash
curl -s "$CH/messages/1771256429915" -H "$H" | jq -r '.from.user.displayName'
# -> Aiko Tanaka
curl -s -o /dev/null -w '%{http_code}\n' -X PATCH "$CH/messages/1771256429915" -H "$H" -H "$J" -d '{"body":{"content":"Mockups moved to Friday."}}'
# -> 403
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$CH/messages/1771256429915/softDelete" -H "$H"
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$CH/messages/1771256429915/undoSoftDelete" -H "$H"
# -> 403
```

---

Source: https://www.rystic.ai/docs/simulators/teams/features/channel-messages · Markdown: https://www.rystic.ai/docs/simulators/teams/features/channel-messages.md
