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
- 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.
- A fallback when YouTube refuses anonymous requests to a video that is otherwise public.
- 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_account | CLI flag | Behaviour |
|---|---|---|
| omitted | — | Anonymous first, your account as fallback. |
true | --account | Use your account. account_required if none is connected. |
false | --no-account | Never 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
- Open a private browser window and sign in to youtube.com with the secondary account.
- Export the cookies for
youtube.comin Netscape format — the tab-separatedcookies.txtformat — with a browser extension you trust. - 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 installedOver 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"
}status | Meaning |
|---|---|
active | Working. |
invalid | YouTube rejected the cookies — usually they expired, or the session was signed out. Export fresh ones and connect again. |
disabled | Turned off by an administrator. |
null | Nothing 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:
| Command | Endpoint | Returns |
|---|---|---|
ayt me playlists | GET /v1/me/playlists | playlists — id, title, channel, video_count, thumbnail |
ayt me subscriptions | GET /v1/me/subscriptions | channels — id, handle, name, subscriber_count |
ayt me liked | GET /v1/me/liked | videos — the usual video summaries |
ayt me watch-later | GET /v1/me/watch-later | videos |
A playlist id from ayt me playlists works with
ayt playlist <id> --videos.
Disconnect
ayt account disconnectDELETE /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 isinvalid). 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—cookiesis empty or over the size limit.
Operations covered
GET/v1/me/youtube-accountWhether a YouTube account is connectedPUT/v1/me/youtube-accountConnect (or replace) your YouTube account from cookies.txtDELETE/v1/me/youtube-accountDisconnect your YouTube account and delete its cookiesGET/v1/me/playlistsPlaylists of the connected YouTube accountGET/v1/me/subscriptionsChannels the connected YouTube account subscribes toGET/v1/me/likedVideos the connected YouTube account likedGET/v1/me/watch-laterThe connected YouTube account's Watch Later list