Skip to Content
agentic-yt

Your own YouTube account

Optionally connect a YouTube account with cookies.txt — what it unlocks, what it risks, and how to disconnect.

Connecting a YouTube account is optional. Search, metadata, transcripts, comments, and downloads of public videos all work without one.

Use a secondary account

Automated access is against YouTube's terms of service, and Google can restrict or suspend an account it sees used this way. Connect an account you made for this purpose — never your main one, and never one tied to purchases, a channel you care about, or your primary Google identity.

What it is for

  1. Videos an anonymous visitor cannot see but your account can: age-restricted videos, members-only videos for channels you have joined, private videos shared with you.
  2. A fallback when YouTube refuses anonymous requests to a video that is otherwise public.
  3. Your own lists: playlists (including private ones), subscriptions, liked videos and Watch Later.

What happens to your cookies

  • They are encrypted at rest with AES-256-GCM before they are stored.
  • They are never returned by any endpoint. The API can tell you an account is connected; it cannot show you the cookies.
  • They are used read-only. agentic-yt reads videos and lists. It never likes, comments, subscribes, uploads, or changes anything on the account.
  • They are deleted when you disconnect.

Cookies are a full login session, not a scoped permission. That is the reason for the secondary account.

When your account is used

By default, only as a fallback: every job and request is tried anonymously first, and your account is used only if that is refused.

use_account on download, clip and frames changes that per request:

use_accountCLI flagBehaviour
omitted—Anonymous first, your account as fallback.
true--accountUse your account. account_required if none is connected.
false--no-accountNever use your account for this request.

Anything fetched with your account is cached privately. Other accounts never get a cache hit on it, and it does not appear in the shared cache.

Connect

1. Export cookies.txt

  1. Open a private browser window and sign in to youtube.com with the secondary account.
  2. Export the cookies for youtube.com in Netscape format — the tab-separated cookies.txt format — with a browser extension you trust.
  3. Close the private window without signing out. Signing out invalidates the session you just exported; so does using that session in a normal browser window afterwards.

2. Upload it

In the dashboard: YouTube account → paste the file or choose it → confirm you have read the risks → Connect account.

From the CLI:

ayt account connect --cookies ./cookies.txt --label "secondary"
ayt account connect --from-browser chrome     # reads the cookies locally; needs yt-dlp installed

Over HTTP:

jq -Rs '{cookies: ., label: "secondary"}' cookies.txt |
  curl -X PUT "https://api.agentic-yt.crafter.run/v1/me/youtube-account" \
    -H "Authorization: Bearer $AGENTIC_YT_TOKEN" \
    -H "Content-Type: application/json" \
    -d @-

The body is { "cookies": "<file contents>", "label": "<optional name>" }. cookies may be up to 512 KB; export only the youtube.com cookies if your file is larger. PUT replaces any account already connected — there is one per agentic-yt account.

Delete the local cookies.txt afterwards.

Status

ayt account status --json
{
  "connected": true,
  "label": "secondary",
  "status": "active",
  "last_used_at": "2026-11-26T13:58:12.000Z",
  "connected_at": "2026-11-20T09:15:00.000Z"
}
statusMeaning
activeWorking.
invalidYouTube rejected the cookies — usually they expired, or the session was signed out. Export fresh ones and connect again.
disabledTurned off by an administrator.
nullNothing connected (connected: false).

Cookies do not last forever. Expect to re-export every few weeks to months; invalid is the signal.

Your lists

All four need a connected account, take limit and cursor, and return next_cursor:

CommandEndpointReturns
ayt me playlistsGET /v1/me/playlistsplaylists — id, title, channel, video_count, thumbnail
ayt me subscriptionsGET /v1/me/subscriptionschannels — id, handle, name, subscriber_count
ayt me likedGET /v1/me/likedvideos — the usual video summaries
ayt me watch-laterGET /v1/me/watch-latervideos

A playlist id from ayt me playlists works with ayt playlist <id> --videos.

Disconnect

ayt account disconnect

DELETE /v1/me/youtube-account deletes the stored cookies and returns { "deleted": true } (false when there was nothing to delete). The dashboard has the same button. Files already cached privately for you stay yours.

To also end the session on Google's side, sign that account out of all devices in its Google security settings.

Errors to expect

  • account_required — an operation needs a connected account and there is none (or it is invalid). An agent should stop and ask its human; connecting an account is a decision with consequences, not a retry strategy.
  • youtube_blocked — YouTube refused even with the account.
  • validation_failed — cookies is empty or over the size limit.

On this page