<!-- https://headless-lms.dev/docs/api/chats -->

# Chats

Direct and group chats inside one community

- [List your chats in a community](https://headless-lms.dev/docs/api/chats/listMemberChats): For a member of the community. Every chat you are in, with your unread count and its last message.
- [Start a direct chat, or return the one that already exists](https://headless-lms.dev/docs/api/chats/startDirectChat): For a member of the community, within its direct-message settings (403 otherwise). With the community set so a first message is a request, a new chat starts `pending` until the other person accepts it. 409 when you message yourself, send attachments without a body, or start a request without a message.
- [Start a group chat](https://headless-lms.dev/docs/api/chats/startGroupChat): For a member of the community while group chats are on (403 otherwise). Everyone named must hold the community and be someone you may message. 409 when fewer than two others are named or the group would exceed the community's group size.
- [Add a person to a group chat you are in](https://headless-lms.dev/docs/api/chats/addChatParticipant): For a participant of a group chat. 409 when the chat is direct, the person is already in it, or it is full.
- [Leave a chat](https://headless-lms.dev/docs/api/chats/leaveChat): For a participant. The chat stays for the others.
- [Accept a message request](https://headless-lms.dev/docs/api/chats/acceptChat): For the person the request was sent to. The chat opens for both sides. 409 when the chat is not a pending request.
- [Read the messages in a chat, newest first](https://headless-lms.dev/docs/api/chats/listChatMessages): For a participant of the chat.
- [Send a message](https://headless-lms.dev/docs/api/chats/sendChatMessage): For a participant while the chat is open and not locked, and nobody in it has blocked the other (403 otherwise). A request's sender cannot send more until it is accepted.
- [Edit your own message](https://headless-lms.dev/docs/api/chats/editChatMessage): Sender only, while the chat is open and not locked. 409 when the message is deleted.
- [Delete your message, or one in a community you moderate](https://headless-lms.dev/docs/api/chats/deleteChatMessage): For the sender, or a moderator of the community. The message stays in the history, marked deleted. 409 when it is already deleted.
- [Withdraw your reaction from a message](https://headless-lms.dev/docs/api/chats/clearMessageReaction): For a participant of the chat. Returns the new counts.
- [Set your reaction on a message](https://headless-lms.dev/docs/api/chats/setMessageReaction): For a participant of the chat. Replaces any reaction you already had and returns the new counts.
- [Flag a message for the moderators](https://headless-lms.dev/docs/api/chats/flagMessage): For a participant of the chat. Flagging it again while your flag is open returns that flag.
- [Dismiss the open flags on a message in a community you moderate](https://headless-lms.dev/docs/api/chats/resolveMessageFlags): For a moderator who is a member of the community. Closes every open flag and leaves the message up.
- [Mark a chat read up to a message](https://headless-lms.dev/docs/api/chats/markChatRead): For a participant. The message must be in the chat (404 otherwise).
- [Mute a chat until a time, or until unmuted](https://headless-lms.dev/docs/api/chats/muteChat): For a participant. Without `until` the chat stays muted until you unmute it.
- [Unmute a chat](https://headless-lms.dev/docs/api/chats/unmuteChat): For a participant.
- [Lock a chat in a community you moderate](https://headless-lms.dev/docs/api/chats/lockChat): For a moderator who is a member of the community. Nobody can send or edit messages until it is unlocked; its open message flags are resolved as `locked`. Locking a locked chat returns it unchanged.
- [Unlock a chat in a community you moderate](https://headless-lms.dev/docs/api/chats/unlockChat): For a moderator who is a member of the community. Unlocking an unlocked chat returns it unchanged.
- [Unblock a person in a community](https://headless-lms.dev/docs/api/chats/unblockMember): For a member of the community. A direct chat closed by the block reopens unless a moderator locked it. 409 when you unblock yourself.
- [Block a person in a community](https://headless-lms.dev/docs/api/chats/blockMember): For a member of the community. Neither of you can message the other there; a direct chat between you closes. Blocking twice is harmless. 409 when you block yourself.
