Origami

Working with files

Upload, download, list, move and delete files without running a command.

The files API works on a workspace's files directly. Use it for what a command does badly: uploading and downloading, binary files, large files, and listing a directory page by page. The reference has every route and field.

All routes are below /v1/workspaces/{id}/files, and every path travels in the query parameter path.

Paths

A path is relative to the workspace's root: docs/a.md is what a command sees as /workspace/docs/a.md. The root is the empty path.

  • Encode the whole path as one query value: encodeURIComponent('docs/report #2.pdf').
  • A leading or trailing / is ignored. Empty segments, . and .. are refused with invalid_path, and so are names over 255 bytes and paths over 1,024 bytes.
  • Names are case-sensitive and never normalized.

Upload a file

The body is the file's bytes:

Bash
curl -s -X PUT "$ORIGAMI_URL/v1/workspaces/$WS/files/content?path=reports/2026.pdf&parents=true" \
  -H "authorization: Bearer $ORIGAMI_API_KEY" \
  --data-binary @2026.pdf
  • The answer is the file's entry: 201 for a new file, 200 for one that was replaced.
  • parents=true creates missing directories. Without it, a missing directory is parent_not_found.
  • An upload is atomic: other clients see the old file or the new one, never part of it.
  • mode=0600 sets the permissions of a new file. A replaced file keeps its own.
  • Up to 1 GiB. Above that the answer is too_large.

Only if it's new. Send If-None-Match: * and the upload fails with precondition_failed if anything is already at the path:

Bash
curl -s -X PUT "$ORIGAMI_URL/v1/workspaces/$WS/files/content?path=notes/today.md" \
  -H "authorization: Bearer $ORIGAMI_API_KEY" \
  -H 'if-none-match: *' \
  --data-binary @today.md

Download a file

Bash
curl -s "$ORIGAMI_URL/v1/workspaces/$WS/files/content?path=reports/2026.pdf" \
  -H "authorization: Bearer $ORIGAMI_API_KEY" -o 2026.pdf
  • One Range is honoured, answered with 206: -H 'range: bytes=0-1023'.
  • HEAD gives the headers alone: size, type and last change.
  • A download is the file as it was when the request began. If the file changes while a large one is being sent, the connection is cut rather than mixing old and new.
  • Files are always sent as attachments, with a type from their extension. Origami never serves a file as a page a browser would run.

List a directory

Bash
curl -s "$ORIGAMI_URL/v1/workspaces/$WS/files/children?path=reports" \
  -H "authorization: Bearer $ORIGAMI_API_KEY"
JSON
{
  "directory": { "path": "reports", "name": "reports", "kind": "directory", "...": "..." },
  "entries": [
    { "path": "reports/2026.pdf", "name": "2026.pdf", "kind": "file", "size": 48211, "...": "..." }
  ],
  "nextCursor": null
}

Listings come in pages of up to 1,000 entries (limit takes up to 5,000), sorted by name. Keep going until nextCursor is null: a short page doesn't mean the end.

TypeScript
async function* children(workspace: string, path: string, recursive = false) {
    let cursor: string | null = null;
    do {
        const query = new URLSearchParams({ path, recursive: String(recursive) });
        if (cursor !== null) query.set('cursor', cursor);
        const page = await call<{ entries: Entry[]; nextCursor: string | null }>(
            'GET',
            `/v1/workspaces/${workspace}/files/children?${query}`,
        );
        yield* page.entries;
        cursor = page.nextCursor;
    } while (cursor !== null);
}

recursive=true lists everything below, in path order. Symlinks are listed, never followed.

One entry

Bash
curl -s "$ORIGAMI_URL/v1/workspaces/$WS/files?path=reports/2026.pdf" \
  -H "authorization: Bearer $ORIGAMI_API_KEY"

An entry has the same shape for a file, a directory or a symlink. Its id stays the same through renames, moves and uploads, so you can tell a moved file from a new one.

Make a directory

Bash
curl -s -X PUT "$ORIGAMI_URL/v1/workspaces/$WS/files?path=archive/2025&parents=true" \
  -H "authorization: Bearer $ORIGAMI_API_KEY" \
  -H 'content-type: application/json' \
  -d '{"kind":"directory"}'

201 when it's made, 200 when it was already there, so it's safe to repeat.

Move or rename

Bash
curl -s -X POST "$ORIGAMI_URL/v1/workspaces/$WS/files/move" \
  -H "authorization: Bearer $ORIGAMI_API_KEY" \
  -H 'content-type: application/json' \
  -d '{"from":"reports/2026.pdf","to":"archive/2025/report.pdf"}'
  • to is the new path itself. Moving a to an existing directory b doesn't put it into b: it fails with already_exists.
  • Nothing is overwritten unless you send "overwrite": true.
  • A directory moves in one step, however much it holds.

Delete

Bash
curl -s -X DELETE "$ORIGAMI_URL/v1/workspaces/$WS/files?path=archive&recursive=true" \
  -H "authorization: Bearer $ORIGAMI_API_KEY"

A directory that isn't empty needs recursive=true. A recursive delete goes all at once: other clients see the whole tree or none of it. Very large trees, of tens of thousands of entries, are removed in several steps. A symlink is removed, not what it points to.

Files and commands together

The files API and commands see the same files at all times. A file you upload is there for the next command, and a file a command writes can be downloaded as soon as the command has answered. A good pattern for agents is to upload inputs, run commands, and download results.