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

# REST API retries and timeouts

Which REST API v1 requests are safe to repeat, and how to recover when a request ends without a response.

Use this reference when you decide how your integration reacts to a timeout, a `429`, or a `5xx` response. Paths are relative to `https://app.podigee.com/api/v1`.

A request that ends without a response is not a failed request. Podigee can have completed the work. If your integration then sends a create request again, it can create a second object. The most frequent result is an episode that exists two times.

## Time limits

| Item                                  | Value                                                              |
| ------------------------------------- | ------------------------------------------------------------------ |
| Request time limit of Podigee         | 35 seconds                                                         |
| Response after the time limit         | A `5xx` response or a closed connection, without a JSON error body |
| Recommended time limit of your client | 40 seconds or more                                                 |
| Guaranteed response time              | None                                                               |

Do not set the time limit of your client below the time limit of Podigee. A shorter limit ends requests that Podigee completes, and your integration cannot see the result.

## Requests that are safe to repeat

| Request                                                                            | Result of a second request                                                                                                    |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Every `GET` request                                                                | The same data.                                                                                                                |
| `POST /uploads` with `idempotency_key`                                             | The same `file_url` and the same upload address.                                                                              |
| `PUT` of the file to `upload_url`                                                  | The file replaces the first file.                                                                                             |
| `PUT /episodes/{episode_id}` and `PUT /podcasts/{podcast_id}` with the same values | The same state.                                                                                                               |
| `POST /productions`                                                                | The new production replaces the first production of the episode. The new production has the state `initial` and its own `id`. |
| `DELETE` requests                                                                  | `404`, because the object no longer exists.                                                                                   |

## Requests that are not safe to repeat

| Request                                     | Result of a second request                                                   | What to do first                                                                       |
| ------------------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `POST /episodes`                            | A second episode with the next free number. The API does not compare titles. | Read the newest episodes of the podcast and look for your `guid` or your `number`.     |
| `POST /podcasts`                            | A second request can create a second podcast.                                | Read `GET /podcasts` and look for the podcast.                                         |
| `POST /productions/{production_id}/start`   | Encoding starts again.                                                       | Read the production. Do not start a production whose state is `encoding` or `encoded`. |
| `POST /listeners`                           | `422`, because the email address is in use for the podcast.                  | Read `GET /listeners` with the `podcast_id`.                                           |
| `POST /batch_encodings`                     | A second batch encoding of the podcast.                                      | Read `GET /batch_encodings/state`.                                                     |
| Other `POST` requests that create an object | A second object.                                                             | Read the list of the objects.                                                          |

### Protect episode creation

Only `POST /uploads` accepts an idempotency key. For `POST /episodes`, send a value that only this episode has. Use one of these methods in every create request:

* Send your own `number`. A second request with the same number, season, and episode type answers `422` and creates nothing.
* Send your own `guid`, and look for it in the episode list before you create the episode again.

With both methods, store the `id` from the response at once, before the next request.

Do not use the title to find an episode. Titles are not unique, and a different episode can have the same title.

## Recover after a request without a response

Follow the sequence for the request that ended without a response.

### After `POST /episodes`

1. Read `GET /episodes?podcast_id=<id>&sort_by=created_at&sort_direction=desc&limit=10`.
2. Look for an episode with the `guid` or the `number` that you sent. Do not compare titles.
3. If the episode exists, store its `id` and continue. If it does not exist, send the create request again.

If you sent no `guid` and no `number`, you cannot identify the episode safely. Open the podcast in the Podigee web app and check the newest episodes before you continue.

### After `POST /productions`

1. Read `GET /episodes/{episode_id}`.
2. If `production_id` has a value, read `GET /productions/{production_id}` and continue with that production.
3. If `production_id` is empty, send the create request again.

### After `POST /productions/{production_id}/start`

1. Read `GET /productions/{production_id}`.
2. If the state is `encoding` or `encoded`, the start was successful. Do not start again.
3. If the state is `initial`, send the start request again.
4. If the state is `error`, do not repeat the request in a loop. See [Encoding errors](#encoding-errors).

### After `PUT /episodes/{episode_id}`

1. Read `GET /episodes/{episode_id}`.
2. Compare the fields with the values that you sent.
3. Send the update again only when the values are different.

## Responses that tell you to wait

| Response                 | Action                                                                                                                                                                                                     |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `429`                    | Wait for the number of seconds in the `Retry-After` header. Then send the same request again. See [Rate limits](https://docs.podigee.com/api-reference/rest-api/authentication-and-errors.md#rate-limits). |
| `409`                    | Read the object again, then repeat the request.                                                                                                                                                            |
| `5xx` on a `GET` request | Wait, then repeat the request. Make each wait longer than the one before.                                                                                                                                  |
| `5xx` on a write request | Use the recovery sequence above. Do not repeat the request first.                                                                                                                                          |

Do not repeat a request after `401`, `402`, `403`, `404`, or `422`. The request stays wrong until you change the credential, the plan, the permission, or the data.

## Encoding errors

A production with the state `error` did not produce encoded media. Read the production and the files that you sent. Check that `file_url` is the address from `POST /uploads` and that the upload contains the complete media file. Then create the production again and start it one time. If the state is `error` again, contact Podigee Support with the episode `id`, the production `id`, and the time of the request. Do not send the credential.

## Rules for a synchronization job

* Start a synchronization from an explicit action, such as "publish" in your system. Do not send every changed record of your system to Podigee.
* Keep one record for each episode: your identifier, the Podigee episode `id`, the production `id`, and the last state that you read.
* Process one episode in one sequence. Do not run two jobs for the same episode at the same time.
* Read changes in pages, newest first. See [Read episodes in pages](https://docs.podigee.com/api-reference/rest-api/podcasts-and-episodes.md#read-episodes-in-pages).
* Store the data that you read from Podigee in your system. Your website or app then shows the stored copy when the API answers `429` or gives no response.
* Give each field one system that leads. See [Decide which system leads](https://docs.podigee.com/api-reference/rest-api/decide-which-system-leads.md).

## 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 authentication and errors](https://docs.podigee.com/api-reference/rest-api/authentication-and-errors.md)
* [REST API media uploads and encoding](https://docs.podigee.com/api-reference/rest-api/media-uploads-and-encoding.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/retries-and-timeouts.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.
