# Version 1 REST and MCP

Base path `/v1/media-library`. Error bodies contain `error.code` and `error.message`. Public routes work without an account when the content is published and entitled. Creator software uses `Authorization: Bearer <catalog key>`. In Creator studio, issue a read key for private discovery or a write key for mutations, and select both scopes for the entire creator workflow. Keys expire after 30 days. Browser sign-in uses a same-origin session cookie.

## Discover and download

| Method and path relative to the base | Operation |
| --- | --- |
| `GET /` | Version and enforced upload, storage and job limits |
| `GET /assets?q=...&kind=video&license=CC0-1.0&tag=...&creator=...` | Browse and search with optional filters. Use `mode=text` for lexical-only search. Supply `limit=1..50` and the returned `next` as `after` with the same filters. |
| `GET /assets?q=...&scope=moments` | Return timecoded observations, including multiple matching moments within an asset. `scope=media` returns asset metadata matches. The default combines results by asset. Exact phrases rank above weaker lexical matches. |
| `GET /assets?movies=...&characters=...` | Filter on any of `movies`, `tvShows`, `characters`, `channels`, `accounts`, `directors`, and `creators`. Each supplied field matches one name regardless of case and can be combined with the other filters. `creator` filters by uploader account ID. `creators` filters by credited names. |
| `GET /facets?field=movies&prefix=...` | List names and matching asset counts from current public publications. Accepts `creator`, `limit=1..50`, and the previous page’s `next` as `after`. |
| `GET /assets/{asset}` | Public card, rights, exact revision and available file links. `?draft=1` requires owner access. |
| `GET /assets/{asset}/clock` | Frame timestamp array in microseconds, source and audio start, frame count and time base. Requires media access. |
| `GET /assets/{asset}/observations?attachment=...&kind=object` | Selected timed data and digital observations. Filter by attachment, kind, or text (`q`). Page with `after` from `next`. Owner-only drafts include private data. |
| `GET /assets/{asset}/receipt` | Stable attribution and source identity. Keep it with the media. The receipt also contains the caller’s specific-use grant when applicable. |
| `GET /assets/{asset}/revisions` | Owner-only immutable history with exact original links. |
| `GET /creators/{id}` | Creator profile. Add its ID to the catalog filter to browse the collection. |
| `GET /drafts?limit=24` | Page through the authenticated owner’s editable assets, including private drafts. Optional `q` matches filename or draft text, including private notes and credit fields, with ASCII case folding. Repeat the same query while paging. MCP `catalog_drafts` takes the same fields. Pass `next` as `after` for the next page. |
| `GET /me`, `PATCH /me` | Read or update the authenticated creator’s profile. Updates accept `name` and `bio` with the write scope. |
| `GET /marks`, `PUT /marks` | List or set an account’s saves and follows. Body `{"kind":"save","target":"<asset id>","enabled":true}`. Kinds are `save`, `asset`, `creator`. |
| `GET /collections`, `POST /collections` | List your collections with read scope or create one with write scope. POST accepts `title`, `kind` (`folder` or `playlist`), optional `parentId`, and optional `visibility` (`private` by default, or `public`). |
| `GET /collections/{id}`, `PATCH /collections/{id}` | Read a public collection or your own private collection. As owner, change any of `title`, `parentId`, or `visibility`. A null parent is the library root. |
| `PUT /collections/{id}/items/{asset}`, `DELETE /collections/{id}/items/{asset}`, `PATCH /collections/{id}/items/{asset}` | As collection owner, add or remove a public asset or move a playlist entry with `{"direction":"up"}` or `{"direction":"down"}`. |

Collection links point to the current public asset, up to 200 entries per collection and 100 collections per account. Withdrawing an asset removes it from collection views while it is private. An anonymous view of a public folder shows only its public children.

A returned file link authorizes one currently selected publication or the owner’s draft and uses HTTP GET, HEAD, and single byte ranges. Resolve links relative to the catalog origin. A stale URL returns 404. Fetch the asset, revision list, or job status for a fresh link. Unpublished sources and withdrawn attachments are denied on new requests. Stored bytes and previous verified copies can retain independent rights. An active-transfer ceiling returns `429 delivery_concurrency_limit` and a `Retry-After` header. Resume interrupted downloads with the last verified byte range.

## Browser or API publishing

1. POST `/uploads` with an `Idempotency-Key` of 8–100 letters, digits or `._-` and JSON `{"name":"source.mp4","bytes":1048576,"sha256":"<64 lowercase hex>" }`. Optionally include `kind` and `assetId` to create a new revision of an existing asset. The same key and exact intent reconcile one upload. `POST /uploads/batch` takes up to 20 `{"key":"...","upload":{...}}` entries and returns one outcome per item.
2. Send `PATCH /uploads/{id}` with `Content-Type: application/offset+octet-stream`, `Upload-Offset: 0`, and `X-Chunk-Sha256: <hex>`. Send up to 4 MiB binary per part. On transport interruption, reconnect with `HEAD` or `GET`, read `Upload-Offset`, and continue at that byte. A stale write returns 409 and the authoritative offset. Browser recovery works by reselecting the same file under the same account. `DELETE /uploads/{id}` cancels an active upload.
3. POST `/uploads/{id}/complete`. Poll `GET /uploads/{id}` for `queued`, `ready`, or `failed`. This validates actual byte count, SHA-256, decoded media, and the source clock. `ready` provides the source revision ID. A browser session may close while the worker completes.
4. GET `/assets/{asset}?draft=1` to obtain the edit number. PATCH the asset with that `edit`, `title`, `credit`, `license`, and optional `description`, `summary`, `use`, `tags`, `source`, `licenseTerms`, `notes`, and `discovery`. Private notes are owner-only. The full media summary is searchable once published. `discovery` accepts optional lists of free-form names, such as `{"movies":["Copper Bay"],"characters":["Harbor Pilot"],"directors":["Léa Martin"]}`. Each field accepts up to 12 names of up to 120 characters. Omit `discovery` to keep saved names during an edit or send `{}` to clear them. These fields appear in search, browse, receipts, and bundle manifests after publication. For a reference, POST the same fields without `edit` to `/references`, with `license: "reference-only"` and a source URL. The server stores the reference as a link.
5. POST raw attachment bytes to `/assets/{asset}/attachments` with `Content-Type: application/octet-stream`, `X-Content-Sha256`, and `X-Attachment-Metadata` set to base64url UTF-8 JSON. Metadata requires `name`, `title`, `type`, `license`, `credit`, `revisionId`, and `sourceSha256`. Optional `source` is a URL. `restricted` defaults to true. Attachment types are `notes`, `observations`, `myrograph`, `mask`, `cutout`, `sfx`, `document` and `biometric`. Use `document` for arbitrary file formats within the 8 MiB limit.
6. POST `/assets/{asset}/publish` with `{"edit":3,"showMedia":true,"attachments":["<attachment id>"],"confirmRights":true}`. A new publication updates what is shared. Metadata and selected open attachments can go live with `showMedia:false`. Use the same endpoint with DELETE for the whole asset or DELETE `/assets/{asset}/attachments/{attachment}` for one file. Reports use POST `/assets/{asset}/reports` with `{"reason":"...","contact":""}`.

Media licenses are `CC0-1.0`, `CC-BY-4.0`, `rights-held`, `specific-use`, and `reference-only`. A creator can grant `specific-use` or `rights-held` media for the current publication via POST `/assets/{asset}/grants` with `{"accountId":"...","terms":"One Festival screening"}`. Use `null` terms to revoke. Every published attachment carries its own open license, source binding and credits.

## Source clock and jobs

Video/GIF source zero is the first presented picture. Audio-only source zero is its first decoded audio sample. `frame` is a zero-based decoded presentation ordinal. Values ending in `Micros` use integer source-local microseconds. Frame and timestamp intervals have exclusive ends. The timestamp still uses the frame displayed at that time. Timestamp clip start selects the first frame whose start meets or follows the requested start. Clip end excludes the first frame starting at or after the requested end. The acknowledgement reports the effective interval. EOF is a valid exclusive end. Audio excerpts use the audio samples covered by the requested source interval and WAV output.

POST these bodies to `/assets/{asset}/renditions`:

```json
{"kind":"clip","startFrame":13,"endFrameExclusive":27}
```

```json
{"kind":"clip","startMicros":512345,"endMicros":1100429}
```

```json
{"kind":"still","frame":39}
```

```json
{"kind":"still","timestampMicros":1626244}
```

```json
{"kind":"audio","startMicros":512345,"endMicros":900017}
```

POST `/assets/{asset}/bundles` with `{"attachments":["<id>"]}`. An omitted selection bundles all available files. A ZIP contains `manifest.json` with schema `vibeedit.mediaBundle.v1`, rights, stable source/revision IDs, clock and a checksum/size entry per archived file. Preserve that manifest when moving and importing the files. Private export uses the same endpoint with `?draft=1` as the owner.

Poll `GET /assets/{asset}/jobs/{job}` no faster than once a second in normal use. Completed jobs return `delivery.url`, `delivery.sha256`, byte count and a derivative receipt link with source credit and the resolved range. Re-submit the same input to reuse it or recover an evicted artifact. Failed jobs may be retried through POST `/assets/{asset}/jobs/{job}/retry` up to the attempt limit. For binary integrity, compare SHA-256 after the complete transfer, including when continuing via Range.

## Attach observations

Use attachment type `observations` and the native portable JSON contract:

```json
{
  "schema": "vibeedit.observations.v1",
  "sourceSha256": "<original SHA-256>",
  "records": [
    {"id":"shot-12","kind":"shot","text":"Warm blocks cross the center","startMicros":500000,"endMicros":1350000,"frame":12,"origin":"human","status":"confirmed","restricted":false},
    {"id":"word-240","kind":"word","text":"shoreline","startMicros":550000,"endMicros":810000,"speaker":"Narrator","origin":"model","status":"suggested","confidence":0.77,"restricted":false}
  ]
}
```

Supported kinds are `note`, `scene`, `shot`, `summary`, `transcript`, `word`, `speaker`, `character`, `faceAppearance`, `identity`, `object`, `beat`, `chapter`, `impact`, `event`, `sfx`, and `artifact`. Optional fields include `startMicros`, `endMicros`, `frame`, `speaker`, `label`, `trackId`, `confidence` and `evidence`. A `box` has `x`, `y`, `width` and `height` as fractions of the source picture with the origin at the upper left. Bind the box to a frame or timestamp for moving media. Evidence-bearing, identity and face-appearance files require private visibility. Publish a separately cleared observations file to expose a shareable description. The original upload remains immutable.

Type `myrograph` accepts a bound `myrograph.stageExport.v2` JSON or `myrograph.completeAnalysis.v3` ZIP within the attachment limit. Original bytes stay private. The adapter normalizes supported stage fields against the source SHA and audio/video clock. It retains job references and model status. ZIP ingest checks unpacked size and listed stage checksums and stores the whole original as a private attachment. Use the existing Myrograph workflow to run new analysis and download an export.

## MCP

Use the stateless Streamable HTTP endpoint at `http://127.0.0.1:4088/v1/media-library/mcp` with a compatible client. Anonymous clients may search, read and prepare published items. Pass the same catalog bearer header for owner reads or writes.

```json
{
  "mcpServers": {
    "vibeedit-open-media": {
      "type": "http",
      "url": "http://127.0.0.1:4088/v1/media-library/mcp"
    }
  }
}
```

The tools include `catalog_search`, `asset_get`, `asset_observations`, `creator_get`, `rendition_request`, `bundle_request`, `job_get`, `job_retry`, `upload_begin`, `upload_state`, `asset_edit`, `asset_publish`, `asset_withdraw` and `catalog_mark`. Discover tool schemas with `tools/list`. Resume original upload bytes through REST PATCH. Transfer originals, renditions and data directly over HTTP using the returned links. Save receipts or bundle manifests alongside downloaded files.

The SDK tool list also includes `asset_receipt`, `asset_clock`, `asset_revisions`, `asset_reference`, `upload_batch`, `upload_part`, `attachment_add`, `asset_grant`, `asset_report`, `catalog_marks`, `catalog_drafts`, `profile_get` and `profile_edit`. Pass an `items` array to `upload_batch` with the same per-item fields and results as the REST route. `catalog_drafts` returns up to `limit` editable assets and accepts the previous page’s `next` as `after`. Send binary MCP tool inputs as base64 with a practical 2 MiB limit. Direct REST supports larger chunks and attachments.

Use `catalog_facets` to list names in any discovery field. Use the same field in `catalog_search` to filter for a name. `asset_edit` and `asset_reference` accept the same optional `discovery` object as REST.

Use `scope: "moments"` with `q` in `catalog_search` to return matching timecoded observations. Use `scope: "media"` for asset metadata matches.

Use `library_collections`, `collection_get`, `collection_create`, `collection_edit` and `collection_item` for playlists and folders. Add the `kind` argument to `asset_observations` to retrieve a type independently.

To download a verified original and attribution sidecar for offline import:

```sh
bun run handoff 'http://127.0.0.1:4088/asset/ASSET_UUID' /path/to/new-directory
```

Provide an entitled catalog key in `VIBE_MEDIA_CATALOG_KEY` for restricted originals. Import the materialized source into VibeEdit Library and retain its sidecar alongside the file.

Add `--native-library` after the destination to create two request files for VibeEdit Library’s existing local agent connection. Send `native-library-import.json` to `companion.import`, then wait for the returned `operationId` with `companion.import.wait`. Once the exact source is present, send `native-library-attribution.json` to `companion.attachments.importFile` and observe its operation. The connection needs write access and a filesystem grant for the handoff folder. Preserve these request files for retries. If you move the folder before import, update the absolute paths. The original bytes and receipt remain available for offline use.

## Inspect a publication and select a download

POST `/assets/{asset}/inspect` with `{}` or `{"range":{"kind":"still","timestampMicros":500001}}`. MCP uses `asset_inspect` with the same optional range and an assetId. This resolves the effective source range without enqueuing a transform. The response includes the source identity and clock summary, allowed renditions, original and preview URLs when available, and per-file SHA-256, size, license, credits, observation counts and confirmation status totals. Private owner inspection uses `?draft=1` or MCP `draft:true`.

Pass the returned `snapshot` as a REST query parameter on inspect, observations, renditions and bundles or as the same MCP argument. A 409 `snapshot_changed` requires fresh inspection. The snapshot pins the source and file selection and conveys no access rights. A removed publication returns 404. Stable source citations use asset ID, revision ID, SHA-256 and time range.

Filter observations using `startMicros` and `endMicros` for source overlap with an exclusive end, `limit` from 1 to 100 and `after` from the previous page. Timeless records are omitted when filtering by time. Pair `attachment` and `observationId` to retrieve one record. The same parameters work in `asset_observations`.

## Community review

Use GET `/assets/{asset}/reviews` or MCP `asset_reviews` with optional `after`. Pages hold up to 50 comments for the current publication. Only approved comments are visible to anonymous readers. The publisher and author can see pending and dismissed comments with read access.

POST `/assets/{asset}/reviews` with write scope, or send this body as the `review` field of `review_propose` alongside assetId.

```json
{"publicationId":"<uuid>","attachmentId":"<sha256 id>","observationId":"shot-12","comment":"The next shot begins at frame 32.","key":"unique-retry-key","allowPublication":true}
```

A review must refer to a currently published observation. The key reconciles identical retries per author. Each account may submit 50 reviews per rolling day. The channel is browser or API, independent of authorship. Review text stays separate from data exports and search. Publishers PATCH `/assets/{asset}/reviews/{reviewId}` with `{"state":"approved"}` or `{"state":"dismissed"}`. The author can permanently withdraw their comment with `{"state":"withdrawn"}`. MCP uses `review_decide` with assetId, reviewId and state. Removing a file or replacing its publication removes its comments from the live view.

### See the image directly in MCP

Call `asset_image` with `{"assetId":"<id>"}` to look at the poster or audio waveform. For a source frame, request a still through `rendition_request`, wait for `job_get` to report ready, then supply the same assetId and the still's jobId to `asset_image`. The first content block gives the revision, range when applicable, byte count and SHA-256. The next is a PNG image block. This rechecks delivery rights and uses the same byte quota as HTTP. Set `draft:true` for an authorized draft. Use the HTTP delivery URL for images above 4 MiB. A poster is a browsing aid and does not identify an exact requested frame.
