# Chats

Group and one-on-one chats outside any team: members, messages, pins, each member's hidden and read state, and a delete that restores.

A chat is a conversation outside any team, with its own members and messages. Load the `teams_launch_hub` scenario, start a group chat and list its members:

```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
U="https://graph.microsoft.com/v1.0/users"
MEMBER='{"@odata.type":"#microsoft.graph.aadUserConversationMember","roles":["owner"],"user@odata.bind":"'$U
curl -s "$RYSTIC_URL/v1.0/chats" -H "$H" -H "$J" -d '{"chatType":"group","topic":"Docs review","members":['"$MEMBER""('a6570d76-bf60-4230-bc55-0f26dfbe39eb')\"},$MEMBER('a82cbb3c-d24e-4dcc-a753-2ccdf8135a5d')\"}]}" | jq -c '{id, chatType, topic}'
# -> {"id":"19:00000000000000000000000000000001@thread.v2","chatType":"group","topic":"Docs review"}
CHAT="$RYSTIC_URL/v1.0/chats/19:00000000000000000000000000000001@thread.v2"
curl -s "$CHAT/members" -H "$H" | jq -c '[.value[].displayName]'
# -> ["Priya Nair","Hannah Weiss"]
```

Every request runs as Priya Nair, the scenario's signed-in member.

### Add and remove a member

Adding a member returns 201 and removing one returns 204, and the member list follows each change:

```bash
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/members" -H "$H" -H "$J" -d "$MEMBER('ccd2836b-cda8-4183-ae08-f03b3611851e')\"}"
# -> 201
curl -s "$CHAT/members" -H "$H" | jq -c '[.value[].displayName]'
# -> ["Priya Nair","Hannah Weiss","Aiko Tanaka"]
AIKO=$(curl -s "$CHAT/members" -H "$H" | jq -r '.value[] | select(.displayName == "Aiko Tanaka") | .id')
curl -s -o /dev/null -w '%{http_code}\n' -X DELETE "$CHAT/members/$AIKO" -H "$H"
# -> 204
curl -s "$CHAT/members" -H "$H" | jq -c '[.value[].displayName]'
# -> ["Priya Nair","Hannah Weiss"]
```

### Send, edit, react to and soft delete a chat message

Chat messages take the same actions as channel posts ([Channel messages and replies](https://www.rystic.ai/docs/simulators/teams/features/channel-messages.md)). Once soft deleted, though, reading a chat message still returns 200, with `deletedDateTime` set:

```bash
curl -s "$CHAT/messages" -H "$H" -H "$J" -d '{"body":{"content":"Docs freeze at noon."}}' | jq -c '{id, chatId}'
# -> {"id":"...","chatId":"19:00000000000000000000000000000001@thread.v2"}
M=$(curl -s "$CHAT/messages" -H "$H" | jq -r '.value[0].id')
curl -s -o /dev/null -w '%{http_code}\n' -X PATCH "$CHAT/messages/$M" -H "$H" -H "$J" -d '{"body":{"content":"Docs freeze at noon sharp."}}'
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/messages/$M/setReaction" -H "$H" -H "$J" -d '{"reactionType":"❤️"}'
# -> 204
curl -s "$CHAT/messages/$M" -H "$H" | jq -c '{content: .body.content, reactions: [.reactions[].reactionType]}'
# -> {"content":"Docs freeze at noon sharp.","reactions":["❤️"]}
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$CHAT/messages/$M/softDelete" -H "$H"
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/messages/$M" -H "$H"
# -> 200
curl -s "$CHAT/messages/$M" -H "$H" | jq -c '{deleted: (.deletedDateTime != null)}'
# -> {"deleted":true}
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$CHAT/messages/$M/undoSoftDelete" -H "$H"
# -> 204
curl -s "$CHAT/messages/$M" -H "$H" | jq -c '{deletedDateTime, content: .body.content}'
# -> {"deletedDateTime":null,"content":"Docs freeze at noon sharp."}
```

### Quote a message in a reply

To quote earlier messages in a new one, send their ids as `messageIds` and the new message as `replyMessage` to `messages/replyWithQuote`:

```bash
curl -s "$CHAT/messages/replyWithQuote" -H "$H" -H "$J" -d '{"messageIds":["'"$M"'"],"replyMessage":{"body":{"content":"Noted."}}}' | jq -c '{quoted: (.attachments[0].content | fromjson | .messageId == "'"$M"'")}'
# -> {"quoted":true}
```

### Pin a message

A pin names a message of the same chat through `message@odata.bind`, and the pinned message's id is the pin's id:

**Differs from Microsoft Graph:** the simulator refuses to send some chat messages Microsoft Graph accepts, so pinning those messages and listing them as pinned differ ([Limitations](https://www.rystic.ai/docs/simulators/teams.md#limitations)).

```bash
curl -s "$CHAT/pinnedMessages" -H "$H" -H "$J" -d '{"message@odata.bind":"https://graph.microsoft.com/v1.0/chats/19:00000000000000000000000000000001@thread.v2/messages/'"$M"'"}' | jq -c '.id == "'"$M"'"'
# -> true
curl -s "$CHAT/pinnedMessages" -H "$H" | jq -c '."@odata.count"'
# -> 1
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT"'/pinnedMessages?$top=1' -H "$H"
# -> 400
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT"'/members?$top=1' -H "$H"
# -> 400
curl -s -o /dev/null -w '%{http_code}\n' -X DELETE "$CHAT/pinnedMessages/$M" -H "$H"
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/pinnedMessages" -H "$H"
# -> 404
curl -s "$CHAT/pinnedMessages" -H "$H" | jq -c '.error.innerError.message'
# -> "Thread property pinnedItems was not found."
```

The pin list and the chat's member list return 400 for `$top`. With no pin left, the pin list returns 404, as Microsoft Graph does.

### Hide a chat and mark it unread

The chat's `viewpoint` shows the caller's own hidden and read state:

```bash
ME='{"user":{"id":"a6570d76-bf60-4230-bc55-0f26dfbe39eb","tenantId":"4c7e9a12-5b3d-4f86-9e21-7a0d3c8b6f54"}'
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/hideForUser" -H "$H" -H "$J" -d "$ME}"
# -> 204
curl -s "$CHAT" -H "$H" | jq -c '.viewpoint.isHidden'
# -> true
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/unhideForUser" -H "$H" -H "$J" -d "$ME}"
# -> 204
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/markChatUnreadForUser" -H "$H" -H "$J" -d "$ME"',"lastMessageReadDateTime":"2026-02-01T00:00:00Z"}'
# -> 204
curl -s "$CHAT" -H "$H" | jq -c '.viewpoint'
# -> {"isHidden":false,"lastMessageReadDateTime":"2026-02-01T00:00:00Z"}
curl -s -o /dev/null -w '%{http_code}\n' "$CHAT/markChatReadForUser" -H "$H" -H "$J" -d "$ME}"
# -> 204
curl -s "$CHAT" -H "$H" | jq -c '.viewpoint.lastMessageReadDateTime'
# -> "2026-03-02T00:00:00Z"
```

`markChatReadForUser` sets `lastMessageReadDateTime` to the simulator's clock, which the scenario starts at 2026-03-02T00:00:00Z.

### Delete a chat and restore it

A deleted chat moves to `teamwork/deletedChats`, and `undoDelete` brings it back. In between, reading the chat returns a stub whose `chatType` is `unknownFutureValue`:

```bash
curl -s -o /dev/null -w '%{http_code}\n' -X DELETE "$CHAT" -H "$H"
# -> 204
curl -s "$CHAT" -H "$H" | jq -c '{chatType, createdDateTime}'
# -> {"chatType":"unknownFutureValue","createdDateTime":"0001-01-01T00:00:00Z"}
DEL="$RYSTIC_URL/v1.0/teamwork/deletedChats/19:00000000000000000000000000000001@thread.v2"
curl -s "$DEL" -H "$H" | jq -c '.id'
# -> "19:00000000000000000000000000000001@thread.v2"
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$DEL/undoDelete" -H "$H"
# -> 204
curl -s "$CHAT" -H "$H" | jq -c '{chatType, topic}'
# -> {"chatType":"group","topic":"Docs review"}
```

---

Source: https://www.rystic.ai/docs/simulators/teams/features/chats · Markdown: https://www.rystic.ai/docs/simulators/teams/features/chats.md
