Key-value storage & collections
Structured per-player, shared, and team collections with OCC and atomic mutations.
Beyond save slots, storage collections hold structured key→value entries with a scope and read/write policy the developer configures (dashboard → Storage). Three scopes: player (private), shared (game-wide), and team (members only).
await tg.storage.put('decks', 'main', { cards: [] });
const { data } = await tg.storage.get('decks', 'main');
const keys = await tg.storage.list('decks'); Concurrency & atomic mutations
Writes support optimistic concurrency (If-Match → storage_conflict on a stale version). For counters and lists, avoid read-modify-write races with server-side atomic ops (incr, append) instead.
await tg.storage.incr('stats', 'wins', 1);
await tg.storage.append('decks', 'main', 'cards', 'card_9');