Skip to content

Build and Upgrade

Buildings produce resources and unlock capabilities. Construct and upgrade them to grow your empire.

List Buildings

GET /api/v1/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/buildings/",
headers={"Authorization": "Bearer your-token-here"},
)
print(response.json())

Returns all buildings across your towns, in the standard pagination envelope { "count", "limit", "offset", "results" }:

{
"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; it reaches level 1 at construction_finishes_at. For a building with a pending upgrade, construction_finishes_at shows when the upgrade completes. Finished constructions and upgrades are applied automatically within a few seconds of their finish time, and the new level produces from the finish time exactly: the town is settled up to construction_finishes_at at the old level before the level changes, so an upgrade you queue and leave uncollected never pays its new rate backwards over the hours before it finished. See Levels change at the finish instant.

To list the buildings of a single town, use GET /api/v1/towns/{town_id}/buildings — see Manage Your Towns.

Building Catalog

GET /api/v1/buildings/types

Lists every building type available in your realm, with full details: costs, prerequisites, revenue, trainable units, and bonuses. Use each entry’s id as the yaml_id when constructing. 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/buildings/types",
headers={"Authorization": "Bearer your-token-here"},
)
print(response.json())

Returns 200 OK with the standard pagination envelope { "count", "limit", "offset", "results" } — one entry per building type in results:

{
"count": 1,
"limit": 50,
"offset": 0,
"results": [
{
"id": "Barracks",
"description": "A training facility for soldiers. Requires a Rally Spot at level 1.",
"initial_cost": [
{ "resource_id": "food", "amount": 250 },
{ "resource_id": "wood", "amount": 1200 },
{ "resource_id": "stone", "amount": 1500 },
{ "resource_id": "iron", "amount": 500 }
],
"upgrade_cost": [
{ "resource_id": "food", "amount": 250, "increment": 2, "type": "power" },
{ "resource_id": "wood", "amount": 1200, "increment": 2, "type": "power" },
{ "resource_id": "stone", "amount": 1500, "increment": 2, "type": "power" },
{ "resource_id": "iron", "amount": 500, "increment": 2, "type": "power" }
],
"base_revenue": [],
"revenue_seconds": 3600.0,
"max_level": 10,
"wall_defense_bonus": 0.0,
"wall_defense_bonus_quadratic": 0.0,
"town_types": ["normal", "colony"],
"warning_seconds": 0,
"enables_trading": false,
"enables_research": false,
"trainable_units": ["worker", "warrior", "scout", "pikeman", "swordsman", "archer", "cavalry", "transporter", "cataphract", "ballista", "ram", "catapult"],
"requirements": [
{ "building_id": "Rally Spot", "min_level": 1 }
]
}
]
}
FieldTypeDescription
idstringThe building type’s id — pass it as yaml_id when constructing. Exact match, e.g. "Lumber Mill".
descriptionstringHuman-readable description.
initial_costarrayResources deducted when constructing, as {resource_id, amount} items.
upgrade_costarrayPer-resource upgrade cost formula — see Upgrade cost formula.
base_revenuearrayResources produced per production cycle at level 1, as {resource_id, amount} items. Empty for non-production buildings.
revenue_secondsfloatLength of one production cycle in seconds, already adjusted for the realm’s pace (see Realm pace).
max_levelint | nullMaximum upgrade level; null means unlimited.
max_countint | nullMaximum instances of this building per town; null means unlimited.
resource_protection_per_levelarray of intPer-level plunder-protected storage capacity (the Warehouse) — see Warehouse protection. Empty [] for every building that isn’t a Warehouse.
alliance_member_limit_per_levelarray of intPer-level alliance member limit an alliance host’s Embassy grants ([10, 20, …, 100]): the alliance may hold min(this at the host's best completed level, the realm's max_alliance_members) members, checked whenever an application is accepted — see How big an alliance can grow. Empty [] for every building that isn’t an Embassy.
embassy_garrisons_per_levelarray of intPer-level count of reinforcing parties a town’s own Embassy lets it host at once ([1, 2, …, 10]); a support march is refused when the target has no free slot or no completed Embassy at all — see Embassy garrison slots. Empty [] for every building that isn’t an Embassy.
trade_order_slots_per_levelarray of intPer-level order slots of the trading building (the Market): Evony’s “each level allows one more concurrent transaction”, [1, 2, …, 10] in the shipped realms. A town may hold that many pending trade offers at once; its current cap is published as trade_order_slots on game state. Empty [] for every building that isn’t the trading building.
fortified_spaces_per_levelarray of intPer-level fortified-space capacity (the Wall) — see Wall fortifications. Empty [] for every building that isn’t a Wall.
field_cap_per_levelarray of intPer-level total resource-field allowance (the Town Hall) — how many field buildings (Farm, Lumber Mill, Quarry, Mine combined, one shared pool) the town may hold at each Town Hall level. See The resource-field cap. Empty [] for every building that isn’t a Town Hall.
indestructiblebooltrue when this building type can never be demolished — the Town Hall and the Walls. See Demolish a Building. false for everything else.
wall_defense_bonusfloatLinear half of the defense multiplier: adds level × wall_defense_bonus when defending.
wall_defense_bonus_quadraticfloatSuperlinear half: adds level² × wall_defense_bonus_quadratic, per building instance. Zero on every building that is not a wall — see Combat.
town_typesarray of stringWhich kinds of town ("normal", "colony") may build this — see Not every building fits every town.
warning_secondsintSeconds of advance warning about incoming attacks this building guarantees (each attack appears between one and two of these windows before it lands). The highest value among your completed buildings applies (they do not stack), divided by the realm’s time_scale; a town with no completed such building has no window and is told nothing of an attack until it resolves. See the warning window. A building with a warning_seconds value is the town’s beacon: its completed level also caps how deep the town’s own scout reports go, whatever its Informatics research.
warning_intel_per_levelarray of array of stringThe beacon’s warning tiers (Evony’s Beacon Tower ladder): per level (index 0 = level 1), the pieces of an unresolved incoming attack a completed beacon of that level adds, cumulatively — attack (the attack is listed at all), purpose, arrival, attacker, origin, unit_types, unit_bands, units, hero, research, one per level 1–10 in the shipped realms. See Beacon warning tiers. Empty [] for every building that isn’t the beacon.
enables_tradingboolIf true, owning this building lets you create and accept trade offers.
enables_researchboolIf true, owning this building lets you research technologies.
trainable_unitsarray of stringUnit type ids this building can train. Each of those units also carries its own gates — a min_training_building_level this building must have reached and leveled research prerequisites — see Training gates.
requirementsarrayPrerequisites as {building_id, min_level} items — see Prerequisites.

For most buildings, revenue scales linearly with level: base_revenue.amount × level per cycle. Fields are the exception — Farm, Lumber Mill, Quarry, and Mine follow a non-linear Evony curve instead (100/300/600/1,000/1,500/2,100/2,800/3,600/4,500/5,500 per hour, levels 1–10) that isn’t derivable from base_revenue alone; see Fields, labour, and staffing for the full table and how a town’s workforce throttles it. Buildings at level 0 (under construction) produce nothing and grant no bonuses.

revenue_seconds is reported pre-divided by the realm’s time_scale (see Realm pace), so it is always the real-world seconds per cycle for this realm — no client-side adjustment needed.

The production formula

What a town actually accrues per resource, from its completed buildings’ revenue, is:

accrued = buildings' revenue
× the production-rate slider for that resource (0–100%)
× the staffing ratio (the whole town's fields together)
× own_ground
× (1 + research boosts + the Mayor's Politics bonus + Σ held valley bonuses for that resource)

then food upkeep is deducted and the result is capped at storage. Nothing in it is rounded: the town banks the whole units and carries the part of a unit in progress to its next settle (see Whole units, and the part in progress), so collecting often or rarely earns the same. Every bonus is a percentage of base, summed, never compounded — the Evony rule: Agriculture 10 (+100%), a 150-Politics Mayor (+150%) and a level-10 lake (+35%) make food at 1 + 1 + 1.5 + 0.35 = 3.85×, not 4.5 × 1.35. The valley term is described under valleys; own_ground is the one multiplicative term, and on the shipped realms a town’s own ground grants nothing (own_ground is 1). A city holding a level-10 lake and a level-6 lake and nothing else makes food at 1.58×, and every other resource at 1×. The production rate on game state is this formula per second, and each town’s valleys there is the breakdown of the valley term. Amounts already in storage are never multiplied.

Construction and upgrade durations are part of the realm config and are not included in the catalog — they show up as construction_finishes_at on the building once you construct or upgrade it. Initial construction (level 0 → 1) always takes the building type’s base build time; upgrade durations then grow with level along the realm’s configured curve, so on the doubling-curve buildings the level 1 → 2 upgrade takes twice the initial build time and each later upgrade doubles again. The town’s researched Construction levels then multiply both by 0.9 ^ level (compounding: 90% at level 1, ~35% at level 10), and a Mayor idle in the town multiplies the result by 0.995 ^ politics; the duration is locked in when the job is queued.

Upgrade Cost Formula

Each upgrade_cost item describes how the cost of the next level grows with the building’s current level:

  • "type": "multiply" — cost is amount × increment × current_level.
  • "type": "power" — cost is amount × increment ^ current_level.

For the Barracks above (amount: 1200, increment: 2, type: power on wood), each level costs twice the last: upgrading from level 1 to 2 costs 2,400 wood, from level 2 to 3 costs 4,800 wood, and the final step to level 10 costs 614,400 wood. With multiply, costs would grow linearly (amount × increment × current_level) instead.

On the fast and free realms, Barracks, Watchtower, Warehouse, Market, Embassy, Inn, Forge, Workshop, Stable, Relief Station, Cottage, Town Hall, and Rally Spot all follow this doubling power curve up to max_level 10, with the level-1 base costs taken from the classic Evony Age 1 tables.

The Wall uses power too: amount: 25, increment: 2, so each level costs twice the last — 50 stone at level 1, 1,600 at level 6, 25,600 for the final step to level 11. That is deliberate. The wall’s defense grows with the square of its level, so its price grows faster still, and the last few levels are the difference between a town that survives a serious attack and one that does not.

Watch your storage: a town cannot spend more of a resource than it can hold (see each resource’s max_storage and the storage caps below), so an upgrade priced above your storage cap is not slow, it is impossible.

Not every building fits every town

A building type is only constructible in a town whose type whitelists it. Every entry from GET /api/v1/buildings/types carries a town_types list saying which kinds of town may build it, and the endpoint accepts a town_type query parameter that filters the catalog to one of them:

Terminal window
curl "http://localhost:8731/api/v1/buildings/types?town_type=colony" \
-H "Authorization: Bearer $REALM_TOKEN"

Cities can build everything the realm defines. Colonies cannot build walls or the Academy. Requesting a building outside a town’s whitelist is rejected with a 400 before any resources are spent.

Cottage, Town Hall, and population capacity

Cottage is the building that houses your population — it, and only it, grants max_population, and the amount jumps per level rather than scaling smoothly: 100/300/600/1,000/1,500/2,100/2,800/3,600/4,500/5,500 at levels 1–10. Multiple Cottages stack. See Cottage capacity for the full table, and Population, Loyalty & Tax for how population actually fills toward that cap over time.

Every town starts with a Town Hall already built at level 1 — you never construct it yourself. From level 3 on it demands the Wall two levels lower to upgrade further (Town Hall 3 needs Wall 1, Town Hall 4 needs Wall 2, …), and Cottage levels 3 and up each demand the Town Hall one level lower (Cottage 3 needs Town Hall 2, …). Colonies cannot build a Wall, so their Town Hall — and every Cottage in them — is permanently capped at level 2 (300 population per Cottage).

This per-level ladder is a different mechanism from the flat requirements field above: requirements gates whether a building can be constructed at all (its existence), while the Cottage/Town Hall ladder gates one specific upgrade step and is not currently listed in the catalog response — it only surfaces as a 400 when you attempt the blocked upgrade:

{
"detail": "Building prerequisites not met: requires Town Hall level 2."
}

Workforce: staffing your fields

Cottage capacity is only half the population story — the other half is labour. Every field (Farm, Lumber Mill, Quarry, Mine) wants a fixed number of workers to run at full output, drawn from the same population your garrison draws from:

Level12345678910
Labour (workers)103060100150210280360450550

Idle population — residents neither farming a field nor already committed to the army — is:

idle = population − field_labour − troop_population

where troop_population sums every garrisoned unit’s population_cost plus every training order (finished or not, until it joins the garrison), every wounded unit and every unit in the healing queue. It can go negative (“over-committed”): the browser client’s Resource panel shows it in red whenever it does, and a negative idle throttles every field’s output by the same ratio (see Fields, labour, and staffing for the full formula). Training an order that would overdraw idle population is rejected with a 400 — the browser client’s training form caps its unit count at whatever idle currently allows, so you cannot even submit an oversized order.

Building more Cottages raises your population cap, but population only grows toward that cap over time (see The tick); it does not top you up immediately. The fast fix for a workforce squeeze is the production rate slider (PATCH /api/v1/towns/{town_id}/production/, exposed in the browser client as the Resource panel’s Workforce button): dropping a resource to 0% excuses that resource’s fields from the labour count entirely, freeing their workers back into your idle pool immediately — the classic Evony move right before queuing a big batch of training.

Forge, Workshop, Stable, and the Relief Station

Four buildings exist mainly as prerequisites: Forge (requires Mine level 3), Workshop (requires Forge level 2), and Stable (requires Farm level 5) each carry per-level cost/build-time tables but little gameplay effect of their own yet — they are the building-level foundation for future Academy research (Metal Casting, Military Science, and Horseback Riding respectively), which does not exist yet. The Workshop does earn its keep today, though: a level-1 Workshop (together with a level-2 Quarry) is what unlocks the Wall — see Prerequisites for the full dependency graph.

The Relief Station (requires Stable level 1) is different: it grants a real march-speed multiplier for marches you send to your own other towns or to a town owned by a player your alliance has an accepted ALLY relation with (see Alliances). The bonus is read from the sending town’s Relief Station level — not the destination’s:

Level12345678910
Speed multiplier2×2×2×3×4×4×4×5×5×6×

A 2× multiplier halves travel time; a town with no completed Relief Station marches at the ordinary baseline speed.

It only speeds up help, never an attack. The Relief Station is a relay for transports and reinforcements, so exactly two kinds of march qualify:

  • Support — reinforcements to your own other town or an allied player’s town.
  • Trade caravans — the transport that leaves the offering town when your offer is accepted, so it is the offering town’s Relief Station that counts.

An attack or a scout never gets the bonus, not even in the rare case where it is aimed at an ally’s town — those are not reinforcements. Nor does the bonus apply to a neutral, at-war, or NPC/barbarian destination, and founding marches (which target an empty map tile, not an existing town) never qualify. See Travel Time for how this combines with unit speed and the realm’s pace.

Wall fortifications

Your Wall does two things: it grants a combat defense bonus (see Combat), and its level caps how many fortification units — garrisoned wall defenses — your town may hold at once, via its fortified_spaces_per_level capacity:

Wall level12345678910
Fortified spaces1,0003,0006,00010,00015,00021,00028,00036,00045,00055,000

Fortification units are a different concept from trained troops:

  • They are built, like a resource purchase with a construction timer — not trained, and not drafted from your idle population.
  • They never leave the town — there is no march or dispatch path for them, and they play no role in an army you send elsewhere.
  • They are capped by the Wall’s fortified-space capacity above, not by population.
  • They fight when the town is attacked, as emplacements fixed at the Wall’s pace — the exact rule is in Wall fortifications in combat. Each type plays one role:
TypeRoleFires atReachFires
Trapanti-infantry contact mineinfantryat the Wallonce — the whole stock, then spent
Abatisanti-cavalry barricadecavalryat the Wallonce
Archer’s Towergeneral ranged emplacementeveryone6 pacesevery turn; the one type attackers can shoot at, and must destroy to win
Rolling Logone-shot burst at rangeeveryone6 pacesonce
Defensive Trebuchetanti-siege volleymachines9 paces (one more than a catapult)once

Repair after a battle: a share of each type’s losses rebuilds itself for free the moment the battle ends — Evony’s “auto-repair”. The realm’s battle config sets the base share, fortification_repair_rate (0.03 in the fast and free realms: 3 of every 100 lost traps come back), and the town’s Machinery research multiplies it by 1 + level — 2× the base at level 1, 11× at level 10, so a Machinery-10 town recovers 33 of every 100 it loses. The count is rounded down per type and can never exceed what that type lost. A stock of Archer’s Towers destroyed to the last one rebuilds nothing (Evony’s “reduced to zero” rule); a one-shot stock that fired does rebuild its share. The battle report’s fortifications_lost_defender lists what was lost before the repair; GET /api/v1/fortifications/ shows what is left.

Each fortification type consumes a fixed number of fortified spaces per unit and requires a minimum Wall level to build at all:

TypeSpacesFoodLumberStoneIronBuild timeRequires
Trap150500100501mWall level 1
Abatis21001,20001502mWall level 2
Archer’s Tower32002,0001,5005003mWall level 3
Rolling Log43006,000006mWall level 5
Defensive Trebuchet560008,000010mWall level 7

GET /api/v1/fortifications/types lists the full catalog for your realm, including each type’s id (trap, abatis, archers_tower, rolling_log, defensive_trebuchet), exact costs, and its battle facts: target_classes (the attacker unit classes it fires at; empty means every class), range in lane paces from the Wall (0 = contact), one_shot, attack, and — for the Archer’s Tower, the one type that can be shot at — damage_class (buildings: attackers read their attack_vs_buildings against it), hp and defense. Those three are null on the one-shot types. (Earlier catalogs listed Evony’s yard ranges and a load figure; both are gone.)

Building one: POST /api/v1/fortifications/build with town_id, fortification_type_id, and count. Resources are deducted immediately; the order completes after build_time × count (adjusted for the realm’s time_scale, then by the town’s Construction research and its Mayor’s Politics, exactly like a building), the same construction-timer shape as unit training and building upgrades. A request is rejected with 400 if:

  • Your town’s Wall level is below the type’s required level.
  • You cannot afford the resource cost.
  • Building count more would push your total fortified-space usage — units already garrisoned, plus every order still in your build queue — over your Wall’s current capacity. A queued order reserves its spaces from the moment it is placed until it is applied to your garrison, so units mid-construction (and finished orders not yet applied) count against the cap exactly like garrisoned ones do.

Checking progress and garrison: GET /api/v1/fortifications/queue lists your pending construction orders across all towns; GET /api/v1/fortifications/ lists each town’s completed, garrisoned fortification units by type (finished orders are applied automatically the moment you call it, the same lazy-completion pattern unit training uses).

Speeding one up: there is no resource-priced speedup for this queue. The one way to shorten a fortification order is Archimedes’ Note, a Speed Up item that takes 30% off the time still remaining — {"target": {"fortification_id": N}}, where N is the order’s id in GET /api/v1/fortifications/queue. It may be applied once per order: a second Note on the same order is a 409 and is not spent. See Speedup.

Construct a Building

POST /api/v1/buildings/

import httpx
response = httpx.post(
"http://localhost:8731/api/v1/buildings/",
headers={"Authorization": "Bearer your-token-here"},
json={"yaml_id": "Farm", "town": "town-uuid"},
)
print(response.json())

Initial construction costs resources, deducted immediately. The available buildings and their costs are defined by the realm config — get them (including the exact yaml_id values) from the building catalog above. Returns 201 Created. Constructing with not enough resources or an unknown yaml_id returns 400.

If the building type has a construction time, the building starts at level 0 (under_construction: true) and reaches level 1 at construction_finishes_at; otherwise it is built instantly at level 1.

A timed construction takes a slot in the same upgrade queue as building upgrades, so starting one while the queue is full returns 400. Instant builds occupy no slot and are never blocked by the queue.

Prerequisites

Some buildings require other buildings at a completed minimum level before they can be constructed (a level-0, still-under-construction prerequisite does not count). The catalog’s requirements field lists them per building; the full dependency graph is:

BuildingRequires
BarracksRally Spot level 1
WatchtowerBarracks level 1
AcademyTown Hall level 2
EmbassyTown Hall level 2
InnCottage level 2
ForgeMine level 3
WorkshopForge level 2
StableFarm level 5
Relief StationStable level 1
WallQuarry level 2 and Workshop level 1

Everything else — Town Hall, Cottage, Rally Spot, Market, Warehouse, Hospital, and the four fields (Farm, Lumber Mill, Quarry, Mine) — has no construction prerequisite. (The Town Hall and Cottage instead carry the per-level upgrade ladder described under Cottage, Town Hall, and population capacity above, a separate mechanism.)

If prerequisites are not met, the API returns 400 with a message specifying which requirements are missing:

{
"detail": "Building prerequisites not met: requires Rally Spot level 1."
}

Resources are never deducted when a prerequisite check fails.

Prerequisites gate construction only — an already-built building keeps upgrading even if its prerequisite is later demolished. And note the Rally Spot is now genuinely load-bearing: nothing trains troops without a Barracks, and no Barracks goes up without a Rally Spot.

Build Limits

Most buildings can be constructed more than once in a town — build ten Farms and they each produce. Some are capped by the realm config; the catalog’s max_count field gives the limit, and null means unlimited.

In the default realm, Cottage, Barracks, Academy, Hospital and Warehouse carry no per-type limit, while Watchtower, Wall, Market, Inn, Rally Spot, Embassy, Forge, Workshop, Stable and Relief Station are capped at one per town. Farm, Lumber Mill, Quarry and Mine carry no max_count of their own but share the Town-Hall-gated resource-field cap below; every other building — the uncapped ones included — draws from the town-wide pool of interior building slots.

Constructing past a cap returns 400:

{
"detail": "Building 'Market' has reached its limit of 1 in this town."
}

Resources are never deducted when a limit check fails.

The resource-field cap

Resource fields — Farm, Lumber Mill, Quarry and Mine — draw from one shared count pool gated by your Town Hall’s level, instead of a per-type max_count: 13 fields at Town Hall level 1, then +3 per level, up to 40 at level 10 (the classic Evony progression). The full table is published on the Town Hall’s catalog entry as field_cap_per_level:

Town Hall level12345678910
Total fields13161922252831343740

The mix is yours — 13 Farms, or 4/3/3/3 across the types, anything that fits the pool. Fields still under construction count against the cap (they already occupy a slot). Constructing a field past the cap returns 400:

{
"detail": "Resource field limit reached: this town supports at most 13 resource fields at its current Town Hall level and already has 13."
}

Upgrade the Town Hall to unlock more fields. As with every limit check, resources are never deducted on the rejection. Non-field buildings (Cottages, Barracks, …) are unaffected by this pool — they consume interior building slots instead.

The interior building-slot cap

Everything that is not a resource field — Cottages, Barracks, the Town Hall, the Wall, and every other structure inside the walls — shares one town-wide pool of interior building slots (the classic Evony city layout: 34 interior locations). The Town Hall and the Wall count against the total like any other building, so a city that has built its Wall has 32 slots left for freely chosen buildings. Resource fields are exterior plots and never touch this pool; they answer to the resource-field cap above instead.

The cap is fixed per town type — it does not grow with any building level. GET /api/v1/towns/ publishes it per town as interior_slots: 34 for a city, 17 for a colony (half a city’s allotment, matching a colony’s half-sized starter pack), null on a realm that leaves the type uncapped. Buildings still under construction hold their slot. Constructing an interior building past the cap returns 400:

{
"detail": "Interior building slot limit reached: this town supports at most 34 interior buildings and already has 34."
}

Resources are never deducted on the rejection, and upgrades are never blocked by it — a full city keeps upgrading what it has, or demolishes something to make room.

When a town holds several buildings of one type, capacity adds up — two Hospitals hold twice the wounded, and two Warehouses shield twice the plunder-protected resources — while prerequisite checks use the highest level among them.

Demolish a Building

DELETE /api/v1/buildings/{building_id}

import httpx
response = httpx.delete(
"http://localhost:8731/api/v1/buildings/building-uuid",
headers={"Authorization": "Bearer your-token-here"},
)
# 204 No Content on success

Permanently removes a building from your town. Any resources the building has produced up to the moment of demolition are settled into your town’s storage before the building is removed — nothing is lost. Construction costs are not refunded.

Buildings that are still under construction (level 0) cannot be demolished. The API returns 400:

{
"detail": "Cannot demolish a building that is under construction."
}

The Town Hall and the Walls can never be demolished — their catalog entries carry indestructible: true (building catalog). Among other things, this keeps the resource-field cap permanently enforced: without a Town Hall a town would have no field cap at all. Demolishing either returns 400:

{
"detail": "This building cannot be demolished."
}

Upgrade a Building

POST /api/v1/buildings/{building_id}/upgrade

import httpx
response = httpx.post(
"http://localhost:8731/api/v1/buildings/building-uuid/upgrade",
headers={"Authorization": "Bearer your-token-here"},
)
print(response.json())

Queues an upgrade to the next level. The upgrade cost is deducted from your town resources immediately; if the building type has an upgrade time, the new level applies when construction_finishes_at elapses (otherwise it applies instantly), and its production counts from that instant exactly — the town is settled at the old level up to the finish first. Upgrade costs grow with the building’s current level, as defined in the realm config.

Upgrading fails with 400 if:

  • the building is still under construction (level 0),
  • the building is already upgrading,
  • the town’s upgrade queue is full,
  • you don’t have enough resources,
  • it’s a Cottage or Town Hall’s level 9→10 upgrade and you don’t own a Michelangelo’s Script.

It fails with 409 when two of your level-10 upgrades race for your last Michelangelo’s Script — see Level 10: building permits.

Upgrade Queue

How many upgrades a town may have running at once is set by the realm. Timed constructions of new buildings count toward the same limit — two running constructions fill a queue of two just as two upgrades do. A premium entitlement adds two more slots on top of it, for every town on the account.

Maximum Level

Some buildings have a maximum level defined in the realm config. Attempting to upgrade a building that has already reached its cap returns 400:

{
"detail": "Building 'Lumber Mill' is already at maximum level (20)."
}

Buildings without a configured maximum level can be upgraded indefinitely.

Speeding up a construction

A running construction or upgrade can be brought forward two ways, and they are governed by different limits — see Speedup for both in full.

  • POST /api/v1/buildings/{building_id}/speedup pays resources out of the town’s wallet and consumes one of the order’s speedup_max_uses (one, in the shipped realms). Under the last five minutes it is free and consumes no use.
  • A Speed Up item — any of the six Guidelines or Napoleon’s Diary (30% of the time left, once per upgrade) — takes its own figure off instead, and never touches that limit, so Guidelines stack freely on one order and a spent resource speedup does not lock them out. Point one at a build with {"target": {"building_upgrade_id": N}}, where N is that building’s upgrade_id in GET /api/v1/state/.

Ultimate Guidelines takes 30% off the time still remaining, so it is worth most on a long upgrade used early. Neither route finishes a job outright: both move the finish time earlier, and the resolver completes it within a few seconds of that time passing.

Level 10: building permits

A Cottage or Town Hall’s final upgrade — level 9 to 10 — also consumes an inventory item, a building permit (Michelangelo’s Script in the shipped realms), on top of its ordinary resource cost. Without one in your inventory, the upgrade 400s naming it:

{
"detail": "Upgrading 'Cottage' to level 10 requires 1 Michelangelo's Script."
}

With one, the upgrade starts normally and exactly one is consumed from your stack — there’s no separate step, no separate endpoint; you never “use” this item directly (POST /api/v1/items/{item_id}/use 400s on it). The permit is spent under a lock as the very last step of the upgrade, so two of your level-10 upgrades started at the same moment can never share one Script: the one that reaches the stack second finds it empty and is refused with 409 ("Your last Michelangelo's Script was just spent by another upgrade; this upgrade was not started.") — nothing is charged to its town, and the first upgrade stands. See Items for how a building permit reaches your inventory (the fortune wheel and barbarian-settlement drops, never a purchase) and Speech Text and Michelangelo’s Script for the full mechanic.

Collect Revenue

POST /api/v1/towns/{town_id}/collect

import httpx
response = httpx.post(
"http://localhost:8731/api/v1/towns/town-uuid/collect",
headers={"Authorization": "Bearer your-token-here"},
)
print(response.json())

Banks the resources your buildings have produced since the last collection and returns the town with its settled totals. Revenue scales with building level (buildings under construction produce nothing), and the town’s terrain multiplier — its held valleys composed with whatever its own tile grants — applies to production.

Collection is optional bookkeeping — resource reads (such as GET /api/v1/towns/{town_id}) already include production accrued since the last collection. Banking locks the amounts into storage, still capped at the storage limits below.

Comfort & Levies

Beyond banking production, a town has two one-shot Town Hall actions that spend against its loyalty/grievance economy directly — Evony’s “comfort the people” and “levy” mechanics. Both are priced against max_population, the town’s Cottage capacity (see Cottage, Town Hall, and population capacity above), and both settle resources and the loyalty/grievance tick at the current state before pricing or applying the action. Full mechanics, request/response shapes, and error codes live on Population, Loyalty & Tax; this is the quick-reference cost/effect table.

Comfort actions

POST /api/v1/towns/{town_id}/comfort/

import httpx
response = httpx.post(
"http://localhost:8731/api/v1/towns/town-uuid/comfort/",
headers={"Authorization": "Bearer your-token-here"},
json={"action": "praying"},
)
print(response.json())

All four actions share one cooldown per town (comfort_available_at) — using any one of them locks out all four for comfort_cooldown_seconds (900 real seconds by default, divided by the realm’s time_scale).

ActionCostEffect
prayingmax_population goldLoyalty +25 (clamped to 100), grievance -5 (clamped to 0)
disaster_reliefmax_population foodLoyalty +5 (clamped to 100), grievance -15 (clamped to 0)
blessing10% of max_population in gold (floored)Grants 10 × max_population in food (floored, capped at storage); loyalty and grievance untouched
population_raising10 × current population in food (floored)Population grows by 10% of its current value (floored), capped at max_population × loyalty ÷ 100

Returns 400 if action isn’t one of the four names above or the town can’t afford the cost, 409 while the shared cooldown is active.

Levies

POST /api/v1/towns/{town_id}/levy/

import httpx
response = httpx.post(
"http://localhost:8731/api/v1/towns/town-uuid/levy/",
headers={"Authorization": "Bearer your-token-here"},
json={"resource_id": "food"},
)
print(response.json())

A levy costs no resources, only grievance — a direct grant priced off max_population, floored and capped at storage. It has its own cooldown (levy_available_at), independent of the comfort actions’ shared cooldown, so you can pray and levy the same town in one sitting.

ResourceGrant
gold10% of max_population
food100% of max_population
wood100% of max_population
stone50% of max_population
iron40% of max_population

Every levy — of any resource — also adds 10 grievance (clamped at 100); there is no resource-free way to levy. Returns 400 if resource_id isn’t one of the five names above, 409 while the levy cooldown is active.

Resource Storage Caps

Resource types can have a maximum storage capacity defined by the realm config (resources without a configured cap are unlimited). When your town’s resources exceed the cap (e.g., from building production over time), the excess is silently discarded — you lose the overflow.

Storage caps are enforced automatically on every resource read and every collection. You cannot exceed the cap through any means.

The shipped realms cap wood, stone, food and iron at 10,000,000 each and gold at 1,000,000 — deliberately far above the priciest upgrade (a level-10 Town Hall needs 1,536,000 wood), so nothing in the catalog is structurally unbuildable. This is a documented divergence from Evony, where each resource field added its own per-level storage (10,000 at level 1 up to 550,000 at level 10, summed over the fields) that halted collection when full and that Stockpile research raised; Restfall’s cap is one flat realm number per resource, no building or research moves it, and overflow is discarded rather than production paused. The Marketplace’s “bank” is how Evony players sidestepped the field cap; it works here too, at the price of the trade fee.

Plan your collection timing and spending to avoid waste. If a resource is near its cap, spend it or collect before production pushes it over the limit.

Warehouse protection

The storage cap above is a ceiling — the most a resource can ever accumulate. The Warehouse building is unrelated to that ceiling; it grants a floor instead, protecting a share of what you already hold from being taken by a successful attacker. The two caps don’t interact: building a Warehouse never raises (or lowers) how much you can store, and a resource sitting at its storage cap is exactly as protected — or unprotected — as it would be below the cap.

Each completed Warehouse contributes its current level’s resource_protection_per_level entry (see the building catalog) to your town’s total protected capacity — a single shared pool across Food, Lumber (wood), Stone, and Iron combined, not four separate per-resource floors. Gold is never protected. Building more than one Warehouse stacks their capacities, same as Hospitals stacking wounded capacity (see Build Limits) — there is no cap on how many Warehouses a town may build.

The town’s researched Stockpile levels then multiply that summed total by 1 + 0.1 × level (rounded down): a lone level-1 Warehouse shields 10,000 with no research, 15,000 at Stockpile 5, 20,000 at Stockpile 10. Stockpile is researched per town and only ever raises the protected floor — it leaves the storage ceiling above untouched, and a town with no Warehouse gains nothing from it.

An attacker’s own research can eat into that floor: an army marching from a town with Privateering multiplies your protected capacity (Stockpile included) by 1 − 0.03 × level — 30% less at level 10, so the 15,000 above shields only 10,500 against a Privateering-10 raider. The product is rounded down once and never drops below 0.

When an attacker plunders your town, up to your total protected capacity (after any Privateering) is shielded from the loot calculation before carry capacity and proportional distribution are applied (see Raiding) — spread across whichever of Food/Lumber/Stone/Iron you actually hold, proportional to how much of each you have. A town with no Warehouse behaves exactly as before: nothing is shielded, and the full stockpile (short of the attacker’s carry capacity) is at risk.