clipwright/skills/openshorts/reference.md
pedro-bento 4e82d60cbc fix: harden Postiz integration and align docs/CLI/n8n after review
- Postiz URL is now required (no built-in host); a key can never be sent to a default instance
- /api/postiz/scheduled normalizes scheduled_date and widens the default window
- Disabled channels are refused for posting; frontend excludes them from connected platforms
- 4xx instead of 500 on missing clip URL / bad schedule date; Postiz error bodies truncated
- Add tests/test_postiz.py (24 tests); fix remaining cloud-removal test drift
- CLI defaults to localhost:8000; n8n workflows fixed against the real routes
- Remove dead media-token auth code, stale copy (download_url/402) and doc drift
2026-10-04 17:25:17 +01:00

4.6 KiB

OpenShorts HTTP reference

Base URL: http://localhost:8000 (self-hosted). The API is open by default and needs no key, but it does need a Gemini key, either in the server's environment or as an X-Gemini-Key header.

Start a job

POST /api/process, JSON body for a URL source (use multipart form fields with a file part to upload a local video instead):

{
  "url": "https://www.youtube.com/watch?v=...",
  "acknowledged": true,
  "layouts": ["auto"],
  "output_format": "auto",
  "target_clips": 4,
  "clip_min_seconds": 15,
  "clip_max_seconds": 60,
  "webhook_url": "https://example.com/hooks/openshorts",
  "webhook_secret": "change-me",
  "force_low_quality": false
}

acknowledged: true is the rights attestation and is required. layouts accepts a JSON list or a comma separated string of auto, split, screencast, speaker_cut, punch_in. output_format is one of auto, vertical, horizontal, square. target_clips is 1 to 15; clip_min_seconds 5 to 175; clip_max_seconds 10 to 180 and at least 5 above the minimum.

Success:

{ "job_id": "0f0a...", "status": "queued" }

Quality gate, also HTTP 200:

{ "needs_confirmation": true,
  "quality_check": { "max_height": 480, "min_height": 720, "cookies_invalid": false } }

Ask the user, then resubmit the identical body with force_low_quality: true.

Errors: 429 too many jobs already running (MAX_CONCURRENT_JOBS), 400 the source duration could not be determined.

Poll a job

GET /api/status/{job_id} returns {"status": ..., "logs": [...], "result": ...} where status is queued, processing, completed or failed. result.clips appears once completed, each entry carrying title, video_title_for_youtube_short, video_description_for_tiktok, video_description_for_instagram, start, end and video_url. A relative video_url is relative to the API base.

Poll every 30 to 60 seconds. Prefer a webhook.

Webhook

Fired once per job, on success and on failure, so a flow never hangs:

{
  "event": "job.completed",
  "job_id": "0f0a...",
  "status": "completed",
  "clips": [ { "index": 0, "title": "...", "video_url": "..." } ]
}

A failed job sends "event": "job.failed" with an error string and no clips. Each clip carries video_url, relative to the instance unless the server sets PUBLIC_API_URL.

The URL must be public HTTPS; it is validated at submit time and re-resolved at delivery time, so a URL that points at a private address is refused. With a webhook_secret, the raw request body is signed HMAC-SHA256 and sent as X-OpenShorts-Signature: sha256=<hex>. Verify against the raw bytes, not against a re-serialized object:

const crypto = require('crypto');
const expected = 'sha256=' + crypto
  .createHmac('sha256', secret)
  .update(rawBody)
  .digest('hex');

Restyle captions

POST /api/subtitle

{ "job_id": "...", "clip_index": 0, "style": "karaoke", "position": "bottom",
  "font_size": 48, "font_name": "...", "font_color": "#FFFFFF",
  "highlight_color": "#FFE600", "uppercase": true }

style is classic or karaoke; position is top, middle or bottom. Only job_id and clip_index are required.

Re-cut a clip

POST /api/clip/rerender

{ "job_id": "...", "clip_index": 0,
  "segments": [ { "start": 812.4, "end": 831.0 }, { "start": 840.2, "end": 858.9 } ],
  "snap_to_words": true, "reapply_captions": true, "framing": "auto" }

Times are seconds in the original source video. Segments concatenate in the order given. framing is auto, full (no side cropping) or track (force subject tracking); omit it to keep the clip's current framing. Anything outside the clip's original range, or any non-auto framing, re-runs the reframe engine and needs the retained source video.

Publish

POST /api/postiz/post

{ "job_id": "...", "clip_index": 0, "platforms": ["tiktok", "instagram", "youtube"],
  "title": "...", "description": "...",
  "scheduled_date": "2026-08-25T18:00:00Z", "timezone": "Europe/Madrid" }

Omit scheduled_date to post now. The backend uploads the clip bytes to your self-hosted Postiz instance and creates the post there; the provider settings (tiktok, instagram, youtube) are built from the title and caption.

Connected channels: GET /api/postiz/integrations.

Queue: GET /api/postiz/scheduled, and DELETE /api/postiz/scheduled/{id} to cancel one before it goes out.

Analytics of what was published: GET /api/postiz/analytics (channel totals) and GET /api/postiz/analytics/posts.

Full generated API docs: http://localhost:8000/docs.