Skip to content

Cloud saves

Each player gets 16 save slots per game, each holding up to 256 KB of text. What you put in them is up to you; JSON is the usual choice.

// Save
await spawnle.saves.save("slot1", JSON.stringify(state));
// Load (null when the slot is empty)
const saved = await spawnle.saves.load("slot1");
const state = saved ? JSON.parse(saved) : freshState();
// What is there
const slots = await spawnle.saves.list();
// [{ slot: "slot1", size: 1834, updatedAt: Date }]
// Delete
await spawnle.saves.delete("slot1");

1 to 32 characters: letters, digits, - and _. Good names describe the slot’s role: autosave, slot1, settings, ghost-run.

Saves are text. Encode binary data (a screenshot, a packed world) as Base64 first — and remember the 256 KB limit applies to the encoded text.

const base64 = btoa(String.fromCharCode(...new Uint8Array(buffer)));
await spawnle.saves.save("world", base64);

A save is one request. Save at checkpoints, on level end, or every few minutes — not every frame. The API allows 60 saves per minute per player and game; beyond that it answers rate_limited.

The last write wins. If your game can run on two computers at once, store a counter or timestamp inside your data and keep the newest.

Request Route
List GET /v1/sdk/saves
Load GET /v1/sdk/saves/{slot}
Save PUT /v1/sdk/saves/{slot} with { "data": "…" }
Delete DELETE /v1/sdk/saves/{slot}