> 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/media-uploads-and-encoding.md). Agents can also search and read this documentation through its [MCP server](https://docs.podigee.com/~gitbook/mcp).

# REST API media uploads and encoding

Endpoints for upload URLs, productions, media clips, and batch encodings in the REST API v1.

Use this reference when you need the exact endpoints to upload a media file, attach it to an episode, start encoding, or read the encoded files. Paths are relative to `https://app.podigee.com/api/v1`.

The normal flow has four stages:

1. Request an upload URL with `POST /uploads` and upload the file to that URL.
2. Create a production for the episode with the returned `file_url`.
3. Start the production with `POST /productions/{production_id}/start`.
4. Read the production until its state is `encoded`.

[Publish an episode from your own system](https://docs.podigee.com/api-reference/rest-api/publish-an-episode-from-your-own-system.md) shows the complete sequence with example requests.

These endpoints are not the media upload protocol of the Model Context Protocol (MCP) server. [Upload local media with your assistant](https://docs.podigee.com/documentation/start-here/ai-agents/media-and-publishing/upload-media-and-cover-images) documents the agent protocol.

## Uploads

| Method | Path                              | Purpose                                             | Notable parameters                                                  | Response notes                                                                                                                                                                  |
| ------ | --------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST` | `/uploads`                        | Get a signed URL to upload one file to storage      | `filename` (required), `filesize`, `idempotency_key`, `upload_type` | Returns `upload_url`, `content_type`, `file_url`, and `multipart_upload`. For a file larger than 30 MB, also `upload_key`, `part_size` (`31457280`), and `multipart_upload_id`. |
| `POST` | `/uploads/part_url`               | Get a signed URL for one part of a multipart upload | `upload_key`, `multipart_upload_id`, `part_number` (all required)   | Returns `upload_part_url`. `422` with `Part number is out of range` or the validation message.                                                                                  |
| `POST` | `/uploads/complete_multipart_url` | Get the URL that completes a multipart upload       | `upload_key`, `multipart_upload_id` (both required)                 | Returns `complete_multipart_upload_url`. `422` with `URL generation failed` or the validation message.                                                                          |

### Upload parameters and limits

| Item                  | Value                                                                                                                                                                              |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `upload_type`         | `public` (default), `private`, or `temporary`                                                                                                                                      |
| `idempotency_key`     | Stable key to retry the same upload without a change of its URL. `1` to `128` characters from letters, digits, `.`, `_`, `:`, and `-`. The key must start with a letter or a digit |
| Upload method         | Send the file with `PUT` to `upload_url`                                                                                                                                           |
| `upload_url` validity | 3600 seconds                                                                                                                                                                       |
| Maximum file size     | 20 GB                                                                                                                                                                              |
| Accepted file types   | See [Accepted file types](#accepted-file-types)                                                                                                                                    |

Send `filesize` in bytes with each `POST /uploads` request. The API uses it to select a normal or a multipart upload. For an upload in one request, a positive `filesize` sets the exact body size. Storage refuses a file of a different size with `403` for this upload method.

When `filesize` is omitted or `0`, the API returns a normal upload with no set size.

### Accepted file types

The extension of `filename` decides the content type of the upload. Uppercase and lowercase letters are equal. The API accepts only filenames with these extensions:

| Group               | Extensions                                                                                                                  |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| Audio               | `mp3`, `mpga`, `m4a`, `m4b`, `aac`, `wav`, `flac`, `ogg`, `oga`, `opus`, `aif`, `aiff`, `aifc`, `caf`, `wma`, `mka`, `weba` |
| Video               | `mp4`, `m4v`, `mov`, `qt`, `mkv`, `mk3d`, `avi`, `webm`, `ogv`, `ogm`, `mpg`, `mpeg`, `mp2`, `wmv`, `3gp`                   |
| Image               | `jpg`, `jpeg`, `jpe`, `jfif`, `png`, `gif`, `ico`                                                                           |
| Transcript and text | `vtt`, `srt`, `txt`, `md`, `markdown`, `csv`                                                                                |
| Document            | `pdf`, `doc`, `docx`, `xls`, `xlsx`, `ppt`, `pptx`                                                                          |
| Certificate         | `pem`                                                                                                                       |

The API refuses each other filename extension with `422`, for example `html`, `svg`, `xml`, `js`, `css`, and `json`. For an upload in one request, storage requires the returned `content_type` in the `Content-Type` header. For a multipart upload, the API sets the final object's content type when it creates the upload. The upload endpoint does not inspect file contents.

This list is the list of the upload endpoint. The formats that Podigee can encode for an episode are in [Upload audio or video](https://docs.podigee.com/documentation/create-and-publish/production/episodes/upload-audio-or-video).

### Upload a file in one request

Use this path when the response contains `"multipart_upload": false`.

1. Send the file with `PUT` to `upload_url`. Set the `Content-Type` header to the returned `content_type`. With a positive `filesize`, the body must have exactly that number of bytes.
2. Keep the returned `file_url`. The production needs `file_url`, not `upload_url`.

### Upload a file in parts

Use this path when the response contains `"multipart_upload": true`. This is the case for a file larger than 30 MB.

1. Choose a part size up to `part_size`. Amazon S3 requires each non-final part to be at least 5 MiB (5,242,880 bytes). Only the final part may be smaller than 5 MiB.
2. For each part, send `POST /uploads/part_url` with `upload_key`, `multipart_upload_id`, and the `part_number`, which starts at `1`. The highest part number is `10000`.
3. Send the part with `PUT` to the returned `upload_part_url`. Keep the `ETag` header of each response.
4. Send `POST /uploads/complete_multipart_url` with `upload_key` and `multipart_upload_id`.
5. Send a `POST` request to the returned `complete_multipart_upload_url`. The body is the XML part list of the Amazon S3 multipart upload protocol, with the number and the `ETag` of each part.
6. Keep the `file_url` from the first response for the production.

A part URL is valid for 3600 seconds.

The upload endpoints do not check the final assembled file size against `filesize`.

### Upload errors

These errors come from the three upload URL endpoints. Some of them have a `reason` field in the JSON body, next to `code` and `message`. The value of `reason` does not change, so your client can read it instead of the message.

| Status | Message                                              | `reason`              | Cause                                                                                                                                                                   |
| ------ | ---------------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `403`  | `MCP upload access is not enabled for this account.` | none                  | You sent a REST API token to one of the three upload URL endpoints, and the account has no write access to the MCP server. Use the account API key for these endpoints. |
| `422`  | `File size exceeds the maximum allowed`              | `too_large`           | `filesize` is above 20 GB.                                                                                                                                              |
| `422`  | `Unsupported content type`                           | `unsupported_type`    | The file type is not in the list of [accepted file types](#accepted-file-types).                                                                                        |
| `422`  | `Invalid upload idempotency key`                     | none                  | The key does not match the allowed pattern.                                                                                                                             |
| `422`  | `Part number is out of range`                        | `invalid_part_number` | `part_number` in `POST /uploads/part_url` is not a whole number from `1` to `10000`.                                                                                    |

This error comes from storage, when you send the file in one request with `PUT`. Its body is XML, not the JSON error body of the API.

| Status | Cause                                                                                                                         | Action                                                                                                       |
| ------ | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `403`  | The body size differs from a positive `filesize`, or the `Content-Type` header is different from the returned `content_type`. | Send `POST /uploads` again with the correct `filesize`, then send the file with the returned `content_type`. |

## Productions

A production attaches one uploaded file to an episode and controls its encoding.

| Method   | Path                                 | Purpose                            | Notable parameters                                                             | Response notes                                                                                                                                                                                                           |
| -------- | ------------------------------------ | ---------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `GET`    | `/productions/{production_id}`       | Read a production                  | none                                                                           | Includes `state`, `files`, and `audio_duration_ms`.                                                                                                                                                                      |
| `POST`   | `/productions`                       | Create a production for an episode | `episode_id`, `files[]`, `inserts[]`, `state`, `publication_flag` (deprecated) | `422` when a file is not in storage or when a file size does not match.                                                                                                                                                  |
| `PUT`    | `/productions/{production_id}`       | Update a production                | `state`, `publication_flag`                                                    |                                                                                                                                                                                                                          |
| `DELETE` | `/productions/{production_id}`       | Delete a production                | none                                                                           |                                                                                                                                                                                                                          |
| `POST`   | `/productions/{production_id}/start` | Start encoding                     | `publish_episode=true` publishes the episode after encoding                    | `402` with `Not enough encoding time left` when the plan has no encoding time left. `403` with `Not allowed to publish` when you send `publish_episode=true` and the user of the credential may not publish the episode. |
| `POST`   | `/productions/{production_id}/stop`  | Stop encoding                      | none                                                                           |                                                                                                                                                                                                                          |

### Production files

Each entry of `files[]` describes one uploaded file.

| Field               | Meaning                                                                                                                                     |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`               | The `file_url` of the upload. Required.                                                                                                     |
| `type`              | `multitrack` (default), `intro`, `outro`, or `spot`. Use the default for the episode audio.                                                 |
| `original_filename` | The name of the file that you uploaded.                                                                                                     |
| `original_filesize` | The size of the file in bytes. When you send it, the API compares it with the stored file and refuses a production whose size is different. |
| `offset`            | The position of the file in seconds. For `intro`, `outro`, and `spot` only.                                                                 |
| `contributor_id`    | The contributor of the track.                                                                                                               |
| `custom_name`       | A name for the track. The API uses it only without `contributor_id`.                                                                        |

### Create a production

`POST /productions` does its work before it answers. It checks that each file is in storage and reads the duration and the metadata of the file. For a large file, the request can take many seconds. Give your client a time limit of at least 40 seconds for this request.

An episode has one production. A second `POST /productions` for the same episode replaces the first production. It does not add a second one. The new production has the state `initial` and its own `id`, so you must start it again.

If a create request ends without a response, read the episode first. When `production_id` in the episode has a value, the production exists: continue with that production. See [REST API retries and timeouts](https://docs.podigee.com/api-reference/rest-api/retries-and-timeouts.md).

### Production states

| State      | Meaning                                   |
| ---------- | ----------------------------------------- |
| `initial`  | The production exists and is not encoded. |
| `encoding` | Encoding runs.                            |
| `encoded`  | Encoding finished.                        |
| `error`    | Encoding failed.                          |

Use `/start` and `/stop` to control encoding. The start of a production requires that the account has permission to encode media for that podcast.

### Wait for encoding

`POST /productions/{production_id}/start` answers at once with the state `encoding`. Encoding runs after the response. The time depends on the length of the file.

1. Read `GET /productions/{production_id}` every 15 to 30 seconds.
2. Continue when the state is `encoded`.
3. Stop when the state is `error`. Do not start the production again in a loop.

The API does not send a notification when encoding ends. With `publish_episode=true`, Podigee publishes the episode when encoding ends, so your system does not need a second request to publish. To schedule the episode for a later time, do not send `publish_episode`. Set `published_at` after encoding. See [Publish, schedule, and unpublish](https://docs.podigee.com/api-reference/rest-api/podcasts-and-episodes.md#publish-schedule-and-unpublish).

## Media clips

A media clip is one encoded file of an episode, or a file that is hosted outside Podigee.

| Method   | Path                           | Purpose                            | Notable parameters                                     | Response notes                        |
| -------- | ------------------------------ | ---------------------------------- | ------------------------------------------------------ | ------------------------------------- |
| `GET`    | `/media_clips`                 | List the media clips of an episode | `episode_id`                                           | Returns only supported audio formats. |
| `GET`    | `/media_clips/{media_clip_id}` | Read a media clip                  | none                                                   |                                       |
| `POST`   | `/media_clips`                 | Register a file for an episode     | `episode_id`, `file_format`, `url`, `size`, `duration` |                                       |
| `DELETE` | `/media_clips/{media_clip_id}` | Delete a media clip                | none                                                   |                                       |

Error: `404` with `The media_clip with id <id> could not be found.`

## Batch encodings

Batch encoding re-encodes every episode of a podcast after you changed the intro or outro audio.

| Method | Path                     | Purpose                                                     | Notable parameters                   | Response notes                                                                                            |
| ------ | ------------------------ | ----------------------------------------------------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| `GET`  | `/batch_encodings`       | Read the progress of the latest batch encoding of a podcast | `podcast_id` (required)              | `404` without a body when the podcast has no batch encoding.                                              |
| `GET`  | `/batch_encodings/state` | Read the intro and outro encoding state                     | `podcast_id` (required)              | Returns `{"state": "..."}`.                                                                               |
| `POST` | `/batch_encodings`       | Start a batch encoding for a podcast                        | `podcast_id` (required), `initiator` | `200` without a body. `422` with `Wrong initiator parameter value` when `initiator` is not a valid value. |

Every batch encoding request needs `podcast_id`. An unknown podcast answers `404` with `The podcast with id <id> could not be found.`

## Related pages

* [Publish an episode from your own system](https://docs.podigee.com/api-reference/rest-api/publish-an-episode-from-your-own-system.md)
* [REST API retries and timeouts](https://docs.podigee.com/api-reference/rest-api/retries-and-timeouts.md)
* [REST API podcasts and episodes](https://docs.podigee.com/api-reference/rest-api/podcasts-and-episodes.md)
* [REST API episode content](https://docs.podigee.com/api-reference/rest-api/episode-content.md) manages the intro and outro audio.
* [REST API authentication and errors](https://docs.podigee.com/api-reference/rest-api/authentication-and-errors.md)


---

# 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/media-uploads-and-encoding.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.
