# Automate Replish with an agent and Postiz This guide sets up a loop that runs without you: an agent finds clips on Replish, renders them as vertical shorts with your own text, and posts them to TikTok, YouTube Shorts and Instagram Reels through [Postiz](https://postiz.com). ``` Replish (find clip) -> Replish (render 9:16 + your text) -> MP4 -> Postiz (upload + post) -> TikTok, Shorts, Reels ``` ## What you need | | Where | |---|---| | A Replish plan | `/pricing`. Agent access (API and MCP) is included in every plan. | | A Replish API key | `/account`, section "Agent access". Shown once: store it in a password manager or a secret store. | | A Postiz account with your channels connected | Postiz Cloud or self-hosted. Connect TikTok, YouTube, Instagram... under Channels. | | A Postiz API key | Postiz, Settings, Developers. | Set four environment variables where your agent runs. Never paste the keys in a prompt, a URL or a file you commit. ```bash export REPLISH_URL="https://" export REPLISH_KEY="rp_live_..." export POSTIZ_KEY="..." export POSTIZ_URL="https://api.postiz.com/public/v1" # self-hosted: https:///api/public/v1 ``` ## Limits to plan around - Replish: your monthly video quota is shared between the website and the API (a failed render does not count). One render per key at a time: wait for the first to finish before starting the next. 2000 API requests a day per key. Past a limit you get 429 with `Retry-After`. - Replish: when the plan ends, the key answers 402 `plan_required` until you renew. - Postiz: the create-post endpoint allows about 90 to 100 calls an hour. Upload the MP4 first (`POST /upload`), then reference its `id` and `path` in the post. - TikTok through Postiz: `content_posting_method: DIRECT_POST` publishes. `UPLOAD` only sends the video to the TikTok app inbox, where you must finish it by hand within 24 hours. ## Option 1: the ready-made script [`replish_to_postiz.py`](replish_to_postiz.py) does the whole loop in one command. It needs Python 3.10+ and `httpx` (`pip install httpx`). ```bash # 1. Find the ids of your Postiz channels python replish_to_postiz.py --list-channels # 2. One short from the rising GTA 6 clips in English, saved as a Postiz draft so you can review it python replish_to_postiz.py --channels , --cat grand-theft-auto-vi --lang en \ --footer "Follow for daily GTA 6 clips" --watermark "@myclips" --tags "#gta6 #twitch #gaming" # 3. When the drafts look right: schedule them at each channel's next free time slot python replish_to_postiz.py --channels , --cat grand-theft-auto-vi --lang en \ --footer "Follow for daily GTA 6 clips" --watermark "@myclips" --mode schedule --count 3 ``` What it does, in order: 1. Takes the candidates: the rising feed (`GET /v1/clips`, filtered by `--cat`, `--lang`, `--platform`, `--window`), or a streamer's or a game's top clips (`--streamer xqc`, `--game "Just Chatting"`, `--period day`). 2. Skips clips it already posted (kept in `replish_posted.json`). 3. Renders the clip (`POST /v1/renders`) with your text: `--hook` at the top (default: the clip title), `--footer` at the bottom, `--watermark` (your handle). Polls every 5 s, then downloads the MP4 with your key. 4. Uploads the MP4 to Postiz (`POST /upload`) and creates one post per channel (`POST /posts`) as a draft, scheduled at the channel's next slot (`GET /find-slot/{id}`), or published now (`--mode now`). The post text credits the streamer and links the original clip. Run it on a schedule with cron (here every 3 hours, one short per run): ```cron 0 */3 * * * cd /home/me/replish-bot && . ./env.sh && python replish_to_postiz.py --channels --cat just-chatting --mode schedule >> bot.log 2>&1 ``` `env.sh` holds the four `export` lines and should be readable only by you (`chmod 600 env.sh`). ## Option 2: an AI agent with both MCP servers Use this when you want the agent to choose the clips and write the text itself. Connect both servers (Claude Code shown; Codex, Cursor and Hermes take the same URL and header): ```bash claude mcp add --transport http replish "$REPLISH_URL/mcp" --header "Authorization: Bearer $REPLISH_KEY" claude mcp add --transport http postiz https://mcp.postiz.com/mcp --header "Authorization: Bearer $POSTIZ_KEY" ``` Replish tools: `rising_clips`, `search`, `streamer_clips`, `game_clips`, `trending_posts`, `create_vertical` (clip, hook, footer, watermark, captions, layout, start, duration, campaign), `render_status`, and for your campaigns `list_campaigns`, `get_campaign`, `campaign_clips`, `add_campaign`, `update_campaign`, `campaign_logo_upload`, `delete_campaign_logo` and `delete_campaign`. Postiz tools include `integrationList`, `integrationSchema` and `schedulePostTool`. The MP4 must reach Postiz as an upload. The `download_url` Replish gives is good for one download within one hour, so do not hand it to Postiz's "upload from URL": the agent downloads the file and uploads it itself. An agent with a shell (Claude Code, Codex) does it with two commands: ```bash curl -sSL -o short.mp4 "$DOWNLOAD_URL" curl -sS -X POST "$POSTIZ_URL/upload" -H "Authorization: $POSTIZ_KEY" -F "file=@short.mp4" # gives id and path ``` A prompt you can start from (save it as a slash command or run it headless with `claude -p`): ```text You run my clip channel. Every run: 1. Call rising_clips (window 180, cat just-chatting, lang en, limit 30) and trending_posts (cat just-chatting). 2. Pick the 2 clips most likely to do well as shorts: high score, big_moment 2 or more, a streamer or a moment that also shows up in trending_posts. Skip clips listed in posted.txt. 3. For each clip write a hook (6 words or less, curiosity, no clickbait lies) and a footer ("Follow for daily clips"). Watermark: @myclips. 4. create_vertical with that text, then render_status every 5 seconds until done. 5. Download the MP4 from download_url, upload it to Postiz (POST $POSTIZ_URL/upload), then schedulePostTool as a draft on my TikTok and YouTube channels. Post text: one line about the moment, then "Clip: ()" and 3 hashtags. 6. Append the clip id to posted.txt. Report what you queued. Never print or log the API keys. ``` Keep the posts as drafts until you trust the agent's choices, then switch to scheduled posts. ## Option 3: n8n or another workflow tool - Replish: HTTP Request nodes with the header `Authorization: Bearer `: `GET /v1/clips`, `POST /v1/renders`, a Wait + `GET /v1/renders/{id}` loop until `status` is `done`, then `GET` the `file_url` as a binary file. - Postiz: the community node `n8n-nodes-postiz` (or HTTP Request nodes): upload the binary, then create the post. ## Make the shorts original (and monetizable) Platforms pay for original content, not for re-uploads. Use what Replish adds on top of the clip: - A hook at the top that frames the moment in your words, a footer (call to action or context), and your watermark on every video. - Burned-in captions (on by default). - Cut to the moment with `start` and `duration`. Check each platform's current rules for length: for example, TikTok's Creator Rewards Program has asked for videos longer than one minute, which you get by rendering 61 to 90 seconds of a long enough clip (Kick clips can run up to 3 minutes). - Always credit the streamer in the post text and link the original clip. Respect a streamer who asks you to stop. - Do not post the same clip twice to a channel (the script keeps a list), and spread posts over the day with scheduled slots instead of bursts. ## Troubleshooting | You see | Do this | |---|---| | Replish 401 `invalid_key` | The key was revoked or mistyped. Create a new one in `/account`. | | Replish 402 `plan_required` | Your plan ended. Renew on `/pricing`; the same key works again. | | Replish 429 `render_in_progress` | One render per key at a time. Poll the running one first. | | Replish 429 `monthly_render_limit` | Quota used. It comes back on the 1st (UTC). | | Render `error` | The clip was deleted or is private. Pick another one. | | Postiz 413 | The body is too big: upload the video with `/upload` and reference it, never inline it. | | Postiz 429 | Too many posts this hour. Batch several channels in one `POST /posts`, or wait. | | TikTok post "published" but not on the profile | It was sent with `UPLOAD`: open the TikTok inbox, or use `DIRECT_POST`. |