Skip to Content
agentic-yt

Errors

The one error envelope, every error code, and what an agent should do when it sees each.

Every error, from every endpoint, has the same shape:

{
  "error": {
    "code": "too_long",
    "message": "This video is 5h 12m; the maximum is 4h.",
    "hint": "The video exceeds the maximum duration. Use POST /v1/videos/{id}/clip for a section.",
    "docs_url": "https://agentic-yt.crafter.run/docs/errors#too_long"
  }
}
FieldUse
codeOne of the closed set below. Branch on this — never on message or the HTTP status alone.
messageWhat happened, specifically. Show it to a human; do not parse it.
hintWhat to do next, written for an agent. Usually present.
docs_urlThe section of this page for that code.

The same body — without the outer error wrapper — appears as error on a job whose status is failed. One handler covers both.

With the CLI, --json prints the envelope on stdout and the exit code tells you the family without parsing.

At a glance

CodeHTTPDefault hint
unauthorized401Send Authorization: Bearer ayt_pat_…. Create a token in the dashboard or run ayt login.
forbidden403This token is not allowed to perform this operation.
validation_failed400Fix the request parameters named in the message and retry.
not_found404Check the id or path. Ids may also be passed as full YouTube URLs.
video_unavailable404The video is private, deleted, region-locked or age-restricted. Connecting a YouTube account may help.
account_required403Connect a YouTube account first: PUT /v1/me/youtube-account with your cookies.txt content.
youtube_blocked502YouTube refused the request. Retry later, or retry with use_account: true.
quota_exceeded429Daily quota reached. See GET /v1/me/usage for the reset time.
too_long422The video exceeds the maximum duration. Use POST /v1/videos/{id}/clip for a section.
rate_limited429Too many requests or concurrent jobs. Wait for running jobs to finish, then retry.
job_failed500The job failed. Inspect error on the job and create a new job to retry.
internal500Unexpected server error. Retry; if it persists, report it.

The decision, in short

The agent should…For these codes
Fix the request and retryvalidation_failed, not_found, too_long
Wait, then retry the same requestrate_limited, youtube_blocked, internal, job_failed
Stop retrying until tomorrowquota_exceeded
Stop and ask a humanunauthorized, forbidden, account_required
Give up on this videovideo_unavailable

unauthorized

HTTP 401. No Authorization header, a malformed token, or a token that has been revoked.

Do: stop. Retrying cannot work. Tell the human to run ayt login or to set AGENTIC_YT_TOKEN to a token from Dashboard → Tokens. If a token is set, check for stray quotes or whitespace and that it starts with ayt_pat_.

See Authentication.

forbidden

HTTP 403. The token is valid but not allowed to do this.

Do: stop and report it. This is about the account's permissions, not the request; changing parameters will not help.

validation_failed

HTTP 400. A path, query or body parameter is missing, of the wrong type, or out of range — or a reference is not a recognisable YouTube id or URL.

Returned by: 26 of 30 operations.

Do: read message. It names each offending field and what is wrong with it, for example Invalid body — end: end must be greater than start. Fix exactly that and retry once. Do not retry unchanged.

Common causes: format that does not match kind (mp3 for a video), a time like 1:75, limit above 100, more than 50 frame timestamps, wait above 60.

A job can also end failed with this code when the problem only shows once the video has been inspected — a frame timestamp beyond the end of the video, for instance.

not_found

HTTP 404. The thing you named does not exist: an unknown job id, a channel or playlist that cannot be found, or a transcript in a language the video does not have.

Returned by: getVideoTranscript, getChannel, listChannelVideos, getPlaylist, listPlaylistVideos, getJob, cancelJob, pollDeviceLogin.

Do: depends on what was missing.

  • Transcript: call ayt languages <ref> and retry with a language that exists, or with --translate-to.
  • Channel or playlist: check the reference; a private playlist looks the same as a missing one.
  • Job: the id is wrong, or the job belongs to another account. List yours with ayt jobs list.

video_unavailable

HTTP 404. The video exists as an id but cannot be read: it is private, deleted, region-locked, age-restricted, or members-only.

Returned by: getVideo, getVideoFormats, getVideoThumbnail, getVideoTranscript, listTranscriptLanguages, listVideoComments, createDownload, createClip, createFrames.

Do: do not retry as-is — the answer will not change. Tell the human which video and why (message says). If they have a connected YouTube account with access to it, retrying with use_account: true (--account) can work. If the video was deleted, nothing will.

account_required

HTTP 403. The operation needs a connected YouTube account and there is none, or the connected one is invalid or disabled. You get it from the /v1/me/… lists, and from any job sent with use_account: true.

Returned by: createDownload, createClip, createFrames, listMyPlaylists, listMySubscriptions, listMyLiked, listMyWatchLater.

Do: stop and ask the human. Connecting a YouTube account means handing over a login session and accepting a risk to that account; it is not something an agent should do, or route around, on its own. Point them at Your own YouTube account. If you set use_account: true yourself and did not strictly need it, retry without it.

youtube_blocked

HTTP 502. YouTube refused the request — rate limiting, a bot check, or a temporary block on the server's address. The problem is upstream, not in your request.

Returned by: 18 of 30 operations.

Do: wait and retry the same request, with backoff: 30 seconds, then a couple of minutes, then stop and report. If the human has a connected YouTube account, retry a job with use_account: true. Meanwhile, anything already cached still works — a video call without --fresh may succeed where a fresh one is blocked.

quota_exceeded

HTTP 429. The account has used its daily quota of requests that reach YouTube.

Do: stop making uncached requests until the reset. The Retry-After header gives the seconds until then, and ayt usage (GET /v1/me/usage) shows today.resets_at — midnight UTC. Cache hits do not use quota and keep working. Tell the human; an admin can raise the quota. See Limits and quotas.

too_long

HTTP 422. The video is longer than the maximum duration (4 hours), so it cannot be downloaded or have frames extracted as a whole.

Returned by: createDownload, createClip, createFrames.

Do: clip the section you need instead. If you need to understand the whole thing, get the transcript — it has no duration limit.

rate_limited

HTTP 429. Too many requests in a short time, or the account already has 3 jobs in flight.

Do: wait and retry the same request. Retry-After says how long (a few seconds). For the job limit, message says so: long-poll one of your running jobs (ayt jobs get <id> --wait) and submit the next when it finishes. Do not fan out more than 3 downloads, clips or frame jobs at once.

job_failed

HTTP 500, and the usual code on a job that ended failed for a reason with no more specific code — the transcode failed, the download broke off.

Do: read the job's error.message. Retry once by sending the original POST again, which creates a new job. If it fails the same way, stop and report; a different format or quality sometimes sidesteps a bad source stream.

internal

HTTP 500. An unexpected error on the server. The message is deliberately generic.

Do: retry once after a few seconds. If it persists, stop and report it with the request you made; check ayt health.

A handler, in outline

switch (error.code) {
  case "validation_failed":
  case "not_found":
  case "too_long":
    return fixRequest(error.message, error.hint);   // change something, retry once
  case "rate_limited":
  case "youtube_blocked":
  case "internal":
  case "job_failed":
    return retryWithBackoff();                       // same request, later, bounded
  case "quota_exceeded":
    return stopUntil(retryAfter);
  case "video_unavailable":
    return skipVideo(error.message);
  case "unauthorized":
  case "forbidden":
  case "account_required":
    return askHuman(error.message, error.hint);
}

On this page