When was the Biblical canon formalised and finalised? 397, 419 or a different date?
Do different branches of Christianity state that the canon was formalised at different times?
Are there branches that have altered their canon in recent times?
This is tricky questions because there are some outliers, but I'll describe the broadly accepted tradition, excluding some smaller Christian groups.
As far as the New Testament, the 39th Festal Letter of Athanasius (AD 367) is the first complete list of the books broadly accepted in the New Testament by Christians (there are a few smaller groups who have slightly different lists). But there was wide agreement on most books well before this.
The Four Gospels were settled and virtually unquestioned very early on (see C. E. Hill Who Chose the Gospels?), and the main corpus of Paul, quite possibly selected by Paul himself, was also widely accepted early on. There were some stragglers like Hebrews, Revelation, and 2 Peter that didn't receive wide acceptance until later and a few that were on the edges of acceptance like 1 Clement and the Shepherd of Hermas, but the list had settled down by the time of Athanasius's letter.
Thus, conservative scholar Michael Kruger suggests there are three senses of "canonical":
Most of the NT books were functioning as canon well before they were officially received. Kruger argues that there never was and still isn't an exclusive canon, but received, functional, and ontological are three useful lenses.
The generally received Old Testament canon has a little bit of extra flux concerning the Apocrypha, going back to the ancient Jews in Alexandria using it, having those books being appended to the Septuagint (ancient Greek translation of the OT), Jerome giving them the name Apocrypha in his preface to the books of Samuel and Kings, and the Council of Trent during the Reformation period declaring the books to be deuterocanonical (second canon) and the opposing Reformers saying the Apocrypha are useful to be read but not infallible or inspired. But otherwise, the OT is already set by the time of Jesus.
This question has an accepted answer, but, with all due respect, I do not think that the answer is accurate.
There are three distinct sources of information related to the formation of the Christian Biblical canon - both Old and New Testament:
The content of ancient Bible manuscript collections themselves
Early Christian writings
The canons of local and Ecumenical Church Councils
I would regard #1 and #2 as interesting and important information, but these items do not indicate a formal or final closure of the canon, as requested by the OP.
The first formal acknowledgement of a New and Old Testament canon by the Church I believe occurred at the 3rd local Council of Carthage in 397. Canon XXIV of this Council enumerated the Books of the Old Testament as comprising:
- Genesis, Exodus, Leviticus, Numbers, Deuteronomy
- Joshua, Judges, Ruth
- Four "books of Kings" (Regnorum libri quator)2, namely 1/2 Samuel and 1/2 Kings
- Two "books of Paraleipomena" (Paralipomenon libri duo), i.e. 1/2 Chronicles
- Five "books of Solomon", understood to be Proverbs, Ecclesiastes, Song of Songs, Wisdom of Solomon, and Wisdom of Sirach/Ecclesiasticus
- The books of the 12 Prophets: Hosea, Amos, Micah, Joel, Obadiah, Jonah, Nahum, Habakkuk, Zephaniah, Haggai, Zechariah, Malachi
- Isaiah, Jeremiah, Ezekiel, Daniel
- Two "books of Esdras" (Esdrae libri duo), understood to be Ezra and Nehemiah
- Two "books of the Maccabees" (Machabaeorum libri duo)
The New Testament Books listed are:
- Four "books of the Gospels" (Matthew, Mark, Luke, John)
- Acts of the Apostles
- 13 "Epistles of the Apostle Paul" plus "one epistle of the same to the Hebrews"
- 2 Epistles of Peter
- 3 Epistles of John
- Epistle of James
- Epistle of Jude
- The Apocalypse of John (Apocalipsis Johannis)
"Let this be made known", the Council instructed,
to our brother and fellow-priest Boniface, or to other bishops of those parts, for the purpose of confirming that Canon, because we have received from our fathers that those books must be read in the Church.
A similar list of the Old and New Testament Books was given in the Apostolic Canons, which where were a collection of ancient decrees regarding the governance of the Church. Although thought to be quite old3, they were only formally accepted by the local Council of Trullo, in 692. Canon LXXXV of the Apostolic Canons enumerated same Books of the Old Testament as is found in the list produced by the 3rd Council of Carthage, with the following exceptions:
- Some texts omit mention of the book of Judith
- Tobit is not listed
- Three rather than two Books of Maccabees are listed
- The Wisdom of Solomon is omitted
- The Wisdom of Sirach is set apart from the other books "of Solomon"4
The list of New Testament books matches what was provided by the Council of Carthage, with the Gospels being listed by name and with reference to "14 Epistles of Paul".
The same council, however, also ratified the Canons of the Third Council of Carthage, which accepted additional books into the Biblical canon. Thus, the full list of Old Testament Books that were accepted in the eastern Sees (see below) was that specified by the Council of Carthage with the addition of 3 Maccabees.
The Council of Trullo was not accepted by the See of Rome at the time, but was accepted by the eastern Sees of Constantinople, Alexandria, Antioch, and Jerusalem. By the time of the Council of Trullo (692), schisms had already arisen that had spawned the two non-Chalcedonian Orthodox branches of Christianity that today comprise the Oriental Orthodox and Church of the East.
I cannot speak to how the canon of Scripture developed within those two branches, but by 692 there were two formal canons - with slight differences in the Old Testament - accepted by the Chalcedonian Churches.
The Seventh Ecumenical Council - the Second Council of Nicea - in 787 was the last Council recognized by all five Sees of the ancient Church (Rome plus the four eastern Sees). Called primarily to condemn the iconoclast heresy, the Council also ratified the acts and canons of the Council of Trullo. This would mark, I believe, the first time that a formal ecclesiastical body representing all five Sees of the ancient Church formally agreed on the list of books to be recognized as belonging to both the Old and New Testament.
The Great Schism between the east (Sees of Constantinople, Alexandria, Antioch, Jerusalem) and the west (See of Rome) occurred in 1054, although many conflicts had been leading up to the break. Subsequently, two additional Councils were convened - one in Trent c. 1546, another in Jerusalem in 1672.
The Council of Trent was a Council held by the Roman Catholic Church that issued a decree, De Canonicis Scripturis, that re-affirmed the canon published at the Third Council of Carthage in 397.
The Synod of Jerusalem was a local council within the Eastern Orthodox Patriarchate of Jerusalem which met in 1672, largely to refute what it saw as heretical Calvinist doctrine attributed to the former Patriarch, Cyril Lucaris. In the course of the Synod, an amendment to the Old Testament canon was adopted which added a 4th Book of Maccabees along with the Prayer of Manasseh in an appendix and included a 151st Psalm. Although the 1672 Synod was a local Council, most Eastern Orthodox Patriarchates today accept the Jerusalem canon, with the exception of the universal inclusion of 4 Maccabees.
In the above, I have only addressed those Christian faiths which have their roots in the ancient Church Sees. I am not familiar with the formal events which gave rise to additional (post-Reformation) changes to the canon that are recognized by other Christian faiths.
1. We should not expect, I think, much in the way of a formal acknowledgment of the Christian Biblical canon until at least the early 4th century, since prior to this time Christians were under terrible persecution in various times and in various parts of the Roman Empire. Until Constantine's legalization of Christianity with the Edict of Milan in 313, it would have been very difficult for such a large body of Church hierarchs to meet in one place.
2. These books are titled 1-4 "Kingdoms" or "Kings" in the Septuagint
3. It has been suggested that the Apostolic Canons arose from the Acts of a local Council in Antioch, in 341
4. "But besides these you are recommended to teach your young persons the Wisdom of the very learned Sirach"