As Thomaskantor, Bach served as music director of Leipzig and had to compose not only for music in the four major churches but also for public municipal functions.
The Ratswechsel was celebrated with an annual church service at the Nikolaikirche on the Monday after St. Bartholomew, August 24.
It was not a democratic election, but a "ceremonial transfer of office" of council members who were appointed.
The service was not part of the liturgical year with cantata texts related to prescribed biblical epistle and gospel readings.
For the Ratswechsel service, Bach could count on the entire council (his employer) listening, and probably also civil servants and representatives of the Elector's administration for the region.
The musicologist Klaus Hofmann notes: "It was an opportunity for Bach to show how sacred music was flourishing under his direction and to present himself as a composer."

The cantata was Bach's first for the occasion in Leipzig.
Early in his career he had written at least one cantata for the equivalent service at Mühlhausen.
There are five surviving cantatas for the Ratswechsel at Leipzig, and librettos of three more,  BWV Anh.
I 3, 4 and 193.
The other four extant cantatas are Ihr Tore zu Zion, BWV 193, composed for the occasion in 1727 but partly lost, Wir danken dir, Gott, wir danken dir, BWV 29, composed for the occasion in 1731, Gott, man lobet dich in der Stille, BWV 120, adapted from earlier cantatas for wedding and homage probably in 1742, and Lobe den Herrn, meine Seele, BWV 69, adapted from Lobe den Herrn, meine Seele, BWV 69a, for the occasion in 1748.

The text was written by an unknown librettist who included psalm verses (from Psalms 147, 85 and 126) and lines from Martin Luther's German Te Deum "Herr Gott, dich loben wir".
To suit the event for which it was written, these are all turned into hymns of thanking and praising God for Leipzig's prosperity and asking him to protect the city in the future.

Bach led the Thomanerchor in the performance on 30 August 1723.
As Thomaskantor, Bach served as music director of Leipzig and had to compose not only for music in the four major churches but also for public municipal functions. The Ratswechsel was celebrated with an annual church service at the Nikolaikirche on the Monday after St. Bartholomew, August 24. It was not a democratic election, but a "ceremonial transfer of office" of council members who were appointed. The service was not part of the liturgical year with cantata texts related to prescribed biblical epistle and gospel readings. For the Ratswechsel service, Bach could count on the entire council (his employer) listening, and probably also civil servants and representatives of the Elector's administration for the region. The musicologist Klaus Hofmann notes: "It was an opportunity for Bach to show how sacred music was flourishing under his direction and to present himself as a composer."
The cantata was Bach's first for the occasion in Leipzig. Early in his career he had written at least one cantata for the equivalent service at Mühlhausen. There are five surviving cantatas for the Ratswechsel at Leipzig, and librettos of three more,  BWV Anh. I 3, 4 and 193. The other four extant cantatas are Ihr Tore zu Zion, BWV 193, composed for the occasion in 1727 but partly lost, Wir danken dir, Gott, wir danken dir, BWV 29, composed for the occasion in 1731, Gott, man lobet dich in der Stille, BWV 120, adapted from earlier cantatas for wedding and homage probably in 1742, and Lobe den Herrn, meine Seele, BWV 69, adapted from Lobe den Herrn, meine Seele, BWV 69a, for the occasion in 1748.
The text was written by an unknown librettist who included psalm verses (from Psalms 147, 85 and 126) and lines from Martin Luther's German Te Deum "Herr Gott, dich loben wir". To suit the event for which it was written, these are all turned into hymns of thanking and praising God for Leipzig's prosperity and asking him to protect the city in the future.
Bach led the Thomanerchor in the performance on 30 August 1723.
Preise, Jerusalem, den Herrn, BWV 119