# Beanie Xchange auth.md

How a software agent gets and uses a credential for https://beaniexchange.com.

## Who this is for

Agents acting for a person who wants to browse, buy or sell on Beanie
Xchange. Every account belongs to a person. An agent may create or use an
account only on that person's instruction, with an email address they
control, and after they have read and agreed to the
[Terms of Service](https://beaniexchange.com/terms) and
[Privacy Policy](https://beaniexchange.com/privacy). Do not register accounts on your own
initiative, and do not register more than one for the same person.

## What needs no credential

Reading the catalogue, live listings and sold-price data is public. The
endpoints are described in [/openapi.json](https://beaniexchange.com/openapi.json)
and listed in the API catalog at
[/.well-known/api-catalog](https://beaniexchange.com/.well-known/api-catalog). They are rate
limited per client address; a `429` response means slow down.

The same read-only data is available as tools from the MCP server at
`https://beaniexchange.com/mcp` (Streamable HTTP, no credential), described by
[/.well-known/mcp/server-card.json](https://beaniexchange.com/.well-known/mcp/server-card.json).

## Agent registration

Supported methods: one. An agent registers by creating an account for the
account holder with their email and a password, and receives a bearer
token. Registration endpoint: `POST https://beaniexchange.com/api/mobile/auth/register`
(details under Register below). There is no OAuth authorization server, no
client registration, no anonymous credential and no identity-assertion
flow, so the site publishes no OAuth metadata under `/.well-known/`.

## Register

```http
POST /api/mobile/auth/register
Content-Type: application/json

{
  "name": "Account holder's name",
  "email": "holder@example.com",
  "password": "at least 8 characters",
  "agreedToTerms": true
}
```

`agreedToTerms` records the account holder's agreement, not the agent's;
send `true` only when they have given it. A successful response is
`200` with `{ "token": "...", "user": { ... } }`. `400` carries a
validation message in `error`, `409` means the email already has an
account (sign in instead), and `429` means too many attempts.

## Sign in to an existing account

```http
POST /api/mobile/auth/login
Content-Type: application/json

{ "email": "holder@example.com", "password": "..." }
```

Returns the same `{ "token", "user" }` body. `401` is a wrong email or
password; `403` is a suspended account.

## Using the credential

Send the token on each request:

```http
Authorization: Bearer <token>
```

- The token carries the full permissions of the account. There are no
  scopes. Store it as you would the password.
- It expires 30 days after it was issued. `GET /api/mobile/me` returns the
  account, and once the token is past half its life the response includes a
  replacement in `token`; keep that one and discard the old.
- A token cannot be revoked on its own. `DELETE /api/mobile/me` deletes
  the account, after which its tokens stop working. A suspended account's
  tokens are rejected with `401`.
- Never put the token in a URL.

## Payments

Card details are entered into Stripe by the account holder. An agent cannot
complete a purchase without them.

## Contact

Questions about automated access: https://beaniexchange.com/support
