# Guide: A room per game / match / order Spin up a dedicated chat room for each unit of activity in your app (a game match, a marketplace order, a support ticket) and drop your users straight into it. This combines the [Cherry API](https://portal.cherry.fun/docs/api/rooms.md) (server) with the [embed SDK](https://portal.cherry.fun/docs/embed/display-modes.md) (client). ## 1. Create the room from your backend When the activity starts (a match is made, an order is placed), call the Cherry API. Add the participants as `initialMembers` so they're active immediately. ```ts // your server - CHERRY_API_KEY is your project key: the one opaque // `cherry_sk__` token copied from the portal. const res = await fetch('https://api.cherry.fun/api/v1/apps/groups', { method: 'POST', headers: { Authorization: `Bearer ${process.env.CHERRY_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ ownerWallet: hostWallet, title: `Match #${matchId}`, initialMembers: [playerA, playerB], }), }); const { roomId } = await res.json(); // persist roomId alongside your match/order record ``` ## 2. Greet them with the bot (optional) See the [Messages API](https://portal.cherry.fun/docs/api/messages.md) for the full send-message endpoint. ```ts await fetch(`https://api.cherry.fun/api/v1/apps/groups/${roomId}/messages`, { method: 'POST', headers: { Authorization: `Bearer ${process.env.CHERRY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ content: 'Match starting - good luck! 🎮' }), }); ``` ## 3. Open the room in the embed Pass the `roomId` to a `single`-mode embed, or, if the user moves between activities, mount once in `external-controlled` mode and call `setRoom()`: ```ts // single room new CherryEmbed({ appId: 'YOUR_EMBED_ID', container: '#chat', roomId, mode: 'single' }); // or, switch rooms as the user navigates chat.setRoom(roomId); ``` ## 4. Clean up When the activity ends, delete the room (it must be app-created): ```ts await fetch(`https://api.cherry.fun/api/v1/apps/groups/${roomId}`, { method: 'DELETE', headers: { Authorization: `Bearer ${process.env.CHERRY_API_KEY}` }, }); ``` ## Where next - [Cherry API › Create rooms & attach to embeds](https://portal.cherry.fun/docs/api/rooms.md) for the full endpoint detail. - [Moderation bot](https://portal.cherry.fun/docs/guides/moderation-bot.md) to keep rooms healthy.