> For the complete documentation index, see [llms.txt](https://docs.podigee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.podigee.com/documentation/start-here/ai-agents/media-and-publishing/encode-and-publish-episodes.md). Agents can also search and read this documentation through its [MCP server](https://docs.podigee.com/~gitbook/mcp).

# Encode and publish episodes

Publish, schedule, or keep as draft an episode with its recording, and follow the encoding.

This page tells you how your assistant gives an episode its recording, how Podigee encodes it, and how the episode goes live, gets a schedule, or stays a draft. Use `publish_episode` for most jobs. It creates or updates the episode, attaches the recording, waits for the encoding, and applies the publication in one previewed step. The production tools give you manual control of the encoding.

To send the file to Podigee first, see [Upload media and cover images](https://docs.podigee.com/documentation/start-here/ai-agents/media-and-publishing/upload-media-and-cover-images.md).

## What you need

* A connection with the scopes `mcp:podcasts:write` and `mcp:media:write`. `publish_episode` needs both scopes for every mode, `draft` included. The scope table is in [Authorization and scopes](https://docs.podigee.com/documentation/start-here/ai-agents/mcp-reference/authorization-and-scopes.md).
* The right to publish on the show, for `now`, `scheduled`, and for a `draft` that takes a live or scheduled episode offline. A person whose role on the show allows edits but not publication gets an error that names this. The owner of the show can publish or give that right.
* The show ID and, for an existing episode, the episode ID.
* A result from `doctor` for the show. It reports whether the show is ready to publish, the plan allowances, and your time zone. See [Check your account, plan, and readiness](https://docs.podigee.com/documentation/start-here/ai-agents/work-safely/check-your-account-plan-and-readiness.md).

Every `publish_episode` call has two steps: a preview with `dry_run: true`, then the same request with an idempotency key and the `confirm` value of the preview, after you said yes. The rules are in [Preview and confirm changes](https://docs.podigee.com/documentation/start-here/ai-agents/work-safely/preview-and-confirm-changes.md).

## Publication modes

| `publication.mode` | What happens                                                      | Final stage of the operation |
| ------------------ | ----------------------------------------------------------------- | ---------------------------- |
| `now`              | The episode goes live when the encoding is complete.              | `published`                  |
| `scheduled`        | The episode goes live at `published_at`.                          | `scheduled`                  |
| `draft`            | The episode stays unpublished. A live episode goes back to draft. | `encoded`                    |

The feed lists only published episodes. A draft or a scheduled episode is not in the feed until it goes live. To take a live episode offline without a new recording, see [Manage episodes](https://docs.podigee.com/documentation/start-here/ai-agents/podcasts-and-episodes/manage-episodes.md).

## Publish new local media from start to finish

**What you need:** the file on your computer, an assistant that can run commands, and the episode texts. A chat app cannot send the file: it gives you the **New episode** page. See [Upload media and cover images](https://docs.podigee.com/documentation/start-here/ai-agents/media-and-publishing/upload-media-and-cover-images.md).

1. The assistant calls `create_upload` with the file name, the exact size, and an idempotency key.
2. The assistant runs the command in `next_part` with the path of the file. The command prints `HTTP 200`.
3. The assistant calls `publish_episode` with `dry_run: true`, the show ID, the episode texts in `episode_attributes`, the publication, and `"media": { "source": "upload", "upload_id": "..." }`.
4. Read the preview: the show, the title, and the publication mode.
5. Say yes. The assistant sends the same request with an idempotency key and the `confirm` value.
6. The assistant keeps the returned `operation_id`.
7. The assistant reads the operation with `get_operation` until it reaches a final state. See [Follow the publication](#follow-the-publication).
8. The assistant reads the episode with `get_episode` and tells you the result.

Leave out `episode_id` to create a new episode. A new episode needs a title and a recording. Do not call `create_episode` first: `publish_episode` creates the episode and attaches the file in one step. Send `episode_id` to give an existing episode a new recording.

```json
{
  "podcast_id": 42,
  "episode_attributes": { "title": "Second Cup Stories, episode 12" },
  "media": { "source": "upload", "upload_id": "00000000-0000-4000-8000-000000000000" },
  "publication": { "mode": "now" },
  "dry_run": true
}
```

**Expected result:** the file uploads once, the episode gets one recording, the encoding completes, and the operation ends in the stage of the reviewed mode.

**If the workflow stops:** do not start it again as new work. If the upload stopped, continue it with its `upload_id`. If the publication stopped, follow its `recovery` action. See [If a publication fails or stops](#if-a-publication-fails-or-stops).

**Next step:** [Distribute a podcast](https://docs.podigee.com/documentation/start-here/ai-agents/content-analytics-and-distribution/distribute-a-podcast.md).

## Publish an episode that already has media

**What you need:** the episode ID of an episode with a recording.

1. Read the episode with `get_episode`. Look at `media.state`:
   * `ready`: the recording is processed.
   * `uploaded` or `processing`: the recording is there. The publication waits for the processing.
   * `failed`: read `media.problem`. It tells what is wrong with the recording and the next step. The episode page is the place to replace a recording. `find_in_podigee` with the episode ID gives the link.
   * `none`: the episode has no recording. Upload one first.
2. The assistant calls `publish_episode` with `dry_run: true`, the show ID, the episode ID, and the publication. It leaves out `media`, so the episode keeps its recording.
3. Read the preview: the episode, any text changes, and the publication mode.
4. Say yes. The assistant sends the same request with an idempotency key and the `confirm` value.
5. The assistant follows the operation with `get_operation`.
6. The assistant reads the episode again and tells you its publication state.

`has_media` in `list_episodes` tells only that a playable file exists. `get_episode` has no `has_media`: use `media.state` to know the state of the recording.

**Expected result:** Podigee applies the reviewed mode to the episode and keeps its recording.

**If it fails:** an episode without a recording gets the error that media is required. Keep it as a draft, upload a recording, and publish again with `media`.

**Next step:** [Manage episodes](https://docs.podigee.com/documentation/start-here/ai-agents/podcasts-and-episodes/manage-episodes.md) to check the episode texts.

## Schedule publication while preparing media

You can upload a recording and schedule its release in one request. Start early enough for the upload and the encoding.

**What you need:**

* The scopes `mcp:podcasts:write` and `mcp:media:write`, and the right to publish on the show.
* The `upload_id` of a completed upload, and the episode texts or the episode ID.

1. Run `doctor`. It returns your `time_zone` and the `local_time`.
2. Choose the release time. A time without a zone, for example "Tuesday at 7am", is in your time zone. If `doctor` returns no `time_zone`, the assistant asks you which zone you mean.
3. The assistant writes the time in ISO 8601 with the offset of your zone, for example `2026-12-01T07:00:00+01:00`.
4. The assistant sends `publish_episode` with this publication and the upload:

   ```json
   { "mode": "scheduled", "published_at": "2026-12-01T07:00:00+01:00" }
   ```
5. Read the time in the preview. The preview shows it in UTC (Coordinated Universal Time).
6. Say yes only when the episode and the time are correct.
7. The assistant follows the operation with `get_operation`.

A time in the past is refused. To publish at once, use mode `now`.

While Podigee processes the recording, the operation waits. Its `waiting.then` value is `publishes_at_scheduled_time`. When the processing is complete, the episode stays scheduled for the reviewed time. If the processing ends after that time, the episode goes live when the processing ends. Its publication date stays the scheduled time. To prevent this, start earlier or choose a later time with a new preview.

**Expected result:** the operation ends in stage `scheduled`, and `get_episode` shows the reviewed `published_at`.

**If it fails:** a time in the past gets a validation error; choose a later time and request a new preview. If the operation stops, follow its `recovery` action. See [If a publication fails or stops](#if-a-publication-fails-or-stops).

**Next step:** to change the time later, see [Manage episodes](https://docs.podigee.com/documentation/start-here/ai-agents/podcasts-and-episodes/manage-episodes.md).

## Follow the publication

A confirmed publication returns an operation. The assistant reads it with `get_operation`.

| State                                   | Meaning                                                                           |
| --------------------------------------- | --------------------------------------------------------------------------------- |
| `queued` or `running`                   | The publication is in progress.                                                   |
| `waiting`                               | The publication waits until Podigee has encoded the audio or processed the video. |
| `succeeded`                             | The publication is complete.                                                      |
| `failed_retryable` or `failed_terminal` | The publication stopped. Follow `recovery`.                                       |
| `cancelled`                             | The publication was canceled.                                                     |

A waiting publication has a `waiting` object. It tells you these facts:

* What the publication waits for (`on`).
* The state of the recording (`recording_state`) and the encoding progress (`percent`).
* When the recording was uploaded and when it changed last.
* What happens when the wait ends (`then`).

While `continues_automatically` is `true`, the publication continues by itself. You can leave, and nobody has to keep asking. `poll_after_seconds` tells when to look again.

Each episode can have only one active publication. A second confirmed `publish_episode` for the same episode gets `operation_in_progress`. Wait for the first operation to end, or cancel it with `cancel_operation`.

The full description of the states and the `waiting` object is in [Follow and recover long-running operations](https://docs.podigee.com/documentation/start-here/ai-agents/work-safely/follow-and-recover-long-running-operations.md).

## If a publication fails or stops

A failed publication has `recovery` with one `action`. Also a waiting publication whose `recording_state` is `no_change_for_hours` or `failed` has a `recovery` action. Follow that action:

* Resume the operation only when the action says so: `resume_operation`, or `restore_access` and `check_plan_allowance` after you fixed the cause and `retryable` is `true`.
* For `correct_request` and `replace_recording`, do not resume. Correct the request, or replace the recording on the episode page.
* For `contact_support`, do not retry. Contact Podigee Support with the operation ID.
* Never upload a new file or convert the file to another format unless the action is `replace_recording`.

The full rule for each action is in [Follow and recover long-running operations](https://docs.podigee.com/documentation/start-here/ai-agents/work-safely/follow-and-recover-long-running-operations.md). Error codes are in [Limits, errors, and recovery](https://docs.podigee.com/documentation/start-here/ai-agents/mcp-reference/limits-errors-and-recovery.md).

## Encode a recording step by step

Use the production tools when you want to attach a recording to an existing episode and control the encoding yourself, without a publication in the same step. A production is the recording of an episode and its encoding.

**What you need:** the episode ID, the `upload_id` of a completed upload, and the scopes `mcp:podcasts:write` and `mcp:media:write`.

### Attach the recording

1. The assistant calls `create_production` with the episode ID, the `upload_id`, an idempotency key, and `dry_run: true`. Podigee checks the file and closes the upload.
2. Read the preview: the episode and the upload.
3. Say yes. The assistant sends the same request with `dry_run: false`, the same idempotency key, and the `confirm` value.
4. The assistant keeps the returned production ID.

An upload can belong to only one production. A repeated request with the same idempotency key for the same episode returns the same production.

### Start, follow, and stop the encoding

1. The assistant calls `start_production` with the production ID and `dry_run: true`.
2. Set `publish_episode` to `true` only when the episode must go live after the encoding.
3. Read the preview and say yes. The assistant sends the request with the `confirm` value.
4. The assistant reads `get_production` until the state is `encoded` or `error`. The states are `initial`, `encoding`, `encoded`, and `error`.

To stop an encoding in progress, the assistant previews `stop_production` with the production ID, you confirm, and the assistant reads the production again.

**Expected result:** the production state is `encoded`. If you set `publish_episode`, the episode is live.

**If it fails:** keep the production ID. Run `doctor` to check the encoding allowance. Do not create a second production from the same upload. If the recording itself is the problem, replace it on the episode page.

**Next step:** [Publish an episode that already has media](#publish-an-episode-that-already-has-media).

## Next step

* [Distribute a podcast](https://docs.podigee.com/documentation/start-here/ai-agents/content-analytics-and-distribution/distribute-a-podcast.md)
* [Media and publishing tools](https://docs.podigee.com/documentation/start-here/ai-agents/mcp-tools/media-and-publishing.md) for the parameters of `publish_episode` and the production tools


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.podigee.com/documentation/start-here/ai-agents/media-and-publishing/encode-and-publish-episodes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
