HTTP API
The Pipeline API is a Flask app in renderer/api/. The dashboard calls it through its proxy, the
poller (scripts/poll.py) reads its work from it, and external tooling should use it too.
| Container | tubematic-api |
| Port | 4000 |
| Prefix | None. Every route is at the app root |
| Content type | JSON in, JSON out |
| Authentication | Authorization: Bearer <api_token> on every route except the two health probes |
| Code | renderer/api/server.py, renderer/api/pipeline.py::create_pipeline_blueprint, renderer/api/api_auth.py |
The same process serves the render gateway, a separate app on HTTPS port 4443 that only renderers call.
Route index
Health and login routes
| Method | Path | Purpose |
|---|---|---|
GET | /health | Liveness probe, no token |
GET | /render/health | Chromium check, no token |
POST | /auth/login | Check the dashboard password |
Video routes
| Method | Path | Purpose |
|---|---|---|
GET | /stats | Count videos per status |
GET | /videos | List videos, with filters |
GET | /videos/actionable | Videos waiting for a human |
GET | /videos/workable | Videos an agent may work |
GET | /videos/<video_id> | One video with its comments |
POST | /videos | File a proposed topic |
POST | /videos/manual | Create a video by hand |
PATCH | /videos/<video_id> | Change status and editable fields |
POST | /videos/<video_id>/agent-outcome | Report a finished agent session |
POST | /videos/<video_id>/agent-retry | Release a stuck video |
POST | /videos/<video_id>/switch-style | Take Auto's runner-up style at SCRIPT_READY |
POST | /videos/<video_id>/switch-formula | Take the runner-up formula at SCRIPT_READY |
POST | /videos/<video_id>/switch-opening | Have the script rewritten from another drafted opening at SCRIPT_READY |
POST | /videos/<video_id>/comments | Add a comment |
DELETE | /videos/<video_id> | Delete files, archive the row |
GET | /retention/backlog | Size of unpublished leftovers |
GET | /storage | Disk space Tubematic uses |
Project routes
| Method | Path | Purpose |
|---|---|---|
GET | /projects | List domains |
POST | /projects | Create or replace a domain |
POST | /projects/<project_id>/status | Pause or resume a domain |
Settings and voice routes
| Method | Path | Purpose |
|---|---|---|
GET | /settings | Read every setting, masked |
POST | /settings | Write a subset of settings |
POST | /voices/<voice_id>/preview | Generate or replay a sample |
GET | /visual-styles | Every visual style, and whether this install can make it |
GET | /script-formulas | Every script formula and hook type, with its label |
GET | /angle-kinds | Every kind a topic's angle can be, with its label |
Research routes
| Method | Path | Purpose |
|---|---|---|
GET | /research/strategies | Read active research modes |
POST | /research/strategies | Set active research modes |
GET | /research/mining-sources | Read the mining URL list |
POST | /research/mining-sources | Replace the mining URL list |
POST | /research/record-run | Count a research run |
Agent routes
| Method | Path | Purpose |
|---|---|---|
GET | /agents | List installed agents |
PATCH | /agents/<agent_id> | Set default, weight, model, effort |
Script profile routes
| Method | Path | Purpose |
|---|---|---|
GET | /script-profiles | List profiles |
GET | /script-profiles/pending | Profiles waiting for an agent |
GET | /script-profiles/<id> | One profile with its markdown |
POST | /script-profiles | Create from YouTube URLs |
DELETE | /script-profiles/<id> | Archive a profile |
POST | /script-profiles/<id>/record-attempt | Claim a build attempt |
Mascot routes
| Method | Path | Purpose |
|---|---|---|
GET | /mascots | List mascots |
GET | /mascots/pending | Mascots waiting for an agent |
GET | /mascots/<id> | One mascot with its versions |
GET | /mascots/<id>/versions/<version>/sheets/<sheet> | One model-sheet image |
POST | /mascots | Request a new mascot |
POST | /mascots/<id>/approve | Approve the draft version |
POST | /mascots/<id>/request-changes | Ask for a new draft |
POST | /mascots/<id>/record-attempt | Claim a build attempt |
DELETE | /mascots/<id> | Archive a mascot |
Publishing and analytics routes
| Method | Path | Purpose |
|---|---|---|
GET | /publishing/accounts | List connected social accounts |
POST | /publishing/accounts | Replace the account allowlist |
POST | /publishing/accounts/connect | Get an account-connect URL |
GET | /videos/<video_id>/publications | Where a video was posted |
POST | /videos/<video_id>/publish-prefill | Starting title and description |
POST | /videos/<video_id>/publish | Publish or schedule a video |
POST | /videos/<video_id>/publish/retry | Recover a failed publish |
POST | /videos/<video_id>/schedule/cancel | Cancel a scheduled post |
GET | /analytics | Read stored performance figures |
GET | /analytics/watch-time | Read one account's watch figures by group |
POST | /analytics/refresh | Poll performance figures now |
GET | /autopilot | Read the Auto Pilot configuration |
POST | /autopilot | Replace the Auto Pilot configuration |
Cost routes
| Method | Path | Purpose |
|---|---|---|
GET | /videos/<video_id>/costs | One video's cost breakdown |
GET | /usage/summary | Spend over a date range |
POST | /usage/agent-session | Record an agent session's usage |
GET | /prices | Model rates and sync state |
POST | /prices/sync | Run the price sync |
POST | /prices/override | Set a manual rate |
DELETE | /prices/override | Remove a manual rate |
Renderer routes
| Method | Path | Purpose |
|---|---|---|
GET | /renderers | List renderers and gateway address |
POST | /renderers/enrollments | Issue a one-time enrollment token |
PATCH | /renderers/<id> | Rename, enable or disable |
DELETE | /renderers/<id> | Remove a remote renderer |
POST | /renderers/<id>/gpu-test | Request a renderer GPU test |
GET | /render/gpu | Built-in renderer's GPU status |
POST | /render/gpu/test | Request the built-in GPU test |
Pipeline control and log routes
| Method | Path | Purpose |
|---|---|---|
POST | /pipeline/pause | Pause or resume the pipeline |
GET | /pipeline/status | Counts, caps, version, time zone |
GET | /logs | Read structured log records |
Conventions
Authentication
Every route except GET /health and GET /render/health needs the API token, the content of
~/.tubematic-data/secrets/api_token. A request without it, or with a wrong one, gets
401 {"error": "unauthorized"}, including a request for a path that does not exist.
curl -H "Authorization: Bearer $(cat ~/.tubematic-data/secrets/api_token)" http://localhost:4000/settings
api_auth.py::install_auth installs the check on the app, so it covers every blueprint and any
route added later. It exempts the two health routes by endpoint name (OPEN_ENDPOINTS), so a path
that starts with /health is not open. server.py raises at start when the token file is missing
or empty. Token creation and rotation are in Infrastructure.
A renderer credential does not work on port 4000, and the API token does not work on the render gateway.
Requests and errors
- An error is
{"error": "<message>"}with a 4xx or 5xx status. Some routes add fields, such ascurrent,expected,voice_conflictorfailures. - Routes differ on unknown body keys.
PATCH /videos/<video_id>drops them.POST /settingsandPATCH /agents/<agent_id>answer400. - An unhandled exception returns HTML (see Known quirks).
pipeline.py::create_pipeline_blueprintreadsTUBEMATIC_DBonce, whenserver.pybuilds the app, and uses that path for the life of the process.
Archived videos
An archived video has had its files deleted and keeps its row (see
Database). /stats, /videos/actionable, /videos/workable and the
counts in /pipeline/status leave archived videos out. GET /videos leaves them out unless asked.
GET /videos/<video_id> still serves one. PATCH and agent-retry answer 409 for one.
Status sets
pipeline.py defines three sets that the routes refer to. mcp/server.py and
dashboard/lib/types.ts hold copies marked # Keep in sync. What each status means is in
The Pipeline.
| Set | Members |
|---|---|
VALID_VIDEO_STATUSES | Every value the status column may hold |
ACTIONABLE_STATUSES | TOPIC_PROPOSED, SCRIPT_READY, VIDEO_READY: the human checkpoints |
WORKABLE_STATUSES | TOPIC_APPROVED, VOICING, VOICE_READY, REVISION_REQUESTED: an agent may act unattended |
VIDEO_APPROVED is not workable, because publishing is not agent work.
Time
The database stores timestamps in UTC and the dashboard displays them in the host's time zone.
The dashboard container has no /etc/localtime mount. It reads the zone from two fields of
GET /pipeline/status, which renderer/api/hosttz.py fills:
timezoneis an IANA name, resolved fromTZ, then/etc/timezone, then the/etc/localtimesymlink target, ornullwhen all three fail. JavaScript'sIntl.DateTimeFormataccepts it.timezone_labelis a display string such asEDT (UTC-04:00), computed without tzdata.Intl.DateTimeFormatthrows on it.
Health
| Route | Response |
|---|---|
GET /health | 200 {"status": "ok"} |
GET /render/health | Runs chromium --version. 200 {"status": "ok", "chromium": "…"}, or 500 {"status": "error", "detail": "…"} on a non-zero exit |
A missing Chromium binary, or a run longer than the 10-second timeout, raises to Flask's HTML error page.
Dashboard login
POST /auth/login
Checks the dashboard password for the dashboard's login route, which cannot read the database the
hash is stored in. The dashboard sets the session cookie itself on a 200. Body:
{"password": "…"}.
| Status | Cause |
|---|---|
200 | {"ok": true} |
400 | password is absent, empty, a non-string or longer than 1024 characters. Refused before hashing |
401 | {"error": "wrong password"} |
429 | Locked after failed attempts, or another login check is running. Retry-After gives the wait |
503 | No password is set. Run python3 onboard.py --set-password |
api_auth.py::LoginThrottle holds the backoff in memory:
- The first five failures in a row are free. Each later failure locks login for
2^nseconds, up to 15 minutes. The password is not checked while locked. - A success resets the count, and so does an API restart.
- The backoff covers the whole install, because every login arrives from the dashboard container and a forwarded client address can be forged.
- One password check runs at a time. A login that arrives meanwhile gets
429withRetry-After: 1and is not queued, because each scrypt check uses about 32 MiB.
Videos
GET /stats
200 {"<STATUS>": <count>} over every video that is not archived. {} for an empty database.
GET /videos
Query parameters status, project_id and strategy are exact matches, combined with AND. Rows
are ordered created_at DESC. archived=only returns archived rows and archived=include returns
both. Any other value of archived is a 400.
List responses clip gemini_feedback to 1200 characters and add a gemini_feedback_truncated
boolean. Each row also carries effective_voice_id and voice_conflicts (see
GET /videos/<video_id>).
GET /videos/actionable
Videos at a status in ACTIONABLE_STATUSES, oldest updated_at first, shaped like GET /videos.
The dashboard's Quick Actions list reads it.
GET /videos/workable
Videos at a status in WORKABLE_STATUSES, oldest updated_at first, as id, topic, status,
agent_model, agent_effort, agent_id and updated_at. The poller starts one session per row
(see The Poller). A video with agent_stuck_at set is left out until a human
acts on it.
GET /videos/<video_id>
The full row plus comments[] in chronological order. gemini_feedback is not clipped.
404 {"error": "Video not found"}.
script_segments, hook_alternatives and script_warnings are returned as parsed JSON on every
video route. The last two are [] for a video with no
script record.
Four computed fields describe the voice:
| Field | On | Meaning |
|---|---|---|
effective_voice_id | Lists and single videos | The video's voice_id, else the install default. "" when neither is on the roster |
voice_conflicts | Lists and single videos | {voice_id: reason} for each roster voice whose model cannot speak the segments the video's voice speaks |
segment_voice_conflicts | Single videos | {segment id: {voice_id: reason}} for each roster voice that cannot speak a segment's markup. Empty outside SCRIPT_READY |
voice_info | Single videos | The voice and model for the modal's read-only Voice rows |
voice_conflicts comes from the check that makes PATCH answer 409 for such a voice, so a
picker that disables these voices agrees with the server. It is empty at TOPIC_PROPOSED, because
approving the topic has the script written for the picked voice. See
The model follows the voice.
Every response that returns one video carries voice_info: this route, PATCH, POST /videos,
POST /videos/manual and agent-retry. The lists omit it, because it costs one ledger read per
row.
{"voice_id": "a1", "name": "Adam", "model_id": "eleven_v3", "model_voiced": true,
"other_voices": [{"voice_id": "r1", "name": "Rachel", "model_id": "eleven_multilingual_v2"}]}
voice_idis the video's own voice, else the install default. It is kept when the voice has left the roster, andnameis then"".model_idis the model of the video's latest voicing call, read fromusage_events, withmodel_voicedtrue. The ledger is the source because a voice's model can be edited in Settings after the video was voiced.- At
TOPIC_PROPOSED,TOPIC_APPROVED,SCRIPT_READYandVOICINGthe ledger is ignored, because a revision can switch the voice before the next voicing.model_idis then the voice's current roster model andmodel_voicedisfalse. The same applies when the ledger has no voicing row.model_idis""when neither is known. - A video spoken in more than one voice has one voicing row per run, each tagged with its voice.
model_idis read from the rows of the video's own voice. When the video's own voice spoke no line,model_idis the current setting withmodel_voicedfalse. other_voiceslists the other voices the video's segments name, in script order.nameandmodel_idare""for one that has left the roster.
POST /videos
Files a topic at TOPIC_PROPOSED. Required: topic, strategy, producibility_score. Optional:
id, project_id, title, voice_id, visual_style, formula_choice, and the topic's angle as
angle, angle_kind and angle_score.
| Status | Cause |
|---|---|
201 | The row, at video_version 1, plus warning if the title was clipped |
400 | A validation failure, listed below |
409 | project_id names a paused domain and strategy is not manual. See Domain pause |
409 | project_id names a domain at its topic_cap and strategy is not manual. See Topic cap |
400 causes:
- A required field is missing:
{"error": "Missing fields: [...]"}. idis not letters, digits,_and-, starts with-, or is longer than 128 characters. The id names the video's job directory.project_idnames no domain,titleis not a string, orvoice_idis not on the roster.visual_styleis notautoor a style pack id.visual_styleisillustrated,under_the_hoodorcase_file_storyand no OpenAI key is stored (the settings row orOPENAI_API_KEY).visual_styleiscartoon_3dand the install-wide GPUstatusis notworking(see GPU rendering).formula_choiceis not a string, or is not""or a formula id.- The angle fails
tubematic_core.angles.angle_error:angleorangle_kindis sent without the other, either is not a string,angle_kindis not a kind,angleis over 300 characters, orangle_scoreis not a whole number from 0 to 10. Anullin any of the three reads as absent.
What the route fills in:
- A
titleover 70 characters is clipped at a word boundary, with awarning. The create is not refused, because a refused create during a research run would lose the topic. agent_idandagent_modelcome from the domain while it names a live agent. Otherwiseagent_idis dealt from the assignment deck andagent_modelis"".agent_effortis the domain'sdefault_agent_effortin both cases (see Assignment). Anagent_idin the body is ignored.- With no
voice_id, the video takes its domain'sdefault_voice_idif that voice is on the roster, whatever itsstrategy. Otherwisevoice_idis"", the install default. The voice is copied onto the row, so a later change to the domain's default does not change filed videos. - With no
visual_style, acurriculumvideo takes its domain'sdefault_visual_style, and every other video starts atauto. An inheritedillustratedorcartoon_3dis stored even when its condition does not hold. The approvingPATCH, which carriesvisual_style, refuses it. - A
curriculumvideo takes its domain'sdefault_script_profile_idwhile that profile isREADYand not archived. Every other video starts with"". The route takes noscript_profile_id. mascot_idis seeded from the domain's or the install's default mascot, whatever thestrategy, while the GPUstatusisworkingand the style is notcartoon_3d(pipeline.py::_seed_mascot).- With no
formula_choice, the video takes its domain'sdefault_formula_idwhile that is a formula, whatever itsstrategy(pipeline.py::_project_default_formula). Otherwiseformula_choiceis"", and a formula is picked for the video before its script.
The route does not validate strategy or producibility_score, and it does not require an angle.
The MCP server's create_video does all three (see Topic angle).
POST /videos/manual
The dashboard's New Video page. Required: title (at most 70 characters) and topic, both
non-blank. Optional: approve (boolean, default true), agent_id, agent_model,
agent_effort, script_profile_id, visual_style, voice_id, formula_choice, and the topic's
angle as angle with angle_kind.
201 returns the row: strategy manual, producibility_score 0, angle_score 0, in the domain
manual, at TOPIC_APPROVED, or at TOPIC_PROPOSED with "approve": false.
400 causes:
titleortopicis missing or blank,titleis over 70 characters, orapproveis not a boolean.- A pick is not a string. Only an absent or
nullpick means its default, sofalseand0are refused. - A pick fails the rule the same field has on
PATCH: the agent, its model and effort, the script profile, the voice, the visual style or the formula. - The angle fails the rule it has on
POST /videos. An absent,nullor blankanglewith noangle_kindmeans no angle, which is accepted: the agent looks for one when it picks the video up. So doesnoneorn/aas the sentence, or as the kind with no sentence (tubematic_core.angles.sent_no_angle). A real sentence withnoneas its kind is refused for the kind. Anangle_scorein the body is ignored.
How it differs from POST /videos:
- It refuses an over-long title, because a person at the form can shorten it.
- It keeps a picked
agent_id, and then takes no agent, model or effort from the domain. With none, the video takes themanualdomain's agent, model and effort asPOST /videosdoes, and anagent_modeloragent_effortin the body replaces the domain's.agent_modelis checked against the agent the video ends up with, and a refused model rolls the deal back. - The video is unscored (see Where topics come from).
The first request creates the domain manual, named Manual Videos, with INSERT OR IGNORE,
so a rename on the Projects page is kept. Nothing is written until every field has passed. With no
voice_id, the video takes the manual domain's default_voice_id when it has one on the roster.
With no formula_choice, it takes the manual domain's default_formula_id in the same way.
PATCH /videos/<video_id>
The main write path. The body may hold any of status, title, script, video_version,
youtube_url, gemini_feedback, voice_id, agent_id, agent_model, agent_effort,
script_profile_id, visual_style, publish_title, publish_description, mascot_id,
formula_choice, angle and angle_kind, plus the optional guard onlyIfCurrentStatus. A body
with segment_voices follows its own rules (see A segment's voice).
{"status": "TOPIC_APPROVED", "onlyIfCurrentStatus": "TOPIC_PROPOSED", "visual_style": "auto"}
Any other key is dropped, including tts_text and resolved_visual_style, which only the MCP
server writes. The four job-path columns are the exception: a body with voice_file_path,
timeline_path, scene_config_path or video_path gets 400 and nothing is applied, so a caller
that relies on one learns it at once (see Database).
| Status | Cause |
|---|---|
200 | The updated row plus comments[] |
400 | A field fails its rule below, a job-path column is present, or the body has no updatable field (No updatable fields provided) |
404 | Video not found |
409 | The video is archived |
409 | script_profile_id, visual_style, mascot_id or formula_choice sent while the video is past TOPIC_PROPOSED |
409 | agent_id, agent_model or agent_effort sent while the video is not at a human checkpoint |
409 | angle and angle_kind sent while the video is past TOPIC_PROPOSED |
409 | An approving PATCH while the video's mascot is archived, or while a Cartoon 3D, Under the Hood or Case File Story video keeps a mascot |
409 | {"error": "Status precondition failed", "current", "expected"} |
409 | {"error", "voice_conflict": true}: the voice's model cannot speak the stored script, or, on approval to VOICING, a segment's own voice cannot speak that segment |
409 | A model was written alone and the video's agent changed while the request was in flight |
Field rules
statusmust be inVALID_VIDEO_STATUSES. The route enforces no transition graph, so a client can move a video fromTOPIC_PROPOSEDtoPUBLISHED. The dashboard and the agent's skills hold the sequence. A body withstatusalso resetsagent_no_progress_countto 0 and clearsagent_stuck_at.titlemust be a string of at most 70 characters. An update is refused where a create is clipped.scriptmust come with bothpublish_titleandpublish_description. Each of those must be a non-blank string within its cap (100 and 2000 characters). MCPupdate_videoapplies the same rule (see Publishing). Ascriptwritten here clears the video'sformula_id,hook_type,hook_alternativesandscript_warnings, because they describe the script it replaces, and the formula pick (formula_pick,formula_runner_up,formula_reason,formula_evidence), because a script written by hand follows no formula.formula_choicestays. Only MCPupdate_videowrites them.voice_idmust be on the roster, or""for the install default.formula_choicemust be a formula id, or""for Auto. An experimental formula is accepted whatever theauto_experimental_formulassetting says, because the setting covers what Auto may pick. AstatusofTOPIC_PROPOSEDemptiesformula_pick,formula_runner_up,formula_reasonandformula_evidenceand keepsformula_choice(tubematic_core/formulas.py::PICK_RESET_SET, whichset_video_statusalso uses).agent_idmust name a live agent. The video's current agent is accepted even when uninstalled. A change setsagent_modelto""in the sameUPDATE, unless the body also setsagent_model.agent_effortis kept, and the assignment deck is not touched.agent_modelmust be a string with no space and no leading-. A non-empty value must be one of the models of the agent the video will have: the body'sagent_id, else the video's, else the default agent. That agent must be live.""means the agent's default model.agent_effortmust below,medium,high,xhigh,maxor""(the agent's owneffort). The levels are the same for every agent.script_profile_idmust be aREADYprofile that is not archived, or""for none.visual_stylemust beautoor a style pack id.illustrated,under_the_hoodandcase_file_storyneed a stored OpenAI key andcartoon_3dneeds a working GPU.mascot_idmust be a string. A changed value must be a pickable mascot, needs a GPUstatusofworking, and is refused on a video that will becartoon_3d,under_the_hoodorcase_file_story.""clears the mascot.angleandangle_kindare sent together, both strings.angleis at most 300 characters andangle_kindis a kind fromGET /angle-kinds.""for both removes the angle. A changed sentence or kind setsangle_scoreto 0 in the sameUPDATE, because the score was the agent's judgement of the words it replaced; the same angle sent again keeps its score.angle_scoreitself is not writable here. A kind is stored by its id whatever its spelling (Broken expectationbecomesbroken_expectation). A request that carries only the angle does not changeupdated_at(see Topic angle).
Guards
onlyIfCurrentStatusis part of theUPDATE … WHERE id = ? AND status = ?statement, so the check and the write are atomic. On a mismatch the route reads the row again and reports the current status. Use it for every status change. The dashboard does.script_profile_id,visual_style,mascot_idand the angle can be written atTOPIC_PROPOSEDonly. The three agent fields can be written at a status inACTIONABLE_STATUSESonly. Both checks read the status before the update, so thePATCHthat approves a video can carry them. The reasons are in Frozen choices.- A write that carries a frozen field is bound to the status the check read, even without
onlyIfCurrentStatus. If the video moved on meanwhile, the answer is409 Status precondition failedwithexpectedset to that status. agent_modelis checked for membership after the freeze check, so a late edit reads as frozen. A model sent withoutagent_idis written withAND agent_id IS ?, and a concurrent reassignment makes it409.- The voice conflict check runs on every request that carries
voice_id, including an approval that re-sends the video's own voice. That voice passes unless its model was changed in Settings after the script was written. The check is skipped atTOPIC_PROPOSED, and a voice written there is bound to that status. It reads only the segments without a voice of their own. - A
statusofVOICINGfromSCRIPT_READYchecks every segment against the voice that speaks it, with or withoutvoice_idin the body, and answers409withvoice_conflictwhen one cannot. - A
mascot_idis checked only when it changes, so a client that echoes the stored value is not refused for a GPU that has gone since. A switch tocartoon_3d,under_the_hoodorcase_file_storyclears the mascot in the sameUPDATE, and a changed mascot resetsmascot_versionto 0. - The approving
PATCH(TOPIC_PROPOSEDtoTOPIC_APPROVED) is409when the video's mascot has been archived, or when the video is Cartoon 3D (by its style or byresolved_renderer) and keeps a mascot. TheUPDATErepeats both checks in itsWHEREclause (tubematic_core/mascots.py::holds_pickable_sql,cartoon_mascot_clash_sql), so an archive or a style write that commits in between also gets409. - A
visual_styledifferent from the stored one clears the record of a style Auto picked (style_pick,style_runner_up,style_reason) and the renderer and canvas recorded for the old scenes. The same value again keeps them. The mascot checks of the same request judge the video by the renderer it will have after the write, so a changed style is not refused for a Cartoon 3D renderer it clears. AstatusofTOPIC_PROPOSEDwithout avisual_stylereturns a style Auto picked toautoand clears the record, and on everyautovideo it clears the recorded renderer and canvas. Both are SQL fragments intubematic_core/visual_styles.pythatupdate_videoandset_video_statusalso use.
A segment's voice
The Script tab sends {"segment_voices": {"<segment id>": "<voice_id>"}} to give a segment its own
voice, or "" to give it back to the video's voice. It is sent alone, without
onlyIfCurrentStatus. The segments are rewritten and nothing else changes: the spoken words, the
script record and the warnings stay. A voice_id equal to the video's voice is stored as no voice.
| Status | Cause |
|---|---|
200 | The updated row plus comments[] |
400 | Another key in the body, an empty or non-string map, an unknown segment id, or a voice not on the roster |
404 | Video not found |
409 | The video is archived, not at SCRIPT_READY, has no segments, or has no voice on the roster |
409 | {"error", "voice_conflict": true}: the voice cannot speak that segment's markup |
409 | The segments changed between the read and the write. The UPDATE is bound to the segments it read |
POST /videos/<video_id>/switch-style
Takes the runner-up of the style Auto picked (How Auto picks a
style). No body. The video must be at
SCRIPT_READY and hold a style_pick and a style_runner_up. The new script is voiced when it is
approved, so on a video that reached SCRIPT_READY through a revision after it was voiced, voicing
is paid again.
The route runs as one write transaction (BEGIN IMMEDIATE) from its first read to its write, so an
approval, a second switch, a removed key or a GPU probe result waits for it. It clears
resolved_renderer and resolved_visual_style, which belong to the scenes the new script replaces,
and sets visual_style to the runner-up (auto
for scenes), swaps style_pick and style_runner_up, sets style_reason to say a person
switched it, and moves the video to TOPIC_APPROVED. It adds a human comment asking the agent to
rewrite the script for the new style. The agent's next session writes a new script, which replaces
the old one. A second switch goes back. The route also empties formula_pick, formula_runner_up,
formula_reason and formula_evidence, so the formula is picked again for the new style.
| Status | When |
|---|---|
200 | The switch landed. The body is the video |
404 | No such video |
409 | The video is archived, not at SCRIPT_READY, has no Auto pick or no runner-up, the runner-up is not a style any more or this install cannot make it (with the reason), or the video changed while the request was in flight |
POST /videos/<video_id>/switch-formula
Takes the runner-up of the formula picked for the video
(How a formula is picked). No body. The video
must be at SCRIPT_READY and hold a formula_pick and a formula_runner_up.
The route runs as one write transaction. It swaps formula_pick and formula_runner_up, sets
formula_choice to the new pick (the formula is now a person's choice, so the agent cannot replace
it), sets formula_reason to say a person switched it, empties formula_evidence (it was about the
formula switched away from), and moves the video to TOPIC_APPROVED. It
adds a human comment asking the agent to rewrite the script in the new formula. The stored script
is left as it is until the agent's next session replaces it, because the route has no way to
rewrite a script. A second switch goes back. An experimental runner-up needs no setting.
| Status | When |
|---|---|
200 | The switch landed. The body is the video |
404 | No such video |
409 | A refusal listed below the table |
409 causes: the video is archived or not at SCRIPT_READY; it has no pick or no runner-up; the
runner-up is a formula this version does not have; the video is on auto with no style_pick
(scripted before styles were picked ahead of the script); or the video changed while the request
was in flight.
POST /videos/<video_id>/switch-opening
Has the script rewritten from another of the openings the agent drafted
(What a script records). Body {"index": n},
the opening's place in hook_alternatives, from 0. The video must be at SCRIPT_READY.
The route runs as one write transaction. It marks that opening kept in hook_alternatives,
clears its note, sets hook_type to its type and moves the video to TOPIC_APPROVED. It adds a
human comment that quotes the opening and asks the agent to rewrite the script from it, word for
word, in the same formula. The stored script is left as it is and its formula_id is cleared,
because the script now starts with another opening than the one its record names. formula_pick is kept, or
set to the script's formula_id on a video scripted before formulas were picked, so the rewrite is
not routed to another formula whose opening types differ.
| Status | When |
|---|---|
200 | The switch landed. The body is the video |
400 | index is not a whole number, or is outside the stored openings |
404 | No such video |
409 | A refusal listed below the table |
409 causes: the video is archived or not at SCRIPT_READY; it has no stored openings; the
opening is the one already in use; the script has no pick and a formula_id this version does not
have; the video is on auto with no style_pick; or the video changed while the request was in
flight.
POST /videos/<video_id>/agent-outcome
The poller calls it after every pipeline session with
{"start_status": "<STATUS>", "session_key": "<key>"}. session_key is optional.
This route decides whether the session made progress, because the agent CLIs' exit codes do not
(see The Poller). It runs one UPDATE:
- If the status differs from
start_status,agent_no_progress_countresets to 0. - If the status is unchanged, the count goes up by one. At 3 (
AGENT_NO_PROGRESS_CAP) the route stampsagent_stuck_atand writes oneagentcomment that explains how to hand the video back. updated_atis not changed, because it orders the poller's queue and times a stalledVOICING.- A report with the
session_keyof the last counted report (agent_last_outcome_key) changes nothing and answers"replayed": true. This covers a session that two poller processes report. A report with no key is counted each time. - An archived video is reported as it stands and is not counted.
| Status | Cause |
|---|---|
200 | {"status", "count", "stuck", "replayed"} |
400 | start_status is missing or invalid, or session_key is not a string of 1 to 100 characters |
404 | Video not found |
POST /videos/<video_id>/agent-retry
The dashboard's Retry agent. It resets agent_no_progress_count to 0 and clears
agent_stuck_at without changing the status, so the poller picks the video up on its next pass.
200 with the row plus comments[]. 404 for an unknown video. 409 for an archived one.
POST /videos/<video_id>/comments
Body {author, content}. author defaults to "human" and must be "human" or "agent".
201 {"ok": true}. 400 for an empty content or a bad author. 404 for an unknown video.
The route does not check the video's status. The dashboard calls it from Request Revision (see Dashboard). The MCP server, the worker and the render gateway write their comments straight to SQLite.
DELETE /videos/<video_id>
Deletes the video's rendered mp4 and its job directory, clears video_path, sets archived_at and
leaves a human comment. The API has no hard delete. The worker's retention sweep runs the same
operation (pipeline.py::archive_video).
| Status | Cause |
|---|---|
200 | {"ok": true, "archived_at", "file_errors": []}. A file that could not be removed is listed, and the row is archived anyway |
404 | Video not found |
409 | Already archived. The body carries archived_at |
409 | {"error", "current"}: the status is not in DELETABLE_STATUSES |
A video cannot be deleted at VOICING, RENDER_QUEUED, RENDERING or PUBLISHING (something is
working on it), at SCHEDULED (a post will go out), or at VOICE_READY or REVISION_REQUESTED.
An agent can hold a scene-work claim at the last two, and that claim exists only inside the MCP
process, so the API blocks both statuses for every video. The status check is part of the archiving
UPDATE, so it cannot race a render claim.
GET /retention/backlog
What unpublished_retention_days would free: every FAILED and TOPIC_REJECTED video that is not
archived, whatever its age and whether or not the setting is on. Read-only.
{"failed": {"count": 3, "bytes": 1073741824}, "rejected": {"count": 12, "bytes": 0}}
bytes is the rendered mp4 plus everything under the job directory. A missing or unreadable file
counts as 0. So does a job directory that is not a direct child of the jobs directory, because
video ids are supplied by callers. See Video retention.
GET /storage
How much disk Tubematic uses, for the disk figure in the dashboard's top bar. Read-only.
{"data": {"measured_at": "2026-11-09T10:00:00Z", "total_bytes": 4400000000,
"items": [{"key": "videos", "bytes": 3221225472}, {"key": "voice_previews", "bytes": 2097152},
{"key": "jobs", "bytes": 1073741824}, {"key": "scenes", "bytes": 5242880},
{"key": "database", "bytes": 41943040}, {"key": "mascots", "bytes": 0},
{"key": "backups", "bytes": 209715200}, {"key": "logs", "bytes": 62914560}]},
"host": {"measured_at": "2026-11-09T09:40:12Z",
"images": {"current_bytes": 5000000000, "old_bytes": 4500000000, "old_count": 2},
"containers_bytes": 31457280, "build_cache_bytes": 2000000000, "install_bytes": 943718400},
"total_bytes": 14875176000}
| Field | Notes |
|---|---|
data | The API's own mounts, counted the way du counts: allocated blocks, a hardlinked file once, symlinks not followed, anything unreadable as 0. Voice previews are left out of videos, and mascot sheets out of database |
host | The host's snapshot, ~/.tubematic-data/data/disk-usage.json, read on each request. null until one is written, and when the file cannot be read. A figure inside it is null when Docker could not be read |
host.images.old_bytes | The sum of each old image's unique size, which is what removing that image alone frees. With two or more old images it is a floor |
host.images.old_count | How many old images there are |
total_bytes | data.total_bytes plus the host's images, container layers and install folder. An images of null adds nothing. The build cache is left out |
- The walk behind
datais cached for 60 seconds (pipeline.py::STORAGE_CACHE_SECS), so open tabs that poll the route share one walk of the jobs tree. - No container has the Docker socket, so the API cannot measure images, the containers' writable
layers or the install folder. The poller writes the snapshot about hourly, and
upgrade.pyand onboarding write it after they change images. See The poller. old_bytesis a floor with two or more old images because a layer that only old images share appears in none of their unique sizes, and Docker reports no per-layer size to add.total_bytesis then a floor too, and the dashboard shows both with "≥".- The build cache stays out of the total because anything else built on the machine shares BuildKit's cache.
- Which images are old is decided by
tubematic_core/disk_usage.py::old_images, the ruleupgrade.pydeletes by. See Old images.
Projects
A project is a domain. Each row carries two derived fields that are not stored: topic_count
(every video filed into it, archived and rejected included) and expired
(topic_count >= topic_cap). See Topic cap.
GET /projects
Every domain, created_at DESC.
POST /projects
Creates a domain or replaces one. 201 with the row. A rule that fails is a 400.
The route writes every column on each call. A caller that changes one field must send the others
back, or they are reset. An omitted status is written as active, so clearing
is_curriculum_seed on a paused domain also resumes it.
| Field | Rule |
|---|---|
name | Required |
id | A string. Defaults to proj_<hex>. A new id must be letters, digits, _ and -, not start with -, and be at most 128 characters |
description | A string of at most 2000 code points. Absent or null stores '' |
is_curriculum_seed | Read as a boolean, default false |
status | active or paused. paused needs is_curriculum_seed |
default_visual_style | auto, a style pack id, or '' for none |
default_voice_id | A roster voice, or '' for the install default |
default_script_profile_id | A READY profile that is not archived, or '' or null for none. Any other non-string, such as false or 0, is refused |
default_mascot_id | '' (inherit the install default), none (no mascot), or a pickable mascot id |
default_agent_id | A live agent's id, or '' for the weighted deal. Absent or null stores ''. Any other non-string is refused |
default_agent_model | One of that agent's models, or '' for the agent's default. Refused without a default_agent_id |
default_agent_effort | One of the five effort levels, or '' for the agent's own level. It needs no default_agent_id |
default_formula_id | A formula id, or '' or null for Auto. An experimental formula is accepted whatever the auto_experimental_formulas setting says |
topic_cap | A whole number from 25 to 750. true, "100" and 100.5 are refused. Absent or null means 100 |
Six checks run only when the value changes, because the dashboard re-sends the whole domain on every edit and a value that became invalid later must not block other edits:
- The
descriptionlength. default_visual_style:illustrated,under_the_hoodandcase_file_storyneed a stored OpenAI key andcartoon_3dneeds a working GPU.default_voice_idon the roster.default_script_profile_idbeingREADY.default_mascot_idbeing pickable, with a working GPU.default_agent_idanddefault_agent_model, as a pair: a new agent is live, and the agent'smodelsholds the model. The stored agent passes when it is sent again, so a model it dropped can be cleared with''while the agent is uninstalled.default_formula_idbeing a formula.
The id of an existing domain is not checked, so a domain filed under an older id stays editable.
The id names the domain's output directory. A topic_cap below the domain's count is accepted and
expires the domain at once.
POST /projects/<project_id>/status
Body {status}. 200 with the row, shaped like GET /projects. 400 for a value other than
active or paused. 404 for an unknown domain. 409 for paused on a domain that is not a
curriculum seed. See Domain pause.
Settings
How settings are stored, typed and masked is in Settings internals. The keys are
pipeline.py::SETTINGS_SPEC.
GET /settings
Every declared key, coerced to its type, with secret keys masked.
POST /settings
Body: any subset of the declared keys. The response is the full settings object, masked like GET.
- An unknown key returns
400 {"error": "Unknown settings: [...]. Valid: [...]"}. - The write is atomic. Every value is coerced first (
pipeline.py::_coerce_setting), and the first failure returns400with nothing written. - A
secretvalue equal to the mask of the stored value is dropped before coercion, so a client canGET, edit one field andPOSTthe whole object back (see Masking). A mask-shaped string posted against an empty key is stored as sent. - A changed
default_mascot_idmust be pickable and needs a working GPU, or the answer is400. - A non-empty
discord_webhook_urlis probed with an unauthenticatedGET, which sends no message. A definitive rejection returns400. An unreachable Discord stores the URL.
POST /voices/<voice_id>/preview
Generates an ElevenLabs sample of a roster voice with that voice's own model, or replays a cached
one. An optional body {"model_id": ..., "speed": ...} names another model or speed, which lets the
Settings page play a change before it is saved. Without speed, the voice's stored speed is used,
or 1.0 when the model named does not honour speed. A missing or non-JSON body is accepted.
| Status | Cause |
|---|---|
200 | {path, cached, credits}. credits is the plan credits the generation spent, 0 for a cache hit |
400 | voice_id does not match [A-Za-z0-9_-]+ or is not on the roster, model_id is not a supported model, or speed is out of range or set on a model that ignores it. No ElevenLabs call is made |
503 | No ElevenLabs key is configured |
502 | ElevenLabs rejected the request, or the call failed |
The cache file name is a hash of the voice id, the model, the speed (left out at 1.0) and the sample
text. A voice whose model or speed changes therefore gets a new sample, and the typed voice_id
does not reach a file path. A cache
hit makes no outbound call.
A generated preview is recorded in the usage ledger with no video, with credits from ElevenLabs'
character-cost header. It appears in the Analytics page's Spend tab. See
Voice previews.
GET /visual-styles
Returns {"styles": [...]}: auto first, then every style pack
in its pack order. Each entry has id, label, experimental, canvas (the canvas the style fixes,
or null), needs (openai_key, gpu), mascot (false when the style's videos take no mascot),
and available with unavailable_reason for this install
now: needs an OpenAI key, needs a working GPU or GPU not tested yet. The dashboard builds its
style pickers from it. The write routes still refuse an unavailable style themselves.
GET /script-formulas
Returns {"formulas": [...], "hook_types": [...]} from the
formula files. Each formula has id, label, family, line,
words ([min, max]) and experimental, in formula order. Each hook type has id and label. The
dashboard uses it to label a video's formula and hook_type and to build its formula pickers.
GET /angle-kinds
Returns the kinds a topic's angle can be, as a list in
ANGLE_KINDS order. Each entry has id, label and means: what a topic must hold for an angle
of that kind. The dashboard uses it to label a video's angle_kind and to fill the kind pickers.
Research
Research modes
| Route | Behaviour |
|---|---|
GET /research/strategies | {"strategies": [...], "mining_available": bool} from settings.active_strategies |
POST /research/strategies | Body {"strategies": [...]}. Values must be curriculum, trending or mining, else 400. Returns {"strategies": [...]} |
While no Gemini key is stored, mining_available is false and GET leaves mining out. The
stored row is not changed, so adding a key brings mining back. In that state a POST that contains
mining is a 400 and writes nothing. Any other POST keeps a stored mining, because the
caller saw the filtered list.
Mining sources
| Route | Behaviour |
|---|---|
GET /research/mining-sources | {"youtube_urls": [...]} |
POST /research/mining-sources | Body {"youtube_urls": [...]}. Replaces the list. [] clears it. 200 with the stored list |
The API stores the mining sources and does not mine. Mining runs through the MCP server's
mine_youtube_topics (see The MCP Server).
Each stored URL becomes the file_uri of a paid Gemini request, so every entry is checked by
tubematic_core/youtube.py::check_mining_sources. This route and the MCP server's
set_mining_sources and mine_youtube_topics all call it.
- An entry must be a YouTube video URL:
youtube.com/watch?v=<id>,youtu.be/<id>,youtube.com/shorts/<id>oryoutube.com/live/<id>, withwww.orm.allowed and an 11-character id. - Each is stored as
https://www.youtube.com/watch?v=<id>. Two URLs for one video are stored once. 400if the body's value is not a list, if any entry is not such a URL, or if more than 50 distinct videos remain. The error names every bad entry and nothing is stored.
The limit of 50 bounds the list. max_mining_per_run bounds the Gemini calls of one run.
POST /research/record-run
Appends the current time to the rolling 24-hour window and returns
{research_runs_today, max_research_runs_per_day}. It always succeeds.
The API reports the research caps and does not enforce them. GET /pipeline/status returns
research_pending_cap and max_research_runs_per_day, and scripts/poll.py compares the numbers
before it starts an agent (see The Poller). The poller records a run before it
starts the agent, so a run that fails still counts against the cap.
Agents
The installed coding agents (see Database and
The Agent Layer). python3 onboard.py --install-agent <name> on the
host creates a row and sets its binary, workspace and models, because it checks them against the
real CLI and no container has an agent binary. Over HTTP you can set four fields.
GET /agents
Every row ordered by created_at then id, with models parsed to a list and is_default as a
boolean. Uninstalled rows are included, because the dashboard labels videos still pinned to one.
The poller reads this route on every pass.
PATCH /agents/<agent_id>
Body: any of is_default, weight, default_model and effort. 200 with the updated row.
404 for an unknown agent. 409 for an uninstalled one. 400 when the body is not a JSON object,
is empty, holds any other key (models included), or a field fails its rule:
is_defaultmust betrue. It clears the flag on every other agent in the same transaction. To clear it, make another agent the default.weightmust be an integer from 0 to 100. A boolean is refused.default_modelmust be one of the agent's installedmodels. It moves that model to the front of the list, because the default model ismodels[0]for the poller, the MCP server and the dashboard. Adding a model needs the host installer, which probes it against the CLI.effortmust below,medium,high,xhighormax. Blank is refused.
The API has no DELETE for agents. python3 onboard.py --uninstall-agent <name> on the host sets
archived_at, clears is_default and removes the skills, commands and MCP registration, which the
API container cannot reach. The row stays, so videos pinned to the agent still resolve it. See
Deployment.
Script profiles
A script profile is a writing style built from YouTube transcripts (see Script profiles).
Reading script profiles
| Route | Response |
|---|---|
GET /script-profiles | Profiles that are not archived, newest first, without markdown and corpus_summary |
GET /script-profiles/pending | Profiles at PENDING or GENERATING, oldest first. The poller reads it |
GET /script-profiles/<id> | The full profile with its markdown. Serves archived profiles too, so a video that references one still resolves. 404 if unknown |
POST /script-profiles
Body {name, urls}. The route fetches each transcript inside the request, one at a time, and
collects per-URL failures without stopping.
| Status | Cause |
|---|---|
201 | The profile at PENDING, plus transcripts_fetched and failures[] |
400 | name is empty, urls is not a non-empty list, or it holds more than 10 URLs |
400 | No transcript could be fetched: {"error", "failures": [...]}. No profile is created |
503 | No youtube_transcript_api_key is configured |
DELETE /script-profiles/<id>
Sets archived = 1 and deletes the profile's stored transcripts. The row is kept.
200 {"ok": true, "archived": true}. 404 if unknown.
POST /script-profiles/<id>/record-attempt
The poller calls it before it starts a profile-building agent.
| Status | Body |
|---|---|
200 | {id, status: "GENERATING", attempt_count}: an attempt was claimed |
200 | {id, status: "FAILED", attempt_count, error}: attempt_count had reached its cap of 2, and the profile is now FAILED |
404 | Profile not found |
409 | {id, status, attempt_count}: the profile is already READY or FAILED |
Transcripts
renderer/api/transcripts.py fetches from https://www.youtube-transcript.io/api/transcripts.
- The key is sent raw in an
Authorization: Basic <key>header, without base64 encoding. - Each request carries one video id.
extract_video_idacceptsyoutu.be/,?v=and&v=,/shorts/,/embed/and a bare 11-character id.- The text is read from
data[0].tracks[*].transcript, then from a flattranscriptfield, and joined into one string. An unrecognised response yields"". - The client has no rate limiting, retry or backoff. The service publishes a limit of 5 requests
per 10 seconds, and one
POST /script-profilesmakes up to 10 calls in a row.
Mascots
A mascot is a library entry whose drawing code an agent writes and a human approves. Creating one
inserts version 1, and each request for changes inserts a new draft version. The draft is the
highest version without approved_at above the approved one. An approved version does not change.
A mascot is pickable once a version is approved and until it is archived, so a failed or pending
revision does not remove the working version.
A video's mascot is set through PATCH /videos/<video_id>. The install
default is the setting default_mascot_id, and a domain's default is default_mascot_id on
POST /projects.
Reading mascots
| Route | Response |
|---|---|
GET /mascots | Mascots that are not archived, built-ins first |
GET /mascots/pending | PENDING and BUILDING mascots, oldest first, each with the draft's change_request. The poller reads it |
GET /mascots/<id> | One mascot plus versions (without their code). Serves archived mascots. 404 if unknown |
GET /mascots/<id>/versions/<version>/sheets/<sheet> | The sheet image. <sheet> is turn, feels or act |
Each mascot carries pickable, draft_version and sheets. sheets has approved and draft,
each null or the API-relative URLs of the sheet files that exist.
A built-in mascot's sheet is a JPEG from its shipped files. Any other is a PNG from the data
directory. The route answers 404 for a missing file and for a symlink.
POST /mascots
Body {description, name, surprise?, agent_id?, agent_model?, agent_effort?, based_on?}. 201
with the mascot at PENDING. A rule that fails is a 400.
nameis required and at most 60 characters. Withsurprise: trueit defaults to "Surprise mascot".descriptionis required unlesssurpriseis true, and is at most 2000 characters.- The agent picks are checked as on
POST /videos/manual. based_onmust be a pickable mascot. TheINSERTrepeats that check, and answers409with nothing created when the mascot was archived meanwhile.- The id is a slug of the name. If another create takes the slug first, the route tries the next
suffix,
pipeline.py::MASCOT_SLUG_ATTEMPTStimes, then answers409.
POST /mascots/<id>/approve
Publishes the draft version and sets READY. 200 with the mascot. 404 for an unknown or
archived mascot. 409 when the mascot is not IN_REVIEW, when the draft has no code, or when one
of its three sheets has not been rendered.
POST /mascots/<id>/request-changes
Body {comment}, required, at most 2000 characters. Adds a draft version and sets PENDING with a
new attempt budget. 200 with the mascot.
| Status | Cause |
|---|---|
400 | comment is missing or too long, or the mascot is built-in. For a variation, create a mascot with based_on |
404 | Unknown or archived |
409 | The mascot is not IN_REVIEW, READY or FAILED, which means an agent is working on it |
POST /mascots/<id>/record-attempt
The poller calls it before it starts a mascot-building agent, and starts no session on a 409.
| Status | Body |
|---|---|
200 | {id, status: "BUILDING", attempt_count, draft_version}. The sheet-render count is reset |
200 | {id, status: "FAILED", attempt_count, error}: the attempts had reached mascots.py::MAX_MASCOT_ATTEMPTS (2). The error names an approved version still in use |
404 | Unknown or archived |
409 | {id, status, attempt_count}: the mascot is not PENDING or BUILDING |
DELETE /mascots/<id>
Sets archived = 1. A built-in mascot can be archived too. The row is kept.
200 {"ok": true, "archived": true}. 404 if unknown.
The three lifecycle routes above write with an UPDATE bound to the status they read and to
archived = 0. An archive or another change that commits after the route read the mascot wins, and
the route answers 409.
Publishing and analytics
These routes publish an approved video now or at a scheduled time, cancel a scheduled post, recover a video that failed while publishing, read performance figures and configure Auto Pilot. What each one does internally is in Publishing internals.
The routes that reach postforme, and POST /publishing/accounts, answer 503 when
publishing_enabled is false or no postforme_api_key is stored. The check runs before any
outbound call. GET /videos/<video_id>/publications, publish-prefill, GET /analytics,
GET /analytics/watch-time and the two /autopilot routes have no such check.
Accounts
| Route | Behaviour |
|---|---|
GET /publishing/accounts | A list: postforme's live accounts reconciled against the allowlist. 502 if postforme cannot be reached |
POST /publishing/accounts | Body {account_ids: [...]}. Replaces the allowlist. 200 {account_ids}. 400 unless it is a list of strings |
POST /publishing/accounts/connect | Body {platform}. 200 {platform, url}: a postforme consent URL that requests posts and feeds. Stores nothing |
An account carries:
| Field | Meaning |
|---|---|
id, platform, username, profile_photo_url, status | From postforme. No other postforme field is passed on |
allowed | The id is on the allowlist |
available | postforme lists the account. An allowlisted id it does not list is returned with available: false and status: "disconnected" |
analytics | true, false or null. false only where postforme rejects a feed read. Probed for allowlisted accounts only |
?feeds=0 skips the feed probe, and every analytics is then null. What the value means is in
What the Socials badges mean.
For connect, platform must be youtube, instagram, tiktok or facebook, else 400 before
any outbound call. 502 when postforme fails (the body carries its message) or its answer holds no
https URL.
Publications and prefill
GET /videos/<video_id>/publications returns the video's publication rows, ordered by platform:
id, video_id, platform, social_account_id, status, post_url, error, published_at,
created_at, updated_at. Each row also carries its latest snapshot: views, likes,
comments, shares, the six watch figures and fetched_at.
They are all null for a row with no snapshot.
POST /videos/<video_id>/publish-prefill is a read that calls no model. It returns
{title, description, duration_secs, youtube_short, youtube_shorts_max_secs}. title and
description are the stored publish_title and publish_description, or the video's own title
and topic when nothing is stored. youtube_short is null when the duration cannot be read. 404
for an unknown video.
POST /videos/<video_id>/publish
Body: account_ids (required, non-empty list), title, description, privacy (an object keyed
by platform) and an optional schedule: {local: "YYYY-MM-DDTHH:MM", timezone: "<IANA>"}. A blank
title falls back to the video's title or topic.
| Status | Cause |
|---|---|
201 | {status, postforme_post_id, scheduled_at, scheduled_timezone, publications}. status is SCHEDULED or PUBLISHING |
400 | A malformed body, an account off the allowlist, no rendered mp4, an unsupported privacy value, or a bad schedule |
404 | Video not found |
409 | The video is archived or not at VIDEO_APPROVED, or a concurrent request took the claim |
502 | postforme rejected the request or could not be reached. With "reconciling": true, the post may exist and the video stays PUBLISHING |
A schedule is bad when its zone is unknown, its time is malformed or falls in an hour the clocks skip, or it is less than 5 minutes or more than 365 days ahead.
POST /videos/<video_id>/publish/retry
No body. Accepts a FAILED video that has publication rows.
| Status | Cause |
|---|---|
200 | {outcome, status}. reconciling: a live post exists and the video is back at PUBLISHING. republish: none exists and the video is back at VIDEO_APPROVED |
404 | Video not found |
409 | Archived, not FAILED, FAILED without publication rows, or a concurrent retry took the claim |
502 | postforme could not be asked. Nothing changes |
POST /videos/<video_id>/schedule/cancel
No body. Deletes the post at postforme and returns the video to VIDEO_APPROVED.
| Status | Cause |
|---|---|
200 | {"status": "VIDEO_APPROVED"} |
404 | Video not found |
409 | Not SCHEDULED, postforme has started sending the post, or the video changed status meanwhile |
502 | postforme failed, answered success: false, or still lists a post it could not find. The post is still scheduled, and the cancel can be tried again |
Analytics
GET /analytics is served from local snapshots and does not call postforme. The optional query
parameters platform and social_account_id filter every part of the response.
| Field | Meaning |
|---|---|
totals | views, likes, comments, shares, publications, videos |
by_platform | The four metrics summed per platform. An unreported metric adds 0 |
publications | Each published row with its latest views, likes, comments, shares (null when unreported), fetched_at, the video's title and the watch figures avg_watch_secs, watched_pct, stayed_pct, engaged_views, reach and saves (null when unreported, see Watch figures) |
by_month | [{month: "YYYY-MM", views}]: views gained in each of the last 12 months, oldest first. Months before any snapshot are left out. A figure can be negative |
timezone | The zone the months were cut in (the host's, or UTC) |
GET /analytics/watch-time returns one account's watch figures by group, from local snapshots.
The optional social_account_id selects the account. Without it the answer is for the account with
the most published posts.
| Field | Meaning |
|---|---|
accounts | [{id, platform, videos}]: every account with a published post, the largest first |
social_account_id, platform, videos | The account answered for and its number of published posts. '' and 0 when nothing is published |
min_group | A group with fewer videos is too small to read (20) |
dimensions | [{id, label, groups}] for visual_style, script_profile, domain, script_length, formula and hook_type |
Each group is {key, label, videos, avg_watch_secs, watched_pct, stayed_pct}. Each measure is
{median, n}: the median over the n posts that report it, and median is null when n is 0.
How posts are grouped is in Publishing internals.
POST /analytics/refresh captures metrics for every account now and returns
{accounts, snapshots, errors}. It first stores videos.duration_secs for published videos that
have none (Watch figures).
Auto Pilot
GET /autopilot returns:
| Field | Meaning |
|---|---|
enabled, gap_mins | auto_pilot_enabled and auto_pilot_gap_mins |
max_in_flight | auto_pilot_max_in_flight. 0 means no limit |
in_flight | Videos in progress, as the in-progress limit counts them |
projects | {project_id: [account_id, …]}. A domain that is a key is on Auto Pilot. Its list may be empty |
account_limits | {account_id: posts per day}, for accounts that have been set |
default_daily_limit | What an account with no entry gets |
waiting | {project_id: {status: count}} for videos at TOPIC_PROPOSED, SCRIPT_READY, VIDEO_READY and VIDEO_APPROVED. The dashboard's confirmation counts from it |
POST /autopilot requires enabled, gap_mins, projects and account_limits, and returns the
same document as GET. max_in_flight is optional, and the stored limit is kept without it. The
body is validated whole and written whole.
400 causes:
enabledis not a boolean.gap_minsis outside 0 to 10080, ormax_in_flightis outside 0 to 500.projectsis not a map of project id to a list of account ids, or names a domain that does not exist.- An account newly added to a domain is not on the allowlist.
- A daily number is not a whole number from 0 to 50.
Costs
The read side of the usage ledger and the price table behind it. Every dollar figure is an API list price and ignores subscriptions and plan credits. ElevenLabs is reported in plan credits. Where rates come from is in Settings.
GET /videos/<video_id>/costs
{has_usage, lines, agent, total_usd, credits, unpriced_calls}.
linesgroups calls that are not agent sessions by service, model and operation. Each hascalls,cost_usd(nullwhen none were priced),credits,unpriced_callsandestimated.agentisnullor{models, share_usd, session_total_usd, shared, estimated, sessions[]}. Each session carriesstage,batch_size,total_usdand this video'sshare_usd.total_usdadds the agent share and leaves out the rest of a shared session.
GET /usage/summary
Spend for a range. Send one of three forms:
| Form | Meaning |
|---|---|
?preset=today, week or month | Resolved by the API, ending today in the host time zone. A week starts on Monday |
?from=YYYY-MM-DD&to=YYYY-MM-DD | Inclusive days in the host time zone |
?since=<ISO timestamp> | Open-ended. Defaults to the start of the current UTC month |
For the first two forms the response echoes from, to, until and the timezone the days were
cut in (UTC when the host zone cannot be named or loaded). until is exclusive. Each end is
converted at its own local midnight, so a range across a DST switch is not off by an hour. The
dashboard sends presets by name, because its copy of the host zone is UTC until it loads.
Response fields: since, until, total_usd, videos, research, agent_other, other,
video_count, unpriced_calls, voice_credits, preview_credits, estimated and
elevenlabs_pool. elevenlabs_pool is {tier, used, limit, resets_at_unix}, or null when the
key lacks the optional user_read permission or the call fails.
400 causes: more than one form, an unknown preset, a from without a to or the reverse, a
date that is not a real YYYY-MM-DD day, from after to, a malformed since, or a range whose
UTC boundaries a datetime cannot hold (such as to=9999-12-31).
POST /usage/agent-session
How an agent session's usage reaches the ledger. The poller has no database access, so it parses each session's JSON output and posts it here (see The Poller).
{"session_id": "…", "operation": "agent_pipeline", "agent": "claude",
"videos": [{"video_id": "vid_abc", "stage": "TOPIC_APPROVED"}],
"events": [{"service": "…", "model": "…", "units": {}, "raw": {},
"reported_cost_usd": 0.12, "estimated": false}]}
operationmust beagent_pipeline,agent_research,agent_profile,agent_mascotoragent_unscoped.- Every event is recorded against every listed video. The poller lists one video for a pipeline
session, with
stageset to the status the session started at. 200 {recorded, events}. Arecordedbeloweventsmeans some events were not recorded.400for an unknownoperation, a missingsession_id, or aneventsvalue that is not a list of 1 to 50 entries.- The write is idempotent per
session_idand event position. A payload resent after a timeout records nothing twice and still counts those events asrecorded.
Every other paid call is written to the ledger by the process that made it.
Prices
| Route | Behaviour |
|---|---|
GET /prices | {models, unpriced, unit_kinds, last_sync_attempt_at, last_sync_ok_at, last_sync_error} |
POST /prices/sync | Runs the price sync now. 200 {ok, updated, rejected, missing, error} |
POST /prices/override | Body {service, model, rates: {unit_kind: usd_per_token}}. 200 {ok, repriced} |
DELETE /prices/override?service=&model= | Drops a manual rate. 200 {"ok": true}. 400 without both parameters |
- Each entry in
modelshasservice,model,rates(USD per token),source(manual,openrouter,litellm,built-inornull),tieredandeffective_from. unpricedlists models with unpriced calls and how many.- A failed sync is a
200withok: falseand keeps every existing price. - A sync does not overwrite a manual rate. Setting one prices that model's unpriced calls, and calls that already have a price keep it. Without one the model uses its synced or built-in rate.
POST /prices/overrideanswers400for a missing name, an unknown unit kind, a rate that is not positive, an emptyrates, orservice: "elevenlabs".
Renderers
The routes behind the dashboard's Renderers panel (Settings → Rendering). They cover every machine that renders, the built-in renderer included, and they use the API token. How renderers are scheduled and added is in GPU and Remote Renderers.
GET /renderers
200 {"remote_enabled", "gateway_address", "renderers": [...]}.
gateway_addressis the settings rowrender_gateway_address, ashost:port. Onlypython3 onboard.py --step rendererswrites it.remote_enabledis whether it holds an address.renderersholds every renderer that is not removed, the built-in one first. The route creates the built-in row again if it is missing.
Each entry is tubematic_core/renderers.py::renderer_states plus the fields
pipeline.py::renderer_list adds. No credential hash is returned.
| Field | Meaning |
|---|---|
id, name, builtin, enabled | id is builtin for the built-in renderer and r_<hex> for an enrolled one |
online | A heartbeat arrived within the last 120 seconds |
state, current_video_id, current_video_title | idle or rendering as last reported, and that video's title (its topic when it has none) |
version, needs_upgrade | The version last reported. A version other than the main install's sets needs_upgrade, and that renderer claims nothing |
gpu_verified, gpu_probed, gpu_configured, gpu_error | From its last GPU probe: whether it passed, whether one exists, whether a GPU was configured, and why it failed |
gpu | null before the first probe, else {ok, configured, error, renderer, name, at}. renderer is the WebGL renderer string Chromium reported |
probe_pending, waiting_for_render | A test was requested and no probe has started since. waiting_for_render adds that the renderer is rendering, which it finishes first |
compute, host | As reported: {cpus, memory_bytes, gpus: [{name, uuid, memory_mb}]} and the renderer's host name |
last_heartbeat_at, last_error, created_at | As stored |
credential_expires_at | '' for the built-in renderer, whose credential does not expire |
POST /renderers/enrollments
Issues a one-time enrollment token, valid for one hour. Body
{"name"}, optional: 1 to 60 characters after trimming. Blank or absent means no name.
| Status | Cause |
|---|---|
201 | {"token", "expires_at", "command"} |
400 | The body is not an object, or name is not a string of 1 to 60 characters |
409 | {"error": "remote_renderers_off"}: no gateway address is stored |
503 | {"error": "gateway_certificate_missing"}: the pin cannot be computed |
The token appears in this response only. The database keeps the hash of its secret. command is
python3 tubematic_remote_renderer.py install and does not contain the token: the script asks for
it with a hidden prompt, because a command line is visible to other users of the machine and is
kept in shell history.
PATCH /renderers/<id>
Body with enabled (a boolean), name (1 to 60 characters), or both. 200 with the updated
renderer. 400 for a body with neither, or a bad value. 404 not_found for an unknown or removed
id. A disabled renderer still sends heartbeats and claims nothing. The built-in renderer can be
disabled.
DELETE /renderers/<id>
200 {"id", "removed_at"}. Sets removed_at and clears both credential hashes, so the renderer's
next heartbeat gets 401. The worker's lease sweep re-queues a render it held once the lease runs
out. 409 {"error": "builtin"} for the built-in renderer. 404 not_found.
POST /renderers/<id>/gpu-test
Stamps the renderer's gpu_probe_requested_at. Its next heartbeat reply carries probe_now, and
it tests between renders. 202 with the renderer, probe_pending: true. The result arrives in a
later GET /renderers. 404 not_found.
GPU rendering
The API container has no GPU. Each renderer tests its own and reports the result through the render gateway, which stores it on the renderer's row (see The GPU test).
| Route | Response |
|---|---|
GET /render/gpu | 200 with the fields below |
POST /render/gpu/test | The built-in renderer's form of POST /renderers/<id>/gpu-test. 202 with the same body, pending: true |
| Field | Meaning |
|---|---|
status | Install-wide, across every renderer: working, unknown, not_usable or not_configured |
rendering_on | gpu when the built-in renderer's own last test passed, else cpu |
configured, gpu | Whether the built-in renderer was given a GPU, and its {uuid, name} |
host_gpus | Each NVIDIA GPU the host had when onboarding's gpu step ran: index, uuid, name, memory_mib, driver |
probe | The built-in renderer's stored probe, or null |
requested_at, pending | The last test request, and whether no probe has started since |
waiting_for_render | pending, and the built-in renderer holds a render it has not uploaded |
status is computed by tubematic_core/renderers.py::gpu_status:
working: an enabled renderer's GPU test passed.unknown: no test has passed and an enabled renderer has not tested yet.not_usable: a GPU is configured and its test failed, so renders use the CPU.not_configured: none of the above.
Every field except status describes the built-in renderer, the one renderer that onboarding's
gpu step configures. status is the aggregate because the Cartoon 3D and mascot checks read it,
and a check on the built-in renderer alone would refuse a style that another renderer can render.
Pipeline control
POST /pipeline/pause
Body {"paused": <bool>}. 200 {"paused": …}. 400 unless paused is a boolean.
GET /pipeline/status
The poller reads it to decide what to start, and the dashboard reads it on load.
| Field | Meaning |
|---|---|
paused | The pipeline_paused setting |
video_counts, workable_count, proposed_count | Counts per status, the sum over WORKABLE_STATUSES, and the count at TOPIC_PROPOSED |
active_strategies, mining_available | The active research modes. mining is left out while no Gemini key is stored |
research_pending_cap, max_research_runs_per_day | The two caps the poller compares against |
research_runs_today, research_window_resets_at, last_research_at | The rolling 24-hour run window and the last completed research |
pending_script_profiles, pending_mascots | How many wait for an agent |
timezone, timezone_label | See Time |
version | The installed version, from tubematic_core/version.py::version |
github_repo | tubematic_core.version.GITHUB_REPO, for the dashboard's update check |
The poller builds its research prompt from active_strategies, so a run is not told to mine
without a key.
Logs
GET /logs
Structured log records, newest first. The dashboard has no log mount and no Docker socket, so this route is its only access to the logs.
| Parameter | Default | Notes |
|---|---|---|
service | all | api, mcp, worker, renderer or poll. Any other value is a 400 |
level | all | A minimum: warning also returns errors. An unknown level is a 400 |
video_id | none | Exact match |
profile_id | none | Exact match |
q | none | Case-insensitive substring, matched against the whole record |
limit | 200 | 1 to 2000. A non-integer or out-of-range value is a 400 |
{
"records": [
{"ts": "2026-09-06T14:20:10Z", "service": "renderer", "level": "info",
"message": "render complete", "video_id": "vid_abc"}
],
"count": 1,
"limit": 200,
"services": ["api", "mcp", "worker", "renderer", "poll"],
"levels": ["debug", "info", "warning", "error"]
}
servicesandlevelsare echoed so a client can build its filter lists from the response.- A record carries
video_id,profile_idandrequest_idwhen the writer had them. - With no
service, the route reads every service's files. The video modal's Logs tab sendsGET /logs?video_id=…, because one video's records are spread over all of them. - A file name is built from an allowlisted service name and a date, so nothing from the request reaches a path. A malformed line is skipped, because a file being appended to can end in half a line.
- The route deletes no file. Retention is the writers' job (see The log files).
The render gateway
The gateway is a second Flask app in the same process, on HTTPS port 4443 under /v1. Renderers
use it to claim a video, download its files, upload the mp4 and report the result. It accepts
renderer credentials only. Its routes, TLS pin, enrollment tokens, credentials and limits are in
The Render Gateway.
Code layout
renderer/api/server.pybuilds the app, registers the pipeline and login blueprints, installs the token check and starts the render gateway in a thread.renderer/api/db.pyprovidesconn(),set_status(),update_fields()andadd_comment(), with WAL mode, foreign keys on and asqlite3.Rowfactory. The worker, the render gateway andrender_results.pyuse it.pipeline.pydefines its own connection helper.- The API stores and returns the path columns as opaque strings and no code reads a location from
them (see Database). The dashboard builds a video's
/stream/…URL from its ids (dashboard/lib/utils.ts::videoStreamUrl) and converts the/output_videos/…path from the voice preview route withvideoToStreamUrl.
Known quirks
| Behaviour | Detail |
|---|---|
| An empty research-mode list is stored as empty | POST /research/strategies with [] stores "", which reads back as [], so the poller skips research. The three-mode default applies only when the row is absent |
| Unhandled exceptions return HTML | No JSON error handler is registered. A malformed body, a foreign-key violation or a corrupt stored settings value produces Werkzeug's HTML page in place of {"error": …} |
| The freeze rule tests presence | {"script_profile_id": ""} on a video past TOPIC_PROPOSED returns 409, although "" is a legal value. So does agent_id set to the video's own agent between checkpoints |
openai_api_key is checked for presence only | The API checks that a key is stored before it accepts illustrated. A revoked key is found later, when the MCP server's generate_image or generate_character uses it |