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

# Tutorials API

> Video tutorials over the API: create a tutorial of your site, read and change its script, make the video ($15), get its files in every language, delete it

Everything **Build → Video tutorials** does in the dashboard is also an API call ([how it works](https://docs.lokutor.com/guides/video-tutorials.md)). Authenticate as for any request (`Authorization: Bearer <key>` or `X-API-Key`); every call sees only your workspace. A key needs the `tutorials` [permission](https://docs.lokutor.com/authentication.md#what-a-key-can-do) (or none narrowed), and a key limited to some agents cannot use tutorials (`403`). Viewers may read; members, admins and owners may create, change, make and delete.

| | |
| :- | :- |
| `POST /v1/tutorials` | A new tutorial; its script is written, free |
| `GET /v1/tutorials` | Your tutorials, newest first |
| `GET /v1/tutorials/{id}` | One, with its script and, once made, its videos |
| `PATCH /v1/tutorials/{id}` | The script's words, the title, what to show, the sign-in |
| `POST /v1/tutorials/{id}/write` | Write the script again, free |
| `POST /v1/tutorials/{id}/make` | Make the video: \$15 from the balance, or free as a remake |
| `DELETE /v1/tutorials/{id}` | The tutorial, its files and its sign-in |

## `POST /v1/tutorials`

Creates a tutorial and starts writing its script. Answers `201` with the [tutorial](#the-tutorial), in state `writing`. Writing is free; like every request it needs the balance to start one (\$0.25) and is held to your spend limits.

| Field | Type | Required | Description |
| :- | :- | :- | :- |
| `site_url` | string | Yes | The page the video starts on: `https://` (or `http://`) on the public internet, no user or password in it. |
| `goal` | string | Yes | What the video should show, in plain words: 10 to 2,000 characters. |
| `confirm_control` | bool | Yes | Must be `true`: you control this site, and the account you give is a test or demo account of it. |
| `languages` | string\[] | No | Up to five of `en`, `es`, `ca`, `gl`, `eu`, `pt`, `fr`, `it`, `de`, `nl`, `pl`, `ro`, `ru`. The first is the script's. Default: the language new agents speak in your workspace (**Settings → Agents**), else `en`. |
| `voice` | string | One of these two | The voice for every language: a slot `F1`–`F5` / `M1`–`M5` or one of your `clone_…` voices ([voices](https://docs.lokutor.com/voices-languages-models.md)). |
| `voices` | object | | A voice per language, `{"en": "F1", "es": "M2"}`; a language without one takes `voice`. |
| `depth` | string | No | How much it explains: `short` (the task alone, under a minute and a half), `normal` (the task explained, a minute and a half to three; the default) or `tour` (every part and setting that matters, three to eight minutes). |
| `title` | string | No | Up to 120 characters. Empty: the script's own title. |
| `audience` | string | No | Who it is for ("new admins of the clinic"), up to 200 characters. |
| `sign_in` | object | No | A test account the video is filmed with: [The sign-in](#the-sign-in). |

```bash theme={null}
curl -X POST https://api.lokutor.com/v1/tutorials \
  -H "Authorization: Bearer sk_your_key" -H "Content-Type: application/json" \
  -d '{
    "site_url": "https://app.example.com/projects",
    "goal": "Create a project called Spring, invite nobody, and open its settings to show where the deadline is set.",
    "languages": ["en", "es"],
    "voice": "F1",
    "sign_in": { "url": "https://app.example.com/login", "user": "demo@example.com", "password": "…" },
    "confirm_control": true
  }'
```

Three tutorials of a workspace may be written or made at once, and thirty scripts written a day; past either, `400`.

## `GET /v1/tutorials`

Your tutorials, newest first (the last 200), without their scripts and videos, the price of a video, and what the service can do right now:

```json theme={null}
{ "tutorials": [ { "id": "…", "title": "…", "state": "done", "…": "…" } ], "price_usd": 15, "sign_in_available": true, "make_available": true }
```

`sign_in_available` false: a tutorial with a `sign_in` is refused (`400`); use a public page. `make_available` false: scripts are written, and `make` answers `503` `tutorials.unavailable`.

## `GET /v1/tutorials/{id}`

The [tutorial](#the-tutorial) with its script and, once made, its videos. Ask again while it is being written or made: `state` and `progress` say how far it is (every few seconds is enough). Links to files last an hour.

## `PATCH /v1/tutorials/{id}`

Changes the script's words, the title, what to show, or the sign-in. Answers the tutorial. While its script is being written or its video waits or is being made, `409` `tutorials.busy`.

| Field | Type | Description |
| :- | :- | :- |
| `scenes` | object\[] | `[{"id": "…", "say": "…", "chapter": "…"}]`: the words of the scenes you change, by their `id`. Only the words change: the steps stay as they were found. |
| `title` | string | Up to 120 characters. |
| `goal` | string | What to show. A different one writes the script again, free (the tutorial goes back to `writing`); a `title` in the same request is kept, `scenes` are not (the script is written anew). |
| `depth` | string | `short`, `normal` or `tour`. A different one writes the script again, as a new `goal` does. |
| `sign_in` | object or `null` | A new sign-in in place of the one there was, or `null` to delete it now ([The sign-in](#the-sign-in)). |

**Markers.** A scene's `say` carries markers such as `[click:open-voices]`: each ties a step to the word after it, so the browser acts as the voice says that word. You may send the words without them: the markers are put back before the same words they stood before (before the next word that is still there, if that one went). Expression tags such as `[laugh]` are words, and stay as you write them. `text` is the same words without markers, as a person reads them.

A scene's words are at most 600 characters. Words that would take longer than eight minutes in the script's language (`estimate.seconds`, at about 15 characters a second) are kept, and Make refuses them until they are shorter.

```bash theme={null}
curl -X PATCH https://api.lokutor.com/v1/tutorials/7d70f33d-… \
  -H "Authorization: Bearer sk_your_key" -H "Content-Type: application/json" \
  -d '{"scenes": [{"id": "voices-list", "say": "Start on the introduction page, then open Voices, Languages and Models."}]}'
```

### The sign-in

`{"url": "…", "user": "…", "password": "…"}`: the page where the account signs in, on the same site as `site_url` (`app.example.com` and `login.example.com` are the same site), and a **test or demo account's** user or e-mail (up to 200 characters) and password (up to 500).

* The user and password are sealed as they arrive and are never answered by any route: a tutorial says only `sign_in.url` and `sign_in.delete_after`.
* They are typed only by a sign-in step that runs before anything is filmed. No filmed step, and no step the model writes, types into a password field.
* They are deleted at `delete_after`: 30 days after you give them, or the end of the video's free remakes if that is later. `"sign_in": null` deletes them now.
* `signs_in: true` says the video is filmed signed in: while it has no sign-in, Make answers `400` until you give one again.
* A page with a CAPTCHA, or an account that asks for a code (a second factor), cannot be signed in to: the job ends with `sign_in_captcha` or `sign_in_second_factor`.

Without a sign-in key on the server, a tutorial with a sign-in is refused (`400`) and public pages still work.

## `POST /v1/tutorials/{id}/write`

Writes the script again from the same `goal`, free. `202` with the tutorial in state `writing`. The words you changed are replaced.

## `POST /v1/tutorials/{id}/make`

Makes the video in every language. `202` with the tutorial in state `queued`; then `making`, then `done` or `failed`.

* **What it costs** is in the tutorial's `make`: `{"charge": true, "usd": 15}` takes **\$15** (`tutorial_video` on the [rate card](https://docs.lokutor.com/api-reference/rate-card.md)) from the balance now, in the same step as the job is queued. Within 30 days of a paid make, `{"charge": false, "remakes_left": 9, "remakes_until": "…"}`: it is made again for nothing, up to ten times.
* The balance must cover the price: `402` `billing.insufficient_balance` otherwise (nothing is taken), or another `402` `billing.*` code for a [spend limit](https://docs.lokutor.com/pricing.md#limits).
* A make that cannot be done ends as `failed` with its `error`, and a paid one is **given back to the balance by itself**, once.
* `400` when there is no script yet, when its words take longer than eight minutes, when a step would pay, delete or send (`flag: "refused"`), or when a video filmed signed in has no sign-in.
* One video is made at a time for every workspace. While yours waits, `ahead` is how many will be worked on before it.

## `DELETE /v1/tutorials/{id}`

Deletes the tutorial, its videos and files, its jobs and its sign-in, at once. A job in progress stops. `200` `{"deleted": true, "id": "…"}`. A paid video that was still waiting or being made is given back to the balance; one that was made is not.

## The tutorial

```json theme={null}
{
  "id": "7d70f33d-e60c-40f8-90f2-29f1e650bf1e",
  "title": "Finding the voices",
  "site_url": "https://docs.example.com/introduction",
  "goal": "Show where the list of voices is, and open the page about making speech from text.",
  "languages": ["en", "es"],
  "voices": { "en": "F1", "es": "F1" },
  "depth": "normal",
  "state": "making",
  "error": null,
  "progress": { "phase": "recording", "step": 4, "of": 12, "at": "2026-11-26T10:04:12Z" },
  "sign_in": { "url": "https://docs.example.com/login", "delete_after": "2026-12-26T10:00:00Z" },
  "signs_in": true,
  "makes": 1,
  "paid_at": "2026-11-26T10:02:00Z",
  "remakes_until": "2026-12-26T10:02:00Z",
  "made_at": null,
  "created_at": "2026-11-26T10:00:00Z",
  "updated_at": "2026-11-26T10:04:12Z",
  "script": {
    "title": "Finding the voices",
    "summary": "Where the voices are listed, and the page on speech from text.",
    "language": "en",
    "scenes": [
      {
        "id": "voices-list",
        "chapter": "Finding the voice list",
        "say": "Start on the introduction page. [click:open-voices] Open the Voices, Languages & Models link.",
        "text": "Start on the introduction page. Open the Voices, Languages & Models link.",
        "steps": [
          { "scene": "voices-list", "id": "open-voices", "do": "click", "what": "Press “Voices, Languages & Models”" }
        ]
      }
    ]
  },
  "videos": [],
  "make": { "charge": false, "usd": 0, "remakes_left": 10, "remakes_until": "2026-12-26T10:02:00Z" },
  "estimate": { "seconds": 41.2 }
}
```

| Field | Description |
| :- | :- |
| `state` | `writing` (the script is being written), `unwritten` (it could not be: see `error`), `ready` (a script to read and make), `queued` (waiting its turn to be made), `making`, `done`, `failed` (see `error`; a script that was there is still there). |
| `error` | `{"code", "message"}`: why the last job did not end well, said as you can act on it. `null` otherwise. |
| `progress` | While a job runs: `phase` (`starting`, `signing_in`, `writing`, `translating`, `voicing`, `recording`, `composing`, `uploading`), and `step` and `of` while recording (and uploading), `language` while putting the words into a language or voicing it. |
| `ahead` | While it waits: how many jobs will be done before it. Absent when none. |
| `script.scenes[].steps[]` | What the browser does in the scene: `do` (`click`, `type`, `choose`, `go`, `press`, `scroll`, `hover`, `highlight`, `upload`, `wait`, `look`), `what` it is in a line, and `flag`: `changes` (it writes or saves something on your site) or `refused` (it would pay, delete, send, invite, call or sign out, and is never pressed). |
| `make` | What Make costs now: `charge`, `usd`, and for a remake `remakes_left` and `remakes_until`. |
| `estimate.seconds` | About how long the script's words take in its language. |
| `makes`, `paid_at`, `remakes_until`, `made_at` | How many times Make was pressed, when the video was last paid, until when it is remade for nothing, when the current videos were made. |

### Videos

Once made, `videos` has one per language, its files by links that last an hour:

```json theme={null}
{
  "language": "es",
  "seconds": 53.1,
  "chapters": [ { "title": "Resumen", "from": 0 }, { "title": "Empezar", "from": 8 } ],
  "video_url": "https://…",
  "download_url": "https://…",
  "poster_url": "https://…",
  "captions_url": "https://…",
  "captions_srt_url": "https://…",
  "chapters_url": "https://…",
  "article_url": "https://…",
  "article": "# Encontrar las voces\n\n…",
  "captions_vtt": "WEBVTT\n\n1\n00:00:00.000 --> 00:00:03.150\nVoz hecha con IA\n…",
  "made_at": "2026-11-26T10:09:40Z"
}
```

`video_url` plays the MP4 in a browser; `download_url` saves it under the tutorial's title and language. `captions_url` and `chapters_url` are WebVTT, `captions_srt_url` SubRip. `article` is the step-by-step article in Markdown, its pictures linked for the hour; `article_url` downloads it. `captions_vtt` is the captions' WebVTT itself, for a player that cannot read the bucket's link from your page. Only the latest make's files are kept.

### Why a job ended

| `error.code` | What happened |
| :- | :- |
| `not_reached` | What you asked for could not be found on the site. |
| `too_many_steps` | It would take more steps than its depth allows (14 short, 32 normal, 90 tour): say what to show more narrowly, or choose a deeper one. |
| `too_much_work` | The site needed more work than a video may take. |
| `too_long` | The words take longer than eight minutes in one of the languages. |
| `step_broken` | A step no longer works on the site (it changed since the script was written). |
| `refused` | It would have pressed something that pays, deletes, sends or signs out. |
| `site_unreachable` | The site did not open. |
| `sign_in_captcha`, `sign_in_second_factor` | The sign-in asks to prove you are not a robot, or for a code. |
| `sign_in_rejected`, `sign_in_no_form`, `sign_in_failed` | The user and password were not accepted, the page has no sign-in form, or the site did not keep the account signed in. |
| `runner_lost`, `failed` | Something went wrong on our side. |

## Errors

Refusals answer `{"error": "…", "code": "…"}`; `error` says what to change.

| Code | HTTP Status | Meaning |
| :- | :- | :- |
| `tutorials.invalid` | `400` | Something in the request cannot be used, or the tutorial cannot do that now; `error` says what. |
| `billing.insufficient_balance` | `402` | Make: the balance does not cover the video. Writing: the balance is under \$0.25. |
| `billing.*` | `402` | A spend limit of the workspace, the person or the key ([Billing errors](https://docs.lokutor.com/api-reference/errors.md#billing-errors)). |
| `account.permission_required` | `403` | The key does not have the `tutorials` permission. |
| `tutorials.not_found` | `404` | There is no such tutorial in your workspace. |
| `tutorials.not_available` | `404` | Video tutorials are not open to your workspace yet. |
| `tutorials.busy` | `409` | Its script is being written, or its video waits or is being made: wait until it is done. |
| `tutorials.unavailable` | `503` | Making videos is not available on this server right now. |


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