# Errors

> Error format, every error code, and how to handle each.

Source: https://www.podcastlookup.com/documentation/errors

Errors use standard HTTP status codes and a JSON body with a stable, machine-readable `code` and a human-readable `message`:

```json
{
  "error": {
    "code": "credits_exhausted",
    "message": "All 50 credits of this month on the Free plan are used. Upgrade at https://www.podcastlookup.com/pricing or wait until 2027-01-01."
  }
}
```

Branch on `code`, never on `message`: messages may be reworded.

## Error codes

| Status | Code | What happened | What to do |
| --- | --- | --- | --- |
| 400 | `invalid_parameter` | A numeric parameter isn't an integer | Fix the request |
| 400 | `invalid_podcast_id` | Podcast ids are positive integers | Use an `id` from search |
| 400 | `invalid_episode_id` | Empty or too long episode id | Use an `id` from the episodes list |
| 400 | `invalid_page` / `invalid_page_size` | `page` < 1, or `page_size` outside 1–100 | Fix the request |
| 400 | `too_many_values` | More than 10 values for one filter | Split the search |
| 400 | `cannot_request` | The episode can't be transcribed (no audio) | Nothing to do |
| 401 | `missing_api_key` | No key in the request | Send `Authorization: Bearer pl_…` |
| 401 | `invalid_api_key` | The key is wrong, revoked or expired | Check or create a key |
| 402 | `payment_past_due` | The last subscription payment failed | Update your card from your [account](https://www.podcastlookup.com/account) |
| 402 | `credits_exhausted` | The month's credits (and any extra credits) are spent | Wait for the reset or upgrade |
| 403 | `email_not_verified` | The account's email isn't confirmed | Confirm it from the email we sent |
| 404 | `podcast_not_found` | No podcast with this id | Check the id |
| 404 | `episode_not_found` | The episode isn't stored | [List episodes](https://www.podcastlookup.com/documentation/rest-api/list-episodes.md) first |
| 404 | `transcript_not_available` | No transcript for this episode yet | [Request one](https://www.podcastlookup.com/documentation/rest-api/request-transcript.md) |
| 429 | `rate_limited` | Per-minute limit reached | Wait `Retry-After` seconds |
| 429 | `refresh_too_soon` | Podcast refreshed less than a minute ago | Wait `Retry-After` seconds |
| 500 | `internal_error` | Something broke on our side | Retry with backoff |
| 502 | `feed_unavailable` | The podcast's own feed didn't answer | Retry later |

## Retrying

Only retry `429`, `500` and `502`. For `429`, wait the number of seconds in `Retry-After`. For `5xx`, use exponential backoff (1 s, 2 s, 4 s…) and give up after a few attempts.

```ts
async function call(url: string, init: RequestInit = {}, attempt = 0): Promise<Response> {
  const response = await fetch(url, {
    ...init,
    headers: { ...init.headers, Authorization: `Bearer ${process.env.PODCAST_LOOKUP_API_KEY}` },
  })
  const retryable = response.status === 429 || response.status >= 500
  if (!retryable || attempt >= 4) return response

  const retryAfter = Number(response.headers.get("Retry-After"))
  const delay = retryAfter > 0 ? retryAfter * 1000 : 2 ** attempt * 1000
  await new Promise((resolve) => setTimeout(resolve, delay))
  return call(url, init, attempt + 1)
}
```

## MCP errors

MCP tools return the same codes as text, with `isError: true`, for example `episode_not_found: No such episode. List the podcast's episodes first (that also reads its feed).` Agents read these messages and usually recover on their own. Authentication and subscription errors (`401`, `402`, `403`) are returned as HTTP errors before the MCP session starts.