Skip to Content
agentic-yt

Authentication

Personal access tokens, ayt login, and the AGENTIC_YT_TOKEN environment variable.

Every operation except GET /v1/health and the two CLI-login endpoints needs a personal access token in the Authorization header:

Authorization: Bearer ayt_pat_…

A token is ayt_pat_ followed by 43 URL-safe characters (32 random bytes). It carries your whole account: its daily quota, its jobs and, if you connected one, its YouTube account. There are no scopes.

The server stores only the SHA-256 hash of a token. The plaintext is shown once, when it is created, and cannot be recovered afterwards — if you lose it, revoke it and make another.

Getting a token

From the dashboard

Dashboard → Tokens → name it → Create token → copy it. Name tokens after where they live (ci, claude-code on laptop); the list shows each token's prefix and when it was last used, which is how you find the one to revoke.

With ayt login

ayt login

This is a device-code flow, for machines where pasting a secret is awkward:

  1. The CLI calls POST /v1/cli/device and receives a user_code like BCDF-2345, a secret poll_token, and a verification_url.
  2. It prints the code and opens verification_url_complete — the dashboard's /cli page with the code pre-filled. If no browser can be opened (--no-browser, SSH), open the URL yourself.
  3. You sign in to the dashboard, check the code matches the one in your terminal, and approve.
  4. The CLI, which has been calling POST /v1/cli/device/token every couple of seconds, receives the new token on its next poll — exactly once — and saves it.

Codes expire after ten minutes and work once. The token created this way appears on the tokens page like any other, named after the client, and revoking it there signs that machine out.

ayt login --token ayt_pat_… stores a token you already have without the browser round-trip. ayt logout forgets the saved token locally; it does not revoke it on the server.

Where the CLI looks for a token

In order:

  1. AGENTIC_YT_TOKEN in the environment.
  2. The saved profile in ~/.agentic-yt/config.json (mode 0600), written by ayt login.
VariablePurpose
AGENTIC_YT_TOKENPersonal access token. Beats the saved one.
AGENTIC_YT_URLAPI base URL. Default https://api.agentic-yt.crafter.run.
AGENTIC_YT_PROFILEWhich saved profile to use; --profile beats it.
AGENTIC_YT_CONFIGPath of the config file.

For an agent, prefer the environment variable: it survives a fresh container and never touches disk.

Who am I?

ayt whoami        # account, token source, profile, API URL — exit code 3 if not signed in
ayt me --json     # the full GET /v1/me response

GET /v1/me returns the account (id, email, role, daily_quota), the token making the request, the state of the connected YouTube account, and the limits that apply — a cheap first call for an agent to confirm its credential works before starting real work.

When it fails

A missing, malformed or revoked token answers 401 with code unauthorized. Retrying will not help; the agent needs a human to run ayt login or supply a new token.

The dashboard is not the API

The dashboard signs humans in with Clerk and reads the database directly. A Clerk session is not a credential for api.agentic-yt.crafter.run, and a personal access token does not sign you in to the dashboard.

On this page