Most jurisdictions require a building permit for retaining walls over a certain height; 4 feet is typical, but it can vary. The wall height includes the footing and part of the wall that's underground, not just the height of the wall from the finished surface. The height limit may be different according to what kind of material is used for wall construction. Some low walls may need a building permit if they meet other criteria.
A permit may also be triggered if the wall will support a surcharge, which is a vertical load on the retained soil that could add lateral pressure in addition to the soil the wall is retaining. Sloping retained soil, structure footings supported by the backfill and vehicles are examples of surcharges on a retaining wall. Terraced, or tiered, walls may require a permit regardless of the height as the upper wall imposes a surcharge condition on the lower wall.
The International Building Code says that retaining walls should be designed to remain stable against overturning, sliding, excessive foundation pressure and water uplift. Good retaining wall design includes details that respond to each of those conditions. When a retaining wall supports soil for a building foundation it may be considered a structural element. Retaining walls are often integral to a building foundation and transportation system, and failure can affect public health and safety.
Handrails or guardrails may be required if the top of the wall is adjacent to a pedestrian path or road. If there's a fence on top of the retaining wall, the fence height combined with that of the retaining wall has be within the height restriction. Before the project begins, consult with the building department to learn about any specific regulations.