Skip to content

Files

An HTML artifact can carry files: images, JSON or CSV data, stylesheets, scripts, fonts, audio, video and PDFs, served next to the page. The page uses them by relative path, the way a small website would: <img src="img/logo.png">, <link rel="stylesheet" href="css/site.css">, fetch('data/desks.json').

Files belong to the artifact’s versions. Every change to them makes a new version, and restoring an older version from history brings back its files too.

Only HTML artifacts carry files. Markdown artifacts don’t.

Open an HTML artifact and choose Files in its More actions (⋯) menu. Everyone who can open the artifact can browse its files by folder. Editors and Owners can also upload files (drop them onto the list), make folders, and move and delete files.

Refer to a file by its path relative to the page, with no leading slash:

<link rel="stylesheet" href="css/site.css">
<img src="img/team/sam.jpg" alt="Sam">
<script src="js/board.js"></script>
<video src="media/demo.mp4" controls></video>
<script>
fetch('data/desks.json').then((r) => r.json()).then(showDesks);
</script>

Paths in CSS work the same way, relative to the stylesheet: url(../fonts/inter.woff2) from css/site.css.

A good layout keeps data in data/, images in img/, styles in css/, scripts in js/ and fonts in fonts/. ShareCube doesn’t require it, but agents and people find things faster.

Files are for what the page ships with. What people do on the page, like ticked boxes, votes or cards on a board, belongs in persistent state. A page can’t change its own files.

Ask for what you want, for example “add our logo and the photos from this folder” or “move the desk list into a JSON file”. These are the MCP tools agents use:

ToUse
Publish a page and its files togethercreate_artifact or update_artifact with files
Change the page’s HTML and some files in one stepedit_artifact with files
Add or replace one filewrite_artifact_file
Change part of a text fileedit_artifact_file
Rename or move a filemove_artifact_file
Remove a filedelete_artifact_file, or null for its path in files
Read a fileget_artifact_file (text comes back inline, anything else as a link)
Upload large files, many files, or binary from coderequest_artifact_upload with files, then commit_artifact_upload

files maps each path to where its content comes from:

{
"data/desks.json": { "content": "[{\"id\": 1, \"name\": \"Window\"}]" },
"img/logo.png": { "url": "https://example.com/logo.png" },
"img/chart.png": { "content_base64": "iVBORw0KGgo..." },
"css/site.css": { "from": { "artifact": "01a1b6a6-76ed-7000-9383-fa9b7ae8401b", "path": "css/site.css" } },
"old/notes.txt": null
}
SourceFor
contentText: HTML, CSS, JS, JSON, CSV, SVG, Markdown
urlA file on the web. ShareCube fetches it, up to 10 MB.
content_base64Small binary files the agent’s own code produced
fromA copy of a file from another artifact you can open
nullRemove the file

Paths left out of files are kept as they are.

  • Never type out base64 for an image. Give its url, or upload it from code with request_artifact_upload. Base64 written out by a model is slow, costly and easily corrupted.
  • Keep each call under 4 MB, base64 included, which makes a binary file about 3 MB. Send more over several calls, or use an upload session.
  • Use relative paths with no leading slash. /img/logo.png and full URLs to the file don’t work.
  • Publish the page and its files in one call where you can, so nobody opens a page whose images aren’t there yet.
  • Read before you write. Pass base_version_id from get_artifact when you update. If someone else saved in between, you get a conflict instead of undoing their change: read the artifact again and redo yours.

For big files, many files, or bytes your own code produced, use an upload session:

  1. Call request_artifact_upload with files, a list of { "path", "size", "sha256" } (size in bytes, sha256 in lowercase hex). Add page as { "size", "sha256" } to change the HTML too, and removes for paths to delete. Pass id and base_version_id to update an artifact, or project_id and display_name to create one. You get back a session_id and where to upload each file. Files the artifact already has aren’t asked for again.
  2. PUT each file’s raw bytes to its URL with exactly the headers given. A large file comes with parts: PUT each part_size slice to its part’s URL, in order.
  3. Within the hour, call commit_artifact_upload with the session_id. It answers committing; call it again until it says committed (with the new version) or failed (with the reason).

A file that hasn’t arrived is named in the error. Upload it and commit again. One session takes at most 500 new files.

  • Paths are relative, use / between folders, have at most 10 parts and 255 bytes in all, and are case-sensitive.
  • Each part uses only letters, digits and . _ - ~, and can’t be . or ... No spaces: img/team photo.jpg is refused, img/team-photo.jpg works.
  • doc, print and anything under _sc/ are reserved.

The extension decides the type, and the content has to match it: a .png has to really be a PNG. JPEG, PNG, WebP and GIF images are stored without their metadata (EXIF, GPS location, XMP and comments).

KindExtensions
Pages and codehtml, htm, css, js, mjs, json, txt, md, csv, xml, wasm
Imagespng, jpg, jpeg, gif, webp, avif, ico, svg
Fontswoff, woff2, ttf, otf
Audio and videomp3, m4a, wav, ogg, mp4, webm
Documents and 3Dpdf, glb, gltf

Anything else is refused.

FreeProTeam
One file10 MB500 MB500 MB
All of one version’s files25 MB2 GB2 GB
Files in one version1001,0001,000

The page itself stays at most 4 MB. Files count toward your organization’s storage, older versions’ files included, until those versions expire or the artifact is deleted.

Two saves of the same artifact can’t both win. If an agent or person saves while a file is being added, the second save is refused with a conflict rather than publishing a version without that file. Read the artifact again and save once more. Agents do this on their own.

  • A page can’t upload or change files while people use it. Use persistent state for what people add.
  • Files are served only to people who can open the artifact, and only alongside it.
  • See what runs in an HTML page for what the page’s sandbox allows.