# Petodo auth.md

How an AI app or agent signs in to Petodo, the to-do list a person shares with their AI agents.

- MCP server: https://app.petodoapp.com/api/mcp
- REST API: https://app.petodoapp.com/api (OpenAPI: https://petodoapp.com/petodo/openapi.json)

There are two ways in. Both end in the same thing: a key tied to one agent, sent as a bearer token.

## 1. OAuth 2.1 (for apps with a connector directory)

The person never sees a key. Petodo follows the MCP authorization spec.

1. Call the MCP server without a key. It answers 401 with a WWW-Authenticate header that points at the protected resource metadata: https://app.petodoapp.com/.well-known/oauth-protected-resource/api/mcp
2. The authorization server is https://app.petodoapp.com, and its metadata (RFC 8414) is at https://app.petodoapp.com/.well-known/oauth-authorization-server
3. Register the client. Either POST to https://app.petodoapp.com/api/oauth/register (dynamic client registration, RFC 7591) or use an https address that serves your own metadata as the client_id (a Client ID Metadata Document). Redirect addresses must be https, http on localhost, 127.0.0.1 or [::1], or the app's own scheme.
4. Send the person to https://app.petodoapp.com/api/oauth/authorize with response_type=code, a code_challenge and code_challenge_method=S256. Only the authorization code grant and PKCE S256 are supported.
5. On Petodo's page the person signs in, picks the @handle the app answers as (a new one, or one of their agents of that kind), and presses Allow. They can tick "Only let it read" for a read-only key.
6. Exchange the code at https://app.petodoapp.com/api/oauth/token with your code_verifier and the same redirect_uri. The answer is an access_token (Bearer) and the petodo_handle. It has no expiry and no refresh token: it lasts until it is revoked.
7. Revoke it at https://app.petodoapp.com/api/oauth/revoke (RFC 7009) with the token and your client credentials. The person can also remove it in Settings, Your agents.

Scopes: `agent` (the person's errands and list) and `agent:read` (the same, read only). A read-only key is refused every change.

## 2. Agent keys

The person makes a key for you: in the app under Settings, Account & sync, Set up an assistant (the one key the free plan allows), or under Settings, Your agents, Connect (a key for a connected agent, part of the subscription), or from a terminal, after `petodo login`, with `petodo keys create "Name"`. They paste it into your app. Send it on every request:

```
Authorization: Bearer YOUR_KEY
```

`X-Api-Key: YOUR_KEY` works too. A missing or wrong key is a 401.

## What a key can and cannot do

A key reaches the person's list and the errands for the agents pointed at it, and nothing else. It cannot read the account's email address, make another key, approve a device, or manage the account; those answer 403 on purpose, so that revoking a key really ends access. It cannot read another key's errands. Assistant keys may read the list 120 times an hour per account (429 after that); an agent's errand check-ins are limited to 120 an hour per key.

One assistant key, which reaches the person's list, works on the free plan; asking for a second key without the subscription answers 402 (code key_limit). Connecting an agent (including from a connector directory) and the errands routes are part of the subscription, and answer 402 (code pro_required) without it. An account whose free week or subscription has ended is locked and answers 402 (code locked) to everything but signing in and paying.
