> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vidjutsu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload media

> Add takes, music and stills to your library: from a link, or straight to storage in parts.

Everything a timeline uses lives in your media library. There are three ways to add a file:

| Way | For | Call |
| - | - | - |
| **Direct upload** | Files on your machine, up to 50 GB | `POST /uploads`, then `PUT` the parts, then `POST /uploads/{upload_id}/complete` |
| **Link** | Files already online | `POST /media` with `{"url": "https://...", "name": "take1.mov"}` |
| **Inline bytes** | Small files (stills, short clips), up to 4 MB | `POST /media?name=logo.png` with the bytes as `application/octet-stream` |

The CLI's `vidjutsu upload <file>` and the SDK's `upload()` do a direct upload for you. `vidjutsu ingest <https-url>` adds from a link.

## What you get back

Every way returns the same thing:

```json theme={null}
{
  "name": "take1.mov",
  "bytes": 734003200,
  "converted": false,
  "conform_at_render": true,
  "note": "...",
  "media": {"id": "take1", "asset_hash": "9f2c...", "duration": {"ticks": 4004, "rate": 100},
            "kind": "video", "lineage": []},
  "audio": {"id": "take1-audio", "asset_hash": "9f2c...", "duration": {"ticks": 4004, "rate": 100},
            "kind": "audio", "lineage": ["9f2c..."]}
}
```

* The media **id** comes from the file name: `take1.mov` becomes `take1`. Name files the way you want to refer to them in edits.
* A video with sound also returns **`audio`**: its sound as separate audio media (`take1-audio`), so you can place picture and sound on their own tracks.
* Pass the `media` (and `audio`) objects to an [`add_media` edit](https://docs.vidjutsu.ai/guides/editing#edit-operations) to use them in a project.
* Files are stored as uploaded, by content hash. Footage that isn't constant-frame-rate H.264 (phone video, ProRes, screen recordings) is converted at render time, only the parts a render uses, and the conversion is cached for later renders (`conform_at_render: true`).
* Uploading the same bytes twice stores them once.

## Direct uploads

The bytes go from you to storage by presigned links, never through the API, in parts you can send in parallel and retry one at a time.

**1. Start the upload**

Send the file's name, exact length and SHA-256 (64 lowercase hex digits).

```sh theme={null}
curl -s -X POST https://api.vidjutsu.ai/uploads \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"name": "take1.mov", "bytes": 734003200, "sha256": "9f2c..."}'
```

```json theme={null}
{"upload_id": "up_...", "name": "take1.mov", "already_stored": false,
 "part_size": 67108864, "expires_at": 1793671600,
 "parts": [{"number": 1, "url": "https://..."}, {"number": 2, "url": "https://..."}]}
```

If `already_stored` is true, those bytes are already in your library: skip to step 3 and complete with `{}`.

**2. PUT each part**

Every part is exactly `part_size` bytes (64 MiB for most files), and the last part is the rest. PUT each part's bytes to its `url` and keep the `ETag` header from each response. A failed part can be sent again. The links work for 6 hours (`expires_at`, Unix seconds).

```sh theme={null}
curl -s -X PUT --data-binary @part1.bin -D - "https://..." | grep -i etag
```

**3. Complete it**

Send every part's number and ETag, in order.

```sh theme={null}
curl -s -X POST https://api.vidjutsu.ai/uploads/up_.../complete \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"parts": [{"number": 1, "etag": "\"a1b2...\""}, {"number": 2, "etag": "\"c3d4...\""}]}'
```

The stored bytes are checked against the SHA-256 you sent (a mismatch stores nothing and is a 400), then the file is added to your library. The answer is the same as adding from a link. Completing again returns the same answer. Checking the hash reads the whole file, so a very large file takes a minute or so to complete.

`DELETE /uploads/{upload_id}` abandons an upload and the parts sent so far.

## Adding from a link

The link must be `https://` to a named host: no IP addresses, `localhost` or credentials in the URL, and redirects are not followed. A presigned link from your own storage works. `name` is optional and defaults to the link's last path part.

## Where a file came from

`POST /media` and completing an upload take an optional `source`: where the file came from, for example `{"type": "hyperframes", "project": "intro-card", "version": 3}`. A project's [files](https://docs.vidjutsu.ai/guides/shot-list.md#files-and-where-they-came-from) list shows it, so an agent knows what to edit to remake the file. Send `project` too, and that project's open editors show the upload and its progress.

## Previews and transcripts

Two background jobs turn a stored file into what the editor and agents read:

| Call | Makes |
| - | - |
| `POST /media/{hash}/preview` | A small proxy video, a filmstrip and a waveform |
| `POST /media/{hash}/transcript` | The words, with start and end times, and speakers when known |

Each is billed by the box time it uses ([pricing](https://docs.vidjutsu.ai/pricing.md)), and made once per file: asking again while one exists or is being made answers `started: false` and costs nothing. Otherwise the answer is a job: poll `GET /jobs/{job_id}`, then read the result, which is free:

```sh theme={null}
curl -s -X POST https://api.vidjutsu.ai/media/<hash>/transcript \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"project": "launch-film"}'
# {"job_id": "rj_...", "state": "queued", "started": true, ...}

curl -s https://api.vidjutsu.ai/media/<hash>/transcript -H "Authorization: Bearer $KEY"
# {"state": "ready", "language": "en", "words": {"url": "https://..."}, ...}
```

`GET /media/{hash}/preview` and `GET /media/{hash}/transcript` report a `state` (`none`, `pending`, `ready` or `failed`) and, when ready, time-limited links. A transcript's `words.url` is a JSON array of words with `start` and `end` seconds. The CLI does both steps and waits: `vidjutsu transcript <hash>` and `vidjutsu preview <hash>`.

Transcripts are what [timeline words](https://docs.vidjutsu.ai/guides/agents.md#cut-by-the-script) and [word search](https://docs.vidjutsu.ai/guides/shot-list.md#find-what-was-said) read.

## Download links

`GET /media/{hash}/url?ttl=3600` returns a time-limited link to any stored file, including finished renders. `ttl` is in seconds, from 60 to 604800 (7 days); the default is one day. The CLI: `vidjutsu url <hash> --ttl 3600`.

## Cost

Uploading is free; stored bytes count toward storage. Previews and transcripts are billed by box time. See [Pricing](https://docs.vidjutsu.ai/pricing.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.