Transactions are context-like objects that encapsulate any changes to a Revit model. Any change to a document can only be made while there is an active transaction open for that document. Attempting to change the document outside of a transaction will throw an exception. Changes do not become a part of the model until the active transaction is committed. Consequently, all changes made in a transaction can be rolled back either explicitly or implicitly (by the destructor). Only one transaction per document can be open at any given time. A transaction may consist of one or more operations.
There are three main classes in the Revit API related to transactions:
Transaction
SubTransaction
TransactionGroup
This section will discuss each of these classes in more depth. Only the Transaction class is required to make changes to a document. The other classes can be used to better organize changes. Keep in mind that the TransactionMode attribute applied to the IExternalCommand definition will affect how Revit expects transactions to be handled when the command is invoked. Review TransactionAttribute for more information.