1
Discover
On a 401 from a gated endpoint (campaigns, MCP, keys, billing), read the The second document carries the
WWW-Authenticate header. It carries resource_metadata pointing at the Protected Resource Metadata document. You can also fetch the well-known URLs directly:agent_auth block. agent_auth.identity_endpoint and agent_auth.claim_endpoint are the registration and claim URLs below. identity_types_supported lists which registration methods the service accepts.2
Pick a method
The service accepts one identity type:
anonymous. Registering with service_auth returns 400 service_auth_not_enabled; identity_assertion returns 400 issuer_not_enabled. Both are terminal: fall back to anonymous.3
Register anonymously
starcovery auth register --ref YOURCODE (or the STARCOVERY_REF environment variable). Invalid codes do not fail registration.The response carries registration_id, a service-signed identity_assertion with assertion_expires, pre_claim_scopes, and claim materials: claim_url, claim_token, claim_token_expires, and post_claim_scopes.Registrations are capped at 100 per UTC day. Past the cap the endpoint answers 429 with error rate_limited.4
Exchange the assertion for an access token
access_token with expires_in. Re-run the exchange with the same identity_assertion when the access token expires. There is no refresh token: the assertion is the long-lived half. Each exchange retires the previous token, so hold exactly one and re-fetch when it lapses.5
Call the API
x-api-key header is accepted as well, with the same token. MCP requires a credential too; see Connect over MCP.Claim ceremony (optional)
Run the claim only when a human wants to own the account. Ask the service to start the ceremony:claim_attempt block with a 6-digit user_code, verification_uri, expires_in, and interval. Starcovery emails a one-time link to the supplied address. The emailed link is the half you never see; the user_code travels only through you. Neither channel alone finishes the ceremony: the mailbox proves the human identity.
Tell the person in one message: open the link emailed to them, then enter the 6-digit code. They set a password on that page and the account is theirs.
Disposable, reserved, or undeliverable addresses return undeliverable_email before initiation. If the claim returns mail_send_failed, ask for a deliverable inbox and retry.
Poll the token endpoint until it stops answering authorization_pending, honoring interval:
access_token and a fresh identity_assertion. Pre-claim access tokens are revoked at that moment: drop them and use the new one.
If the user_code window closes, call the claim endpoint again with the same claim_token and email for a fresh code. The new code and link replace the previous pair immediately.
Scopes
Registration returnspre_claim_scopes and post_claim_scopes; on this service they are the same set. Claiming does not widen API access. It gives a human the account (sign-in, credit packs, billing) while the credential, credits, and history carry over. The user id never changes.