# FlashData agent authentication

Coding and personal agents share one flow:
discover → temporary account and API key → first query → human claim → owner API key → recurring use.

## Choose and reuse access first

Start with https://flashdata.dev/agents.md to select CLI, MCP or SDK/HTTP for the task.
Reuse a valid configured API key or saved owner connection when one is available.
Existing owner access does not require registration or claiming. Invalid, expired,
revoked or exhausted access needs recovery; do not silently create a new trial.

An existing verified owner can also connect through MCP OAuth. The host owns
browser login, protected token storage and refresh. OAuth access tokens authorize
https://data.flashdata.dev/mcp; they are not API keys for REST query endpoints.
OAuth setup and the access matrix: https://flashdata.dev/docs/guides/agent-access/reference.md
Host guides: https://flashdata.dev/docs/integrations/codex/reference.md and https://flashdata.dev/docs/integrations/openclaw/reference.md
Agent skill installation: https://flashdata.dev/docs/guides/agent-skill/reference.md

This document specifies the temporary-access HTTP protocol. A compatible CLI
can manage this lifecycle on the agent's behalf. API queries and billing use
the same Data API for temporary and owned keys. Claiming does not automatically
create an OAuth connection or authorize payments.

## CLI onboarding

Download the standalone CLI v1.4.0 for Linux, macOS or Windows (no Node.js or Python required; also on Homebrew, PyPI via `uv tool install flashdata-cli`, and signed APT/RPM repos):
https://github.com/flashdatadev/flashdata-cli/releases/tag/v1.4.0
Installation, checksums and command guide:
https://flashdata.dev/docs/guides/flashdata-cli/reference.md

With the executable installed, run from the agent's project directory:

```bash
flashdata setup
flashdata auth status
```

Setup offers Codex, Claude Code and Cursor, installs 16 bundled CLI skills and
reuses saved access or requests one eligible trial. It runs no paid query.
For unattended setup, specify the host explicitly, for example
`flashdata setup --agent codex --non-interactive`.
Use `--skip-auth` for offline skill installation only.
For terminal-only access, use `flashdata init --name "My CLI"` instead of setup.
Other skill hosts can install from https://github.com/flashdatadev/flashdata-skills.

Run the first task after checking access:

```bash
flashdata search "battery recycling research" --num 5
```

When continued access is needed, run `flashdata auth claim`. The owner completes
signup, email verification and consent in the browser. Then run
`flashdata auth finish --wait --timeout 10m` and `flashdata auth status`.
Keep the same profile throughout; do not create a replacement trial.

Official skills: https://github.com/flashdatadev/flashdata-skills. The optional `flashdata-mcp` skill is separate
from the CLI skills and requires a configured MCP connection.
Official MCP server: https://github.com/flashdatadev/flashdata-mcp.

Reuse the same profile and protected state for every step. Existing account holders
can use auth login with hidden terminal input, or --api-key-stdin --non-interactive
with input supplied by their secret manager. No key belongs in command arguments.
Set --state-dir to one absolute private directory on every command when the host
does not use the default ~/.flashdata. Keep --profile unchanged throughout.
An explicitly configured FLASHDATA_API_KEY overrides saved credentials for that
command; select the intended access before testing a saved connection.

Windows uses DPAPI and macOS uses Keychain. For a new headless Linux profile,
CLI v1.4.0 can fall back to a private plaintext file (0600; directory 0700)
when the desktop keyring is unavailable. --credential-store os requires OS protection.
Existing encrypted profiles do not silently downgrade. Inspect credentialProtection
in auth status; never print vault contents or put keys in scheduler configuration.

The following sections describe the equivalent HTTP lifecycle for other clients.
Go SDK v1.3.0 (Go 1.25+): https://github.com/flashdatadev/flashdata-go/releases/tag/v1.3.0
Install in an application's Go module with `go get github.com/flashdatadev/flashdata-go@v1.3.0`.
The SDK provides the HTTP lifecycle but the caller owns durable proof/credential
storage, installation verification and task scheduling; it has no CLI run journal.
SDK guide: https://flashdata.dev/docs/guides/flashdata-go/reference.md

## Discover

GET https://api.flashdata.dev/v2/agent-connections/capabilities

Continue only for protocolVersion 2 and available true. A 404, 503 or unavailable
response means onboarding is disabled. Existing signup: https://flashdata.dev/signup.
MCP instructions: https://flashdata.dev/docs/mcp/reference.md. CLI/API clients require protected
persistent storage; browser-only hosts need a supported host adapter.

Management origin: https://api.flashdata.dev
Data origin: https://data.flashdata.dev
Pin both origins in your configuration; never forward a key to an arbitrary returned URL.

## Request product permissions

Capabilities.permissions is the current catalog: source, name, product,
trialEligible, ownerAllowed and requiresStorageDestination. Request only the
sources your task needs; owner permission and free-trial eligibility are separate.
The HTTP protocol and claim page require no per-product permission allowlist.

| Source | Product | Trial | Owner approval |
| --- | --- | --- | --- |
| google_search | google_search | Yes | Available |
| google_images | google_search | No | Available |
| google_news | google_search | No | Available |
| google_shopping | google_search | No | Available |
| google_videos | google_search | No | Available |
| google_places | google_search | No | Available |
| youtube_search | youtube_data | Yes | Available |
| youtube_search_extended | youtube_data | No | Available |
| youtube_metadata | youtube_data | Yes | Available |
| youtube_transcript | youtube_data | Yes | Available |
| youtube_captions | youtube_data | Yes | Available |
| youtube_trainability | youtube_data | No | Available |
| youtube_channel | youtube_data | No | Available |
| youtube_suggestions | youtube_data | No | Available |
| youtube_download | youtube_download | No | Available |

YouTube Download is available after owner approval, never on anonymous trial
credits. It uses the normal asynchronous download API, account pricing and a
configured storage destination; it is not a realtime search request.
Catalog and input schemas: GET https://api.flashdata.dev/v2/catalog/sources.

## Register

POST /v2/agent-connections/registrations on the management origin.
Authorization: Bearer <registration-proof>
Content-Type: application/json
Body: {"name":"Research assistant","scopes":["google_search"]}

Generate 32 random bytes as unpadded base64url (43 characters). Persist that
registration proof BEFORE sending. Retry lost responses with the same proof and
body. Optional audience (coding or personal) is descriptive metadata only.
Optional client identifies the host (for example codex or openclaw; lowercase letters,
digits, underscores and hyphens, at most 64 characters). Optional transport is api,
cli or mcp. These self-reported labels appear in the admin portal and never grant
access. Keep them unchanged when retrying a registration.

Save credentials.apiKey, credentials.setupCredential and credentials.handoffProof
in protected storage. The API key is an ordinary fd_ key on an isolated temporary
account with 1 credit (up to **50 Google searches** or **100 YouTube data requests**), valid for 72 hours. Request equivalents share one credit balance.
Capabilities report current trial.requestCounts; connection.trialRequestCounts uses
that trial's saved prices and describes its starting allowance.
Limits use the standard account
controls: 1 request/second, batch size 1, pending job limit 1. Sources are
listed in connection.trialScopes, restricted to explicitly requested eligible sources.
The credit allowance limits billed usage; it is not a fixed number of queries.

connection.requestedScopes preserves the original owner-access request;
connection.scopes is the CURRENT key's actual access, and connection.permissions
describes those requested sources. deniedScopes contains unsupported requests,
not owner-only sources waiting for approval. Owners can reduce the original
request; neither claiming nor a catalog update silently adds new sources.
For example, requesting google_search and youtube_download gives a search-only
trial key and lets the owner approve either or both. A download-only HTTP request
returns nextAction: claim, an empty scopes array and null trialRequestCounts.
That temporary key authenticates onboarding but cannot query any data source.
Proceed directly to claiming before the first download.

Published CLI v1.4.0 and Go SDK v1.3.0 still require at least one of
the five original trial sources when registering: google_search, youtube_search,
youtube_metadata, youtube_transcript or youtube_captions. Their typed capabilities
do not expose the permission catalog; read capabilities.permissions through HTTP.
For an owner-only request such as youtube_download, use this HTTP onboarding flow
or import an existing owner key with the required scope. Do not add an unrelated
trial source merely to pass client validation. Mixed requests using those clients
can include the task's required owner-only sources alongside a trial source.

## Complete the first task

POST https://data.flashdata.dev/v1/queries/realtime
X-API-Key: <saved API key>
Content-Type: application/json
Body: {"source":"google_search","query":"Your question"}

Use the normal data API for all queries, scopes, errors and billing. No management
execution endpoint is involved. Never print keys or put them in URLs, chats or source code.
The realtime API has no server-side replay contract. Do not automatically resend
an uncertain request. Compatible clients can persist run IDs and completed responses
locally; this prevents repeats only within their original protected state directory.

## Claim and install the owner key

POST /v2/agent-connections/{connectionId}/claims with {} using the setup credential
as a Bearer token. Show https://flashdata.dev/connect/claim/{claimId} and the eight-digit
confirmation code. The user signs in, confirms the code, reduces source scopes if
needed, and explicitly approves use of their shared account balance, including
purchased credits. There is no separate per-key spending cap and approval buys no credits.
New users create an account and verify their email; the signup browser resumes
this claim automatically. Code checking and consent stay on one page, and approval
always requires the user's explicit action.
An existing signed-in account is the owner shown on the consent page. To test a
new-account signup, open the claim URL in a private window. Show the confirmation
code separately; do not put it in the URL. The human handles signup, email
verification, legal acceptance and source/shared-balance approval.
The claim expires after 15 minutes or at trial expiry, whichever comes first.

Approval closes the temporary account, revokes its key, and issues an ordinary
API key on the owner's account. Unused trial credits do not transfer. Queries
already admitted on the temporary account remain charged to that account.
Verified-signup credits follow the normal account offer independently of claiming;
read account balance/pricing for that account instead of promising a fixed grant.

GET /v2/agent-connections/{connectionId}/onboarding using the handoff proof as Bearer.
Respect pollAfterSeconds. At handoff_ready, POST {} to the path ending in /handoff.
Save credentials.apiKey atomically and verify it from a fresh process by GETting
/v2/agent-connections/{connectionId}/identity with that saved API key as Bearer.
Then POST /v2/agent-connections/{connectionId}/handoff/ack with
{"apiKey":"<saved replacement>"}, authenticated by the handoff proof.

Handoff retrieval is retryable for 24 hours until acknowledged. The new key is
usable immediately and expires after 24 hours unless acknowledged. Acknowledgement
removes that installation expiry. No activation request is needed. Remove obsolete
proofs after acknowledgement. Never copy a key into chat for handoff.

## Recurring tasks

Schedule only work the user requests. Use the same installed owner key and private
state directory each run. For the CLI, first require auth status to report installed
owner access with recurringAllowed true. Run each occurrence in a fresh process:

```bash
flashdata query --input /absolute/path/daily-research.json --recurring --run-id daily-research:2026-10-24:Asia-Shanghai --state-dir /absolute/private/flashdata --profile research --json --non-interactive
```

Use the profile and state directory from onboarding. The example run ID identifies
one occurrence; the host supplies a new dated slot ID for the next intended run.
The host owns the schedule and keeps the executable, input and state paths and
timezone in its configuration, never the API key. Give each intended slot a stable run ID,
including timezone; retries reuse it. A client with a persistent run journal returns saved successful
results without another call, and stops on uncertain outcomes. Do not delete history
or change the ID just to repeat uncertain work. Local replay protection does not
coordinate across machines or copied state directories.

Stop on missing/revoked credentials, exhausted credits, an unknown result, or a
configuration conflict. Do not create another trial or purchase credits automatically.
Revocation is available in https://flashdata.dev/app/settings/connections and uses
the same API-key invalidation mechanism as other account keys.
After revocation, auth status, cached-result replay/export and new recurring runs
fail access checks with 401/403; local history remains, but the CLI does not return
saved result content through those commands or submit replacement work. Direct
Data API calls with that key are also rejected. auth logout only removes local
credentials; it does not revoke remote access.

## Guides and examples

- First application query: https://flashdata.dev/docs/guides/search-in-an-app/reference.md
- Video evidence with timestamps: https://flashdata.dev/docs/guides/youtube-summary/reference.md
- Google and YouTube research: https://flashdata.dev/docs/guides/google-youtube-research/reference.md
- Recurring work: https://flashdata.dev/docs/guides/recurring-tasks/reference.md
- Recovery decisions: https://flashdata.dev/docs/guides/agent-recovery/reference.md

