Projects

Save editable video state and export the same project more than once.

A project keeps an editable video in your workspace. Use one for a draft you will revisit, an editor with autosave, or a workflow that uploads media before rendering.

For a single export without saving a draft, use Exports.

Create a project

Send a complete, validated editorState and stateSchemaVersion: "v1" to POST /v1/projects. The state document also contains its own stateSchemaVersion: "v1".

This example uses the sample from the Quick Start:

import { readFileSync } from 'node:fs'
import { IndreamClient } from '@indreamai/client'

const client = new IndreamClient({ apiKey: '<YOUR_API_KEY>' })
const editorState = JSON.parse(readFileSync('editor-state.json', 'utf8'))
const project = await client.projects.create({
  title: 'Product introduction',
  description: 'A short introduction for the website.',
  editorState,
  stateSchemaVersion: 'v1',
})
console.log(project.projectId)

Keep projectId for subsequent reads, updates, uploads, and exports.

Read and update a draft

GET /v1/projects/{projectId} returns project metadata and its saved editor state. GET /v1/projects returns a paginated list of summaries.

Use PATCH /v1/projects/{projectId} to update the title or description. Use POST /v1/projects/{projectId}/sync to replace the full saved state:

await client.projects.sync(project.projectId, {
  editorState,
  stateSchemaVersion: 'v1',
})

This snippet continues the create example. A sync request sends a complete state, not a partial field update. Validate your draft first and coordinate saves in your application so an older draft cannot overwrite a newer one.

Debounce autosaves. If the API returns OPEN_API_PROJECT_SYNC_RATE_LIMITED, wait and retry with backoff; do not send one request per keystroke.

Add media

Upload a file with the project's ID or bind an existing asset. See Assets for upload headers, supported files, and the fields needed in editor state.

Binding an asset to a project does not place a clip on the timeline. The saved state must also contain the asset and the item that references it.

Export saved state

const created = await client.projects.createExport(project.projectId, {
  ratio: '16:9',
  scale: 1,
  fps: 30,
  format: 'mp4',
  filename: 'product-introduction.mp4',
})
const completed = await client.exports.wait(created.taskId)
console.log(completed.projectId, completed.outputUrl)

The export uses the state saved when the request is made. Save your latest changes before exporting. Export tasks and webhook payloads include projectId so you can associate results with the draft.

Delete a project

DELETE /v1/projects/{projectId} deletes the project. Removing a project binding and deleting an asset are separate operations; use the asset endpoints when managing uploaded files.

Last updated on

On this page