# Snap That Piece auth.md

You are an agent. This document tells you how to register a credential for the **Snap That Piece API preview**, which reads a chess position from a photo of a real board.

This is the auth.md **verified email** method (`verified_email`) in the user claimed flow: you name the person's verified email address, they claim your request while signed in, and you collect the credential.

Endpoints live at `https://app.snapthatpiece.com`. The claim happens at `https://app.snapthatpiece.com/settings`.

## Audience

Agents and scripts acting for a person who has a Snap That Piece account. An MCP client doesn't need this flow: it connects to `https://app.snapthatpiece.com/mcp` and the person signs in with OAuth. Browsing the website, reading its markdown pages and using the links into the web app need no credentials at all. See [agents.md](https://snapthatpiece.com/agents.md).

## Discovery

- This file: `https://snapthatpiece.com/auth.md`
- API catalog: [snapthatpiece.com/.well-known/api-catalog](https://snapthatpiece.com/.well-known/api-catalog)
- OpenAPI description: [app.snapthatpiece.com/api/v1/openapi.json](https://app.snapthatpiece.com/api/v1/openapi.json)
- API docs: [snapthatpiece.com/developers/](https://snapthatpiece.com/developers/)
- Agent skill: [snapthatpiece.com/.well-known/agent-skills/snap-that-piece/SKILL.md](https://snapthatpiece.com/.well-known/agent-skills/snap-that-piece/SKILL.md), listed in [the skills index](https://snapthatpiece.com/.well-known/agent-skills/index.json)
- MCP server card: [snapthatpiece.com/.well-known/mcp/server-card.json](https://snapthatpiece.com/.well-known/mcp/server-card.json)
- OAuth metadata, for MCP clients: [the authorization server](https://app.snapthatpiece.com/.well-known/oauth-authorization-server) and [the protected resource](https://app.snapthatpiece.com/.well-known/oauth-protected-resource). Authorization code with PKCE and dynamic client registration, one scope, `scan`.

## Registration

An agent registers by asking a person for access, and gets a credential of type `api_key`. The agent shows a code and the person gets an email, so they can tell the request is theirs. An agent can't provision an account, accept the terms or approve anything itself.

### 1. Ask

Send the agent's name and the person's email address. No credentials are needed.

```http
POST /api/agent/auth/register HTTP/1.1
Host: app.snapthatpiece.com
Content-Type: application/json

{"agent_name": "Board Reader", "email": "person@example.com"}
```

`agent_name` is 1 to 40 letters, digits, spaces, `-` or `_`. A valid request gets `202`, whether or not the address has an account:

```json
{
  "claim_id": "...",
  "status": "pending",
  "user_code": "K7PM-3QXD",
  "expires_at": "2026-10-30T15:42:04+00:00",
  "poll": "/api/agent/auth/claims/...",
  "next": "Show the person the code ..."
}
```

### 2. Have the person approve

Show the person `user_code` and send them to [app.snapthatpiece.com/settings](https://app.snapthatpiece.com/settings). If their account has a verified email address, they also get an email. Under API access they see your agent's name and the code, check the code against the one you showed, accept the terms, and approve or deny.

Their approval is this request, which Settings sends with their signed-in session. You can't send it:

```http
POST /api/developer/claims/{claim_id}/approve HTTP/1.1
Host: app.snapthatpiece.com
Content-Type: application/json

{"accept_terms": true}
```

The person needs an account with a verified email address. Without one no email is sent and the request shows nowhere. They can sign up in the web app and create a key there themselves, then give it to you.

### 3. Collect the key

Poll the `poll` path every few seconds, for up to 30 minutes:

```http
GET /api/agent/auth/claims/{claim_id} HTTP/1.1
Host: app.snapthatpiece.com
```

Once the person has approved, the answer carries the credential:

```json
{"status": "approved", "key": "stp_..."}
```

`key` is your bearer credential. Use it straight away.

| `status` | Meaning |
| --- | --- |
| `pending` | Not answered yet. Keep polling. |
| `approved` | The answer carries `key`, the secret. It's shown this one time, so store it now. |
| `delivered` | The key was already collected. |
| `denied` | The person said no, or the approval no longer stands because they changed their key or approved another request. Ask again only if they want you to. |
| `expired` | Nobody answered in 30 minutes. Start again with a new request. |

A request is removed soon after it expires, and then answers `404` with `not_found`. Treat that like `expired`. An approved key has to be collected within 30 minutes of the approval.

An account has one key. Collecting a key replaces any key the account already had, and the old one stops working.

### Limits on registration

10 requests an hour from one IP address, and 3 an hour and 6 a day for one email address. Polling allows 60 requests a minute from one IP address. Over a limit, the answer is `429` with a `Retry-After` header.

Errors have an `error` code and a `message`: `bad_request`, `bad_agent_name`, `bad_email`, `rate_limited`, and `not_found` for a request that doesn't exist.

## Supported method

One credential type, `api_key`: a bearer API key, tied to the person's account. Every key can do the same things. A person can also create a key themselves in Settings and give it to you, which works the same way. An OAuth access token works in place of a key, with the same limits, since they count per person.

## Credential use

Send the key on every request to `/api/v1/`, for example:

```http
GET /api/v1/usage HTTP/1.1
Host: app.snapthatpiece.com
Authorization: Bearer stp_...
```

- The same key reports a wrong read: `POST /api/v1/scans/{id}/rating` and `POST /api/v1/scans/{id}/correct`. See the [API docs](https://snapthatpiece.com/developers/#report-a-wrong-read).
- A missing or invalid key gets `401` with `WWW-Authenticate: Bearer`.
- Keep the key out of logs, prompts and anything shared. It acts for the person: anyone holding it can send photos as them, read the results of scans sent with a key, and change those scans' position and rating.

## Limits and rules

- The preview allows 5 scans a day per account. A new key doesn't reset that.
- A result may be used to answer the person who asked for it. It may not be used to train or fine-tune models, to build a dataset, or be sold or redistributed. See the [Terms of Service](https://snapthatpiece.com/terms/).

## Revocation

The person can replace or revoke the key in Settings at any time, and the old key stops working at once. Deleting the account also ends it. After a `401`, ask the person again.
