# Pieverse agent authentication and API token guide

Pieverse uses wallet-signed sessions as the canonical auth model for protected product surfaces.
Current public discovery endpoints require no credentials. Protected product writes, wallet policy changes, skill installs, invoice/payment actions, and agent provisioning require a Pieverse application session created from a wallet signature.
API token status for agents: public discovery requires no API token, Pieverse does not issue public product-write API tokens through these discovery endpoints today, and future scoped machine credentials would require registration, wallet-backed authority, scopes, rotation, and revocation.
Programmatic token flow when available: discover metadata, register through the documented register_uri, obtain a scoped token programmatically, then call protected product APIs with `Authorization: Bearer <token>` and `Idempotency-Key` on retryable writes.
Compatibility note: the section names below intentionally mirror the WorkOS agent-auth walkthrough structure for machine readers; Pieverse maps that structure to wallet-signed sessions today, not to a public OAuth client registration flow.

## Discover
Public discovery surfaces do not require credentials:
- https://pieverse.io/index.md
- https://pieverse.io/llms.txt
- https://pieverse.io/pricing.md
- https://pieverse.io/auth.md
- https://pieverse.io/sandbox.md
- https://pieverse.io/developers
- https://pieverse.io/developers.md
- https://pieverse.io/AGENTS.md
- https://pieverse.io/agents.md
- https://pieverse.io/CLAUDE.md
- https://pieverse.io/GEMINI.md
- https://pieverse.io/.github/copilot-instructions.md
- https://pieverse.io/.cursor/rules/pieverse-public-discovery.mdc
- https://pieverse.io/.well-known/agents.md
- https://pieverse.io/.well-known/agent-card.json
- https://pieverse.io/.well-known/oauth-protected-resource
- https://pieverse.io/.well-known/oauth-protected-resource.md
- https://pieverse.io/.well-known/oauth-authorization-server
- https://pieverse.io/.well-known/oauth-authorization-server.md
- https://pieverse.io/agent/auth
- https://pieverse.io/agent/auth/register
- https://pieverse.io/agent/auth/register.md
- https://pieverse.io/api-deprecation-policy.md
- https://pieverse.io/docs/llms.txt
- https://pieverse.io/api/llms.txt
- https://pieverse.io/openapi.json
- https://pieverse.io/.well-known/mcp.json
- https://pieverse.io/.well-known/mcp
- https://pieverse.io/mcp
- https://pieverse.io/.well-known/mcp/server-card.json
- https://pieverse.io/.well-known/webmcp.json
- https://pieverse.io/webmcp-register.js
- https://pieverse.io/.well-known/ai-catalog.json
- https://pieverse.io/.well-known/api-catalog
- https://pieverse.io/.well-known/agent-skills/index.json
- https://pieverse.io/.well-known/agent-skills/pieverse-public-discovery/SKILL.md
- https://pieverse.io/schemamap.xml
- https://pieverse.io/schema-org.jsonl
- https://pieverse.io/ask
- https://pieverse.io/api/agent-discovery/batch
- https://pieverse.io/api/agent-discovery/resources
- https://pieverse.io/api/agent-discovery/pricing
- https://pieverse.io/api/agent-discovery/auth
- https://pieverse.io/api/agent-discovery/sandbox
- https://pieverse.io/api/agent-discovery/status

### oauth-protected-resource
- Metadata URL: https://pieverse.io/.well-known/oauth-protected-resource
- The metadata describes protected Pieverse product resources for agents that understand RFC 9728.
- Public discovery resources remain zero-auth; protected product actions still require wallet-signed sessions.

### oauth-authorization-server
- Metadata URL: https://pieverse.io/.well-known/oauth-authorization-server
- This compatibility document advertises Pieverse's discovery-only machine-auth posture.
- It does not make public product writes or token issuance available.

## Pick a method
- Current method: wallet-signed session.
- Future machine-client method: scoped credentials once product execution APIs are intentionally public.

## Register
- register_uri: https://pieverse.io/agent/auth/register
- No public autonomous client registration is available today.
- Developers should use the public read-only discovery resources until protected SDK/API surfaces are opened.

## Claim
- Current human flow: connect a wallet in the Pieverse app, review the nonce, and sign it to claim a browser session.
- Current agent flow: use public discovery without credentials; do not claim product-write access through discovery metadata.
- Future machine-client flow: claim scoped credentials only after a wallet-backed identity assertion or operator approval is available.

## Use credential
- Current credential: the established Pieverse browser or messaging-app session for protected product actions.
- Public discovery endpoints must not require cookies, wallet signatures, bearer tokens, or user data.
- Future machine credentials should be sent as `Authorization: Bearer <token>` only to documented protected product APIs with the minimum requested scopes.
- Agents should send `Idempotency-Key` on retryable protected writes once those APIs are intentionally public.

## Errors
- 401: obtain or refresh a wallet-signed Pieverse session; inspect the `WWW-Authenticate` metadata URL when present.
- 403: the signed wallet is authenticated but lacks the required entitlement, ownership, or scope.
- 409: retry used a conflicting idempotency key or request body.
- 429: slow down and respect `Retry-After` or rate-limit headers.

## Revocation
- End the browser session to revoke local access.
- Rotate or remove future scoped machine credentials if they are introduced.
- Contact support@pieverse.io for account-level access issues.

## agent_auth
- Discovery entrypoint: https://pieverse.io/agent/auth
- register_uri: https://pieverse.io/agent/auth/register
- authorization_endpoint: https://pieverse.io/agent/auth/authorize
- token_endpoint: https://pieverse.io/agent/auth/token
- identity_types_supported: anonymous, identity_assertion
- anonymous credentials: none, public read-only discovery only.
- identity_assertion credentials: future wallet-backed identity assertions for scoped protected APIs.
- These endpoints are discovery/status surfaces for agents. They do not issue live access tokens for product writes.

## Agent auth quickstart
AI agents should authenticate to Pieverse according to the surface they are calling:
1. For public discovery, call `GET /llms.txt`, `GET /openapi.json`, `GET /auth.md`, `GET /pricing.md`, `GET /.well-known/api-catalog`, `GET /.well-known/webmcp.json`, or the docs-only MCP server without credentials.
2. For read-only public POST transports, send JSON to `/ask`, `/api/agent-discovery/batch`, `/.well-known/mcp`, `/api/mcp`, or `/mcp`. Include `Idempotency-Key` when retrying after a network failure.
3. If a protected Pieverse product route returns `401`, read the `WWW-Authenticate` resource metadata URL and obtain a wallet-signed browser session through the Pieverse app.
4. If Pieverse later opens scoped machine credentials, register through the documented `register_uri`, bind the client to a wallet-signed identity assertion, request the minimum scopes, then send `Authorization: Bearer <token>` on protected product APIs.
5. Never use public discovery metadata as proof that product-write API tokens, wallet-policy writes, skill installs, or payment execution are publicly available.

## Programmatic API tokens
- Current status: Pieverse does not issue public programmatic API tokens for product-write APIs through these discovery endpoints.
- Agents can read public docs, pricing, OpenAPI, API catalog, ARD, schema feeds, sandbox examples, and docs-only MCP resources without a token.
- When protected machine credentials are opened, the expected flow is:
  1. Read the protected-resource metadata and this auth document.
  2. Register a machine client through the documented register_uri.
  3. Bind the client to a wallet-signed identity assertion.
  4. Request scoped credentials for the minimum scopes needed.
  5. Send `Authorization: Bearer <token>` to protected product APIs.
  6. Send `Idempotency-Key` on retryable protected writes such as provisioning, invoices, payments, renewals, and wallet-policy changes.
  7. Rotate or revoke credentials when operator, wallet, or ownership state changes.

## Protected surfaces
- A2A merchant and agent SDK docs
- Purr-Fect Claw instance management
- Skill installation and merchant workflows
- Wallet policy approvals and on-chain actions

## Session flow
1. Client signs in through Privy (social, email, passkey or an external EOA wallet).
2. The client sends Privy's signed identity token, or a SIWE message signed by the active wallet.
3. The backend verifies the token or signature and binds the session to the wallet address.
4. The backend issues the application session.
5. Protected product pages and API calls rely on that signed session and server-side authorization.

## Future machine-client scopes
- read:agent-discovery
- read:pricing
- read:sandbox
- read:status
- write:* is not public in this OpenAPI milestone

## Idempotency for protected writes
- Public discovery APIs are GET/read-only except for read-only ask/MCP helper POSTs; they do not create product state.
- Future protected write APIs should accept an `Idempotency-Key` header so autonomous agents can retry safely after timeouts.
- The same key should return the original result for the same authenticated actor and request body, and reject conflicting replays.
- High-risk flows that need idempotency: Purr-Fect Claw provisioning, invoice/payment creation, subscription renewal, skill installation, and wallet-policy updates.

## Error response examples
```json
{
  "unauthenticated": {
    "status": 401,
    "code": "UNAUTHENTICATED",
    "message": "A wallet-signed session is required for this protected surface."
  },
  "forbidden": {
    "status": 403,
    "code": "FORBIDDEN",
    "message": "The signed wallet does not have access to this resource."
  },
  "validation": {
    "status": 400,
    "code": "INVALID_REQUEST",
    "message": "The request body or query did not match the documented shape."
  }
}
```

## Recovery guidance
- If a protected route returns 401, obtain or refresh a wallet-signed session.
- If a protected route returns 403, the signed wallet is authenticated but lacks access.
- Public discovery endpoints should not require cookies, wallet signatures, or user data.
