> 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/api-reference/rest-api/publish-an-episode-from-your-own-system.md). Agents can also search and read this documentation through its [MCP server](https://docs.podigee.com/~gitbook/mcp).

# Publish an episode from your own system

Create, upload, encode, and publish one episode with the REST API v1, step by step.

Use this tutorial to publish one episode from your own software, for example from a content management system (CMS). It uses a test podcast, one audio file smaller than 30 MB, and `curl`. Your integration sends the same requests in the same sequence.

## What you will complete

At the end of this tutorial, you will have a published test episode that your system created, uploaded, encoded, and published. You will also have the two identifiers that your system must store for each episode.

## Before you start

* Your plan includes API access: Scale and above, or an older plan that includes it.
* You have the account API key, or a REST API token with the scope **Read and write**. See [Get your API key or token](https://docs.podigee.com/documentation/connect-and-administer/integrations/get-your-api-key-or-token). The request for an upload address in step 3 accepts a REST API token only when the account has write access to the Model Context Protocol (MCP) server. If you are not sure, use the account API key for this tutorial.
* The user of the credential has the permission to publish episodes.
* You have a test podcast. Do not use a podcast with listeners for your first requests. Podigee has no separate test environment, so each request changes real data in your account.
* You have one audio file smaller than 30 MB, for example `episode.mp3`.

Read these rules before you write code:

* Your system is the source of the text and the publication time. Podigee is the source of the encoded media, the feed, and the analytics. Your system sends changes to Podigee and reads the state back. Podigee does not send changes to your system. This tutorial uses the model in which your system leads. For the other models, see [Decide which system leads](https://docs.podigee.com/api-reference/rest-api/decide-which-system-leads.md).
* Podigee assigns the `id` of each object. Store it with your own identifier.
* A request without a response can still be complete. See [REST API retries and timeouts](https://docs.podigee.com/api-reference/rest-api/retries-and-timeouts.md).

## Follow the tutorial

### 1. Find the podcast

1. Replace `mytoken` with your credential in each command of this tutorial.
2. Run this command:

```bash
curl -H "Token: mytoken" "https://app.podigee.com/api/v1/podcasts?fields_filter[]=subdomain"
```

Expected result: a JSON list. Find your test podcast and keep its `id`. The examples use `42`.

### 2. Create the episode

1. Send the fields as one flat JSON object.
2. Send a `guid` that only this episode has. Your system can then find the episode again when a request ends without a response.
3. Run this command:

```bash
curl -X POST -H "Token: mytoken" -H "Content-Type: application/json" \
  -d '{"podcast_id": 42, "title": "Test episode from my system", "guid": "my-system-episode-1"}' \
  https://app.podigee.com/api/v1/episodes
```

Expected result: the response is the new episode with your `guid`. Keep its `id`. The examples use `1001`. Store the `id` in your system now, before the next request. The episode is not published.

### 3. Request an upload address

1. Find the exact size of your file in bytes. The upload in step 4 must have exactly this size.
2. Run this command with the file name and the size:

```bash
curl -X POST -H "Token: mytoken" \
  "https://app.podigee.com/api/v1/uploads?filename=episode.mp3&filesize=18400000"
```

Expected result: a JSON object with `upload_url`, `content_type`, `file_url`, and `"multipart_upload": false`. Keep `upload_url`, `content_type`, and `file_url`.

### 4. Upload the file

1. Replace `<upload_url>` and `<content_type>` with the values from step 3.
2. Run this command:

```bash
curl -X PUT -H "Content-Type: <content_type>" --data-binary @episode.mp3 "<upload_url>"
```

Expected result: the status is `200` and the response has no body. The `upload_url` is valid for 3600 seconds.

### 5. Create the production

1. Replace `<file_url>` with the `file_url` from step 3. Do not use `upload_url` here.
2. Run this command:

```bash
curl -X POST -H "Token: mytoken" -H "Content-Type: application/json" \
  -d '{"episode_id": 1001, "files": [{"url": "<file_url>"}]}' \
  https://app.podigee.com/api/v1/productions
```

Expected result: the response is the production with the state `initial`. Keep its `id`. The examples use `2002`. Store this `id` in your system too. This request can take many seconds, because Podigee reads the file before it answers.

### 6. Start encoding

1. Run this command:

```bash
curl -X POST -H "Token: mytoken" https://app.podigee.com/api/v1/productions/2002/start
```

Expected result: the response is the production with the state `encoding`.

### 7. Wait until encoding is complete

1. Run this command every 15 to 30 seconds:

```bash
curl -H "Token: mytoken" https://app.podigee.com/api/v1/productions/2002
```

2. Continue when `state` is `encoded`.

Expected result: the state changes from `encoding` to `encoded`. If the state is `error`, stop. Do not start the production again in a loop.

### 8. Publish the episode

1. Replace `<time>` with the current time to publish now, or with a time in the future to schedule the episode. Use the ISO 8601 format, for example `2026-11-02T06:00:00Z`.
2. Run this command:

```bash
curl -X PUT -H "Token: mytoken" -H "Content-Type: application/json" \
  -d '{"published_at": "<time>"}' \
  https://app.podigee.com/api/v1/episodes/1001
```

Expected result: the response is the episode with your `published_at` value.

## Check your result

1. Read `GET /episodes/1001` and compare `published_at` with the value that you sent.
2. Open the test podcast in the Podigee web app. The episode shows as published, or as scheduled when the time is in the future.
3. After the publication time, open the feed of the test podcast. The episode is in the feed.

Your system now holds the episode `id` and the production `id` for its own record of the episode.

## If the result is different

* The response is `401`: check the credential and the plan. See [REST API authentication and errors](https://docs.podigee.com/api-reference/rest-api/authentication-and-errors.md).
* The response is `403` with `This token is read-only.`: create a REST API token with the scope **Read and write**.
* The update in step 8 answers `422`: the user of the credential may not publish, or the plan has no episode publications left. See [Permission to publish](https://docs.podigee.com/api-reference/rest-api/podcasts-and-episodes.md#permission-to-publish).
* A request answers `200` but nothing changed: the body was not a flat JSON object, the `Content-Type` header was missing, or the field name is wrong. See [Request body](https://docs.podigee.com/api-reference/rest-api/authentication-and-errors.md#request-body).
* Step 3 answers `403` with `MCP upload access is not enabled for this account.`: you sent a REST API token, and the account has no write access to the MCP server. Use the account API key for the request in step 3.
* Step 4 answers `403`: the file does not have the size that you sent as `filesize` in step 3, or the `Content-Type` header is not the `content_type` from step 3. Repeat step 3 with the exact size, then repeat step 4.
* Step 3 answers `422` with `Unsupported content type`: the API does not accept this file type. See [Accepted file types](https://docs.podigee.com/api-reference/rest-api/media-uploads-and-encoding.md#accepted-file-types).
* Step 5 answers `422`: the file is not in storage. Repeat step 4, then step 5.
* Step 6 answers `402`: the plan has no encoding time left.
* A request ended without a response: do not send it again at once. See [REST API retries and timeouts](https://docs.podigee.com/api-reference/rest-api/retries-and-timeouts.md).
* The test podcast now has two equal episodes: a create request was sent two times. Delete one episode with `DELETE /episodes/{episode_id}`.

## Before you use the integration for real podcasts

* Each episode in your system stores the Podigee episode `id` and the production `id`.
* A timeout or a `5xx` response starts the recovery sequence, not a second create request.
* The time limit of your client is 40 seconds or more.
* The integration waits after a `429` for the time in `Retry-After`.
* A file larger than 30 MB uses the multipart upload. See [Upload a file in parts](https://docs.podigee.com/api-reference/rest-api/media-uploads-and-encoding.md#upload-a-file-in-parts).
* Only an explicit action in your system publishes an episode in Podigee.
* The credential is on your server and not in a browser or an app.
* You tested one complete episode on the test podcast, with a scheduled time and with an immediate publication.
* You tested episodes with the content that your team uses: long show notes, special characters, chapter marks, and a transcript.
* The first podcast with listeners is a podcast where an error has a small effect. A published episode goes to the public feed, and an unpublish request does not remove it from an app that has already loaded it.

## Next step

[REST API retries and timeouts](https://docs.podigee.com/api-reference/rest-api/retries-and-timeouts.md) lists the requests that are safe to repeat and the recovery sequence for each request.


---

# 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/api-reference/rest-api/publish-an-episode-from-your-own-system.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.
