Manage Your Towns
Once you have founded a town and placed it on the map, these endpoints let you keep an eye on it — check resources, rename it, see its buildings, or tear it down and start over.
All endpoints require a realm token. You can only see and manage your own towns.
List Your Towns
GET /api/v1/towns/
Supports limit and offset query parameters for pagination (limit defaults to 50, max 200; offset defaults to 0).
import httpx
response = httpx.get( "http://localhost:8731/api/v1/towns/", headers={"Authorization": "Bearer your-token-here"},)print(response.json())curl http://localhost:8731/api/v1/towns/ \ -H "Authorization: Bearer your-token-here"const response = await fetch("http://localhost:8731/api/v1/towns/", { headers: { Authorization: "Bearer your-token-here" },});const data = await response.json();Returns 200 OK with the standard pagination envelope { "count", "limit", "offset", "results" }, where count is the total number of your towns and results holds the towns for the requested page:
{ "count": 1, "limit": 50, "offset": 0, "results": [ { "id": "uuid", "name": "My Town", "resources": { "wood": 740, "stone": 200, "food": 315 }, "units": { "pikeman": 5 } } ]}| Field | Type | Description |
|---|---|---|
id | uuid | The town’s id, used in all town-scoped endpoints. |
name | string | The town’s name, unique within the season. |
resources | object (str→int) | Current resource totals, keyed by resource id. |
units | object (str→int) | The garrison — units stationed here, keyed by unit id. |
gates_open | bool | The city gates: false (closed, the default) or true (open). |
Resource totals are live: they already include production accrued since your last collection, capped at the realm’s storage limits. You do not need to call collect before reading them — see Resource Storage Caps for how the limits work.
Get a Town
GET /api/v1/towns/{town_id}
import httpx
response = httpx.get( "http://localhost:8731/api/v1/towns/town-uuid", headers={"Authorization": "Bearer your-token-here"},)print(response.json())curl http://localhost:8731/api/v1/towns/town-uuid \ -H "Authorization: Bearer your-token-here"const response = await fetch( "http://localhost:8731/api/v1/towns/town-uuid", { headers: { Authorization: "Bearer your-token-here" }, },);const data = await response.json();Returns 200 OK with a single town in the same shape as the listing, including live resources and the unit garrison.
Errors
- 404 — the town does not exist or does not belong to you (
Town not found.).
City gates
PATCH /api/v1/towns/{town_id}/gates — body {"gates_open": true} to open them, {"gates_open": false} to close them. Every town starts closed. Returns the updated town (the same shape as Get a Town); 404 if the town is not yours, 422 without the field. Other players are never shown your gate state — not on the map, not in a scout report.
Evony’s Rally Spot had one checkbox, Open Gate to Fight, and that is what this is. The state is read at the moment a march arrives, so flipping it while something is on the road changes how that arrival is handled:
| Gates closed (default) | Gates open | |
|---|---|---|
| An attack lands | Your garrison holds the wall line and fights from behind the standing Wall: melee attackers must breach it first, ranged fire at your troops is softened by the wall bonus, and your troops only leave the line once the Wall falls. | Your garrison sorties: every defender group with nothing in reach advances to meet the attackers on the field, as attacking troops do. The Wall still stands and siege still shells it, your fortifications still fire from it — but a group that has stepped past the Wall’s pace has left its cover and is hit at full strength. |
| Enemy scouts arrive | Your scouts do not fight. Whoever has the higher Informatics wins: if the party’s effective intel is not higher than your Informatics they bounce — home unharmed, with no report — and you are told your counter-intelligence held; otherwise they read your town (depth graded by the margin) and you are told it failed. | Your garrisoned scouts screen the party — the scout war — and your Informatics plays no part: a party that breaks the screen reports at its own intel level. |
Open gates are the classic posture (your allies’ support garrisoned with you sorties alongside you, and a standing scout screen is what keeps a city unscoutable); closed gates are the troop-saving one against a hopeless attack or a scout bomb. Barbarian settlements have no gate and behave as if theirs were closed in battle and open to scouts; computer-led players never open theirs. Without a Wall the two battle rows are the same fight.
Rename a Town
PATCH /api/v1/towns/{town_id}
Request Body
| Field | Type | Description |
|---|---|---|
name | string | Optional. The town’s new name. |
name is the only field you can change — resources, units, and placement cannot be edited through this endpoint.
import httpx
response = httpx.patch( "http://localhost:8731/api/v1/towns/town-uuid", headers={"Authorization": "Bearer your-token-here"}, json={"name": "New Name"},)print(response.json())curl -X PATCH http://localhost:8731/api/v1/towns/town-uuid \ -H "Authorization: Bearer your-token-here" \ -H "Content-Type: application/json" \ -d '{"name": "New Name"}'const response = await fetch( "http://localhost:8731/api/v1/towns/town-uuid", { method: "PATCH", headers: { Authorization: "Bearer your-token-here", "Content-Type": "application/json", }, body: JSON.stringify({ name: "New Name" }), },);const data = await response.json();Returns 200 OK with the updated town, including live resources and units. Omitting name leaves the town unchanged.
Name Rules
The same rules apply as when founding a town:
- At most 128 characters.
- Letters, numbers, underscores, spaces, hyphens, apostrophes, and periods only.
- Unique within the season.
Errors
- 400 — another town in the season already has this name (
A town with this name already exists.). - 403 — the season is no longer active.
- 404 — the town does not exist or does not belong to you.
- 422 — the name is empty, too long, or contains invalid characters.
Delete a Town
DELETE /api/v1/towns/{town_id}
import httpx
response = httpx.delete( "http://localhost:8731/api/v1/towns/town-uuid", headers={"Authorization": "Bearer your-token-here"},)# 204 No Content on successcurl -X DELETE http://localhost:8731/api/v1/towns/town-uuid \ -H "Authorization: Bearer your-token-here"const response = await fetch( "http://localhost:8731/api/v1/towns/town-uuid", { method: "DELETE", headers: { Authorization: "Bearer your-token-here" }, },);// 204 No Content on successReturns 204 No Content. Deletion is permanent and cannot be undone. The town is razed exactly like a colony that falls, with a few differences that protect your allies and your heroes:
- Everything in it burns. Its buildings and everything queued in them, the garrison, the wounded in the hospital, the healing queue, the wallet and the population are gone. Nothing is refunded.
- Its map tile is freed for anyone to settle, and map clients see it go (the next occupant delta carries a tombstone). The town disappears from your town list and from the map; battle and scouting reports that name it still open.
- Valleys it holds become unowned, exactly as if you abandoned each one: fresh garrison, back on the daily cycle, and any reinforcements standing in them sent home.
- Reinforcements standing in the town march home alive. Every party standing in it, an ally’s or one of your own from another town, leaves at once with whatever of it survived the town’s battles. It arrives home one normal journey later (the time its march to you took). A reinforcement still on its way finds no room in the ruin and turns back with everything it brought.
- Its pending trade offers are cancelled. Their escrow was in the town’s wallet and burns with it. Caravans can’t be on the road at this point (see below).
- Your heroes in it move to your oldest other town, as they stood: an idle hero stays idle, a wounded one stays wounded. The mayor’s seat goes with the town. If it is your last town, your heroes in it are deleted with it, the mayor included, rather than left at a ruin where they could never act again. A hero of yours held captive elsewhere is not affected.
- Heroes it held captive go free. Each returns idle to its owner’s oldest town, exactly as when a prison town is razed.
Deleting your last town is allowed. It is how you start over: once you hold no town, you can found a new one with POST /api/v1/towns/ and place it somewhere else.
Wait until everything is home
A town can’t be deleted while anything of yours is on the road to or from it:
- troops out (an attack, scouts, or reinforcements away, including ones standing in one of its valleys);
- survivors and loot coming home;
- one of your own reinforcements on its way in (one you send from another town at the very moment of the delete can slip past this check: it then finds the ruin and marches back whole);
- a caravan of one of its trades, in either direction;
- a founding expedition, or the refund of one that turned back.
Each of these would otherwise come home to a ruin. Marches that aren’t yours don’t hold the delete: an enemy attack on its way still lands, on the empty ruin, and an ally’s reinforcement on its way turns back as described above.
Errors
- 403 — the season is no longer active.
- 404 — the town does not exist or does not belong to you.
- 409 — something is still on the road to or from the town, yours or — for a town you captured — a march its previous owner sent before it changed hands (
Something is still on the road to or from this town (troops, loot, a caravan or a founding expedition). Wait until everything is home, then delete it.). Nothing was deleted. - 409 — the town changed in the very instant the deletion ran: it won a valley, a reinforcement was being sent home, or a hero arrived (
Your town changed while it was being deleted. Nothing was deleted; try again.). Send the same request again.
List a Town’s Buildings
GET /api/v1/towns/{town_id}/buildings
Supports limit and offset query parameters for pagination (limit defaults to 50, max 200; offset defaults to 0).
import httpx
response = httpx.get( "http://localhost:8731/api/v1/towns/town-uuid/buildings", headers={"Authorization": "Bearer your-token-here"},)print(response.json())curl http://localhost:8731/api/v1/towns/town-uuid/buildings \ -H "Authorization: Bearer your-token-here"const response = await fetch( "http://localhost:8731/api/v1/towns/town-uuid/buildings", { headers: { Authorization: "Bearer your-token-here" }, },);const data = await response.json();Returns 200 OK with the standard pagination envelope { "count", "limit", "offset", "results" }, where count is the total number of buildings in that town and results holds the buildings for the requested page:
{ "count": 1, "limit": 50, "offset": 0, "results": [ { "id": "uuid", "town": "town-uuid", "level": 2, "yaml_id": "Farm", "under_construction": false, "construction_finishes_at": null } ]}A level of 0 with under_construction: true means the building is still being constructed. On this endpoint construction_finishes_at is always null; to see when a pending construction or upgrade finishes, use GET /api/v1/buildings/ instead (see Build and Upgrade).
To construct, upgrade, or demolish buildings, and to browse the realm’s building catalog with costs and prerequisites, head over to Build and Upgrade.
Errors
- 404 — the town does not exist or does not belong to you.