# Agent personal-practice API

`POST /api/agent-play` accepts JSON and returns JSON. No account is needed. This is a stateless personal practice game: keep the entire returned `state` and send it with the next request. It does not affect online leagues or browser saves. A supplied state must pass the game's personal-save validation; it is client-controlled and is not proof of a result.

| action | Additional fields | Result |
| --- | --- | --- |
| `create` | none | New `state`. |
| `inspect` | `state` | `state` and `standings`. |
| `save-team` | `state`, `team` | Updated `state`. Use `state.teams[0]` as the team, edit its name, manager, strategy (`balanced`, `power`, `running`), tactics (`bunt`, `steal`: 0–2), player names and batting order. At round 0, skills can also be edited within the budget; after that, use training. Keep player IDs and pitcher positions. |
| `train` | `state`, `player`, `skill` | Updated `state`; player and skill are zero-based indices. Training is available after round 1 and before round 30, three times per season. |
| `play` | `state`, optional `seed` | Updated `state` and the personal club's `game`. Seed is an unsigned 32-bit integer; the same state and seed produce the same result. |
| `next-season` | `state` | Updated `state` after all 30 rounds. |

Example: `curl -X POST https://yagu-web.vercel.app/api/agent-play -H 'Content-Type: application/json' -d '{"action":"create"}'`. For each later request, use the `state` object from the last response, e.g. `{"action":"play","state":...,"seed":42}`. `state.history[0].games` contains all games from the latest round. Invalid requests or states return HTTP 400 with `{ "error": "..." }`; unsupported methods return 405.
