Editing projects
With a logged-in session you can round-trip a project: download it, edit it
in memory (best with scratch4js), then save it back — and
optionally publish it. You must own the project you write to.
Download
projects.download(id) fetches the project.json plus every costume and sound
it references. It returns { json, assets }, where assets is a Map of
md5ext → Uint8Array — exactly the shape a scratch4js Project is built from:
Shared projects download without a login; your own unshared projects need
one (the session's X-Token resolves the project token for you). Lower-level
pieces are available if you need them:
Edit
Do the editing with scratch4js — sprites, scripts, costumes, sounds, variables
and lists are all plain getters and setters:
See the scratch4js guide for the full editing surface.
Save
projects.save(id, project) uploads every asset, then writes the new
project.json — i.e. it saves the edited .sb3 back to the website:
save() accepts a scratch4js Project or any { json, assets }, where
assets is a Map/object of md5ext → Uint8Array (or an array of
[md5ext, bytes] pairs). The asset store is content-addressed by MD5, so
re-uploading unchanged assets is a harmless no-op.
If you changed only scripts and not costumes/sounds, skip the asset uploads:
Or upload a single asset yourself:
Metadata
Title, instructions and the "Notes and Credits" description are separate from the
.sb3 and edit through api.scratch.mit.edu:
Publish
projects.share(id) publishes a project so it becomes publicly visible
(PUT /proxy/projects/<id>/share); unshare(id) reverses it:
Sharing makes a project public. If you're building a tool or agent on top of
s-api4js, confirm with the user before sharing — the
scratch-mcp server does exactly this.