# Automate Video Clipping with an API (and an MCP Client)

If you clip more than a couple of recordings a week, script it. The whole pipeline is a handful of HTTP calls: hand over the source, start a job, poll until it finishes, then download the clips and subtitle files. This post walks through each step with short curl examples against the autoclip API, covers the details that make a script safe to rerun, and ends with connecting an MCP client so an assistant can do the same work from a chat.

The snippets are trimmed for reading. The full reference, with every field, error code and limit, lives at [/docs](https://autoclip.sh/docs).

## Before you start

You need an account with some credits and an API key. Create the key under **Settings → API keys**. Keys start with `sk_`. Store yours in an environment variable and never commit it:

```bash

```

Every request sends it as a bearer token. Listing your jobs is a good first test, because it also returns your balance:

```bash
curl -s https://autoclip.sh/api/clips/jobs \
  -H "Authorization: Bearer $AUTOCLIP_KEY" | jq '.data.balance'
```

Answers share one envelope: `code` is `0` on success, `data` holds the result, and `message` explains an error. Jobs are billed per minute of source, rounded up, at the rates on [/pricing](https://autoclip.sh/pricing). A script that checks the balance first can stop early instead of failing halfway through a batch.

## Step 1: hand over the source

If the recording already sits at a public https address (your own storage bucket, a CDN, a file host that serves the raw file), one call is enough:

```bash
curl -s https://autoclip.sh/api/clips/sources \
  -H "Authorization: Bearer $AUTOCLIP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://files.example.com/talk-42.mp4"}'
```

autoclip copies the file into your private storage, measures it and answers with its `id`, `seconds`, `width` and `height`. The `id` is the `sourceId` a job takes. The link must point at the file itself; pages that need a sign-in, YouTube and social networks don't work.

For files on disk, upload in parts. One dropped connection at 90% then costs one part, not the whole file:

```bash
start=$(curl -s https://autoclip.sh/api/clips/upload/start \
  -H "Authorization: Bearer $AUTOCLIP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fileName":"talk-42.mp4","contentType":"video/mp4","size":734003200}')
SOURCE_ID=$(echo "$start" | jq -r .data.sourceId)
TOKEN=$(echo "$start" | jq -r .data.token)
PART=$(echo "$start" | jq -r .data.partSize)
```

Split the file into chunks of `partSize` bytes and send each as raw bytes, collecting the `etag` of every part. Part numbers start at 1:

```bash
split -b "$PART" -d -a 3 talk-42.mp4 part_
n=1; parts=()
for f in part_*; do
  etag=$(curl -s -X PUT "https://autoclip.sh/api/clips/upload/part?n=$n" \
    -H "Authorization: Bearer $AUTOCLIP_KEY" \
    -H "X-Upload-Token: $TOKEN" \
    --data-binary @"$f" --retry 3 | jq -r .data.etag)
  parts+=("{\"partNumber\":$n,\"etag\":\"$etag\"}")
  n=$((n+1))
done
curl -s https://autoclip.sh/api/clips/upload/complete \
  -H "Authorization: Bearer $AUTOCLIP_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"sourceId\":\"$SOURCE_ID\",\"token\":\"$TOKEN\",\"parts\":[$(IFS=,; echo "${parts[*]}")]}"
```

`--data-binary` matters: plain `-d` strips newlines and corrupts binary data. Sources can be up to 60 minutes, in MP4, MOV, M4A, MP3 or WAV. Send only recordings you have the rights to.

## Step 2: start a job with an Idempotency-Key

A job has one of four modes:

- `transcript`: the transcript and subtitle files, plus highlight timestamps. No video, so it costs the least.
- `clips`: each highlight cut as an MP4 in the original frame.
- `vertical`: the same clips cropped to 9:16.
- `shorts`: vertical clips with word-by-word captions burned in.

```bash
curl -s https://autoclip.sh/api/clips/jobs \
  -H "Authorization: Bearer $AUTOCLIP_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: talk-42-shorts-v1" \
  -d "{\"sourceId\":\"$SOURCE_ID\",\"mode\":\"shorts\",\"count\":6,\"focus\":\"moments about pricing and churn\"}"
```

- `count` is how many highlights you want, up to 20.
- `focus` is optional free text that steers the picks toward a theme. It is screened by an automated safety check before the job runs, and nothing is charged if it is refused.
- `ranges` replaces the AI pick when you already know the moments: `"ranges":[{"start":812,"end":869}]`, in seconds, each 15 to 90 seconds.

**Why the Idempotency-Key header?** Networks fail in annoying ways. Your request can reach the server, start a job and charge credits, and then the response gets lost. A naive script retries and now you have two jobs and a double charge. Send the same `Idempotency-Key` on the retry and the API returns the original job instead of creating a new one.

Pick a key that is unique per logical job and stable across retries: your recording id plus the mode plus a version you bump when you deliberately want a fresh run. A random value per attempt defeats the point.

Credits are taken when the job starts. If the whole job fails, they come back automatically. If only some clips fail, the share for those clips comes back.

## Step 3: poll until it finishes

The create call returns the job with its `id`. Poll it:

```bash
while :; do
  phase=$(curl -s "https://autoclip.sh/api/clips/jobs/$JOB_ID" \
    -H "Authorization: Bearer $AUTOCLIP_KEY" | jq -r .data.phase)
  echo "$phase"
  case "$phase" in done|failed) break ;; *) sleep 20 ;; esac
done
```

`phase` moves through `audio` (only for large files), `transcribe`, `pick` and `render`. Wait 20 to 30 seconds between calls; an hour-long file needs more patience than a ten-minute one, and hammering the endpoint won't make it faster.

## Step 4: download the clips and subtitles

A finished job looks roughly like this:

```json
{
  "phase": "done",
  "clips": [
    {
      "start": 812.4,
      "end": 869.1,
      "title": "The discount that doubled churn",
      "hook": "Why a launch discount backfired six months later.",
      "status": "done",
      "output": "https://cdn.autoclip.sh/..."
    }
  ],
  "transcriptUrl": "https://cdn.autoclip.sh/...",
  "refunded": 0
}
```

`start` and `end` are seconds into the original file, so you can line clips up with your own timeline. Download everything with a few lines of `jq`:

```bash
job=$(curl -s "https://autoclip.sh/api/clips/jobs/$JOB_ID" \
  -H "Authorization: Bearer $AUTOCLIP_KEY")
echo "$job" | jq -r '.data.clips[] | select(.status=="done") | .output' |
  nl -w2 -s' ' | while read i url; do curl -s -o "clip_$i.mp4" "$url"; done
curl -s -o talk-42.srt "https://autoclip.sh/api/clips/jobs/$JOB_ID/subtitles?format=srt" \
  -H "Authorization: Bearer $AUTOCLIP_KEY"
```

Save the titles and hooks next to the files; they make a decent first draft for post captions.

Files are deleted automatically 30 days after they were made, so treat the links as temporary and copy what you want to keep. They are long and unguessable, but anyone with a link can open it, so don't paste them in public places.

## Making the script robust

- **Check the balance first** and skip the batch if it is too low.
- **Derive Idempotency-Keys from your data**, so reruns after a crash pick up existing jobs.
- **Store job ids** as soon as you get them. If the script dies while polling, it can resume without creating anything new.
- **Review before publishing.** The picker works from the transcript, and transcription can mis-hear names and numbers.
- **Keep one key per machine or service.** If one leaks, you revoke it without breaking the others.

## Let an assistant run jobs over MCP

The same account works from MCP clients such as Claude, ChatGPT and Cursor. Point the client at:

```
https://autoclip.sh/mcp
```

Sign in through OAuth when prompted, or configure the client with your API key as a bearer token. Setup steps for each client are on [/mcp-server](https://autoclip.sh/mcp-server).

Once connected, the assistant can list the modes and prices, start a job from an attachment or a link, and fetch results. Ask in plain language: "Cut six vertical shorts about pricing from this talk and give me the SRT." The assistant spends your credits and acts as you, so connect only clients you trust.

MCP is handy for one-off requests. For a weekly pipeline that runs unattended, the plain HTTP script above is easier to monitor.

## Where to go next

- The full endpoint reference, limits and error codes: [/docs](https://autoclip.sh/docs).
- Per-minute rates, plans and credit packs: [/pricing](https://autoclip.sh/pricing).
- Try a single file by hand on [the home page](https://autoclip.sh/), then automate once the output looks right.

---

Source: https://autoclip.sh/blog/automate-video-clipping-api · Site index for AI agents: https://autoclip.sh/llms.txt · Full content: https://autoclip.sh/llms-full.txt
