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

# Shotstack plugin

> Cloud video editing and rendering: build a timeline as JSON, render video, image, GIF or audio, manage templates, generate AI assets, ingest source files and serve hosted assets.

Use **Shotstack** through Corsair: one client, typed API calls, and incoming webhooks.

Shotstack renders a video, image, GIF or audio file from a JSON timeline. `renders.create` queues the render and returns a render id at once; `renders.get` reports progress until status is `done` or `failed`. Templates store an edit with placeholders, AI generation and file ingestion poll the same way, and the Serve API returns the durable CDN URLs.

* **Keys.** Create an account at [app.shotstack.io](https://app.shotstack.io/register) and open API Keys. Each account gets a Production key (the `/edit/v1`, `/ingest/v1`, `/serve/v1` paths) and a free Sandbox key (the `/stage` paths, watermarked output). Store either one. Set the account's `environment` to `v1` or `stage` (or the `environment` plugin option); left unset, the plugin tries production first, switches to the sandbox when production refuses the key, and remembers the answer.
* **Credits.** Production renders spend credits: new accounts get 10 free credits (about 10 minutes of video). Sandbox renders are free but watermarked and still need a credit balance on the account. AI generation is charged on the sandbox too: quote it first with `generations.quote`.
* **Callbacks.** Pass `callback` on `renders.create` or `sources.fetch`, or put it in the saved edit of a template (`template.callback` on `templates.create` / `templates.update`) for `templates.render`, and Shotstack POSTs the result there: the `render`, `source` and `serve` (hosted copy ready) webhooks. Shotstack does not sign callbacks, so the plugin looks each one up with the account's key and answers with the API's own status and URL; a callback for an id the account doesn't have is refused. `verifyWebhooks: false` turns the lookup off.
* **The render URL expires.** `renders.get` returns `response.url`, a temporary download link that dies 24 hours after the render. For a permanent link, read the CDN URL from `assets.getByRenderId` (or `https://cdn.shotstack.io/...`).
* **Long jobs.** `renders.create`, `templates.render`, `generations.create` and `sources.fetch` start work that runs after the call returns. Poll the matching get operation until the status is `done` (or `ready` for sources) or `failed`. Shotstack sends no cancel operation, and a render cannot be deleted once queued. A render takes roughly 20 seconds per minute of output video.
* **Retries.** Rate limits are per key in a fixed 60-second window: edit 300 requests per minute, serve 600, ingest 300 (halved on sandbox). Over the limit the API answers 429, and the plugin waits for the window to reset (Retry-After when sent, otherwise 60 seconds) and retries once. 5xx answers are replayed only for reads, and for `generations.create` when an `idempotencyKey` was sent: retrying with the same key returns the job it first created instead of generating and billing again.
* **Merged renders.** `renders.get` sends `data: false` by default; pass `data: true` to include the full timeline echo in `response.data`, and `merged: true` with it to include the merged edit.
* **Uploads.** `uploads.create` returns a signed S3 URL; PUT the bytes to it within one hour and the file appears as an ingest source. The binary upload goes to S3 directly, not through the plugin.
* **Responses.** Output fields are typed from Shotstack's OpenAPI spec (v1.27.0) and checked against live sandbox calls. Fields Shotstack adds pass through, and status values it adds are kept as strings. `templates.update` answers with a message only (no id), and Shotstack refuses an update without the edit, so `template` is required.
* **Deletes.** `templates.delete`, `sources.delete` and `assets.delete` are permanent; there is no undo and no trash.

**What you get:**

* 23 typed API operations
* 3 incoming webhook event types

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/shotstack better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/shotstack better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/shotstack better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/shotstack better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { shotstack } from '@corsair-dev/shotstack';

export const corsair = createCorsair({
	plugins: [
		shotstack(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the Shotstack API key before the first call: `pnpm corsair setup --plugin=shotstack --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> shotstack()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'shotstack',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Check where a render stands**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.shotstack.api.renders.get({ id: '2abd5c11-0f3d-4c6d-ba20-235fc9b8e8b7' });
```

**Render a template with placeholders filled in**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.shotstack.api.templates.render({
	id: 'f5493c17-d01f-445c-bb49-535fae65f219',
	merge: [{ find: 'NAME', replace: 'Jane' }],
});
```

See the full list on the [API](https://docs.corsair.dev/plugins/shotstack/api.md) page.

## Webhooks

This plugin registers **3** webhook event types. Configure the provider to POST to your Corsair HTTP handler, then use `webhookHooks` on the plugin factory.

See [Webhooks](https://docs.corsair.dev/plugins/shotstack/webhooks.md) for every event path and payload shape, and [Webhooks concept](https://docs.corsair.dev/concepts/webhooks.md) for routing.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/shotstack/api.md)
>
> Every `shotstack.api.*` operation with input and output types.

> [card] [Webhooks](https://docs.corsair.dev/plugins/shotstack/webhooks.md)
>
> Event paths, payloads, and `webhookHooks` examples.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


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