A monoid object in a pointed category $\mathcal{C}$ is an object $M$ equipped
with a multiplication morphism $\mu: M\times M\to M$ that is associative and unital, meaning that the diagrams that express those properties commute. A (two-sided) $M$ "module" also can be formulated in terms of arrows: we need action map $\alpha\_R:X\times M \to X$ and $\alpha\_L:M\times X\to X$ that are associative and unital. The arrows $M \to M\times X\to X$ and $M\to X\times M \to X$ should be equal; let's call it $t:M\to X$.


Now let $t: M\to X$ be the morphism from the monoid $M$ to its two-sided module $X$. I'd like to find an "extension" $e:M\to N$ of $M$ using $t$. The properties that I want for the extension are


1. $N$ should be a monoid object and $e$ should be a homomorphism
2. $e$ should factor $M\xrightarrow{t} T\xrightarrow{f}N$
3. if $h:M\to Q$ is a monoid homomorphism that factors $M\xrightarrow{t}T\xrightarrow{k} Q$ for some morphism $k:T\to Q$, then there is a unique homomorphism $g\_k: N\to Q$ such that $k =g\_k\circ f$.


I have a plan for how to make this construction. Set $N(0) = M$ and inductively define $N(k)$ by forming the pushouts of the diagrams
$$
 N(k)
 \longleftarrow
 (N(k)\times\_{M} N(0)) 
 \cup 
 (N(k-1) \times\_{M} N(1)) 
\longrightarrow
 N(k)\times\_{M} N(1) 
$$
Then $N = \mathrm{colim}\, N(k)$ should do the job.
Some notes:


1. The notation $A \times\_M B$ indicates a "tensor product of modules" defined to be the pushout of $A\times B \gets A\times M \times B\to A\times B$, using the action map of $A$ on the left and $B$ on the right.
2. I am using union as shorthand for a pushout.
3. Partial multiplications $N(k)\times\_M N(\ell) \to N(k+\ell)$ would have to be defined along the construction.


I don't have any serious fears about this construction; but rather than work it all out and write it all down, I'd prefer a good reference.


**Question:** *Is there a good reference for monoid extensions in this sort of categorical generality?*



Extending a monoid object in a category
I don't think the question as you asked with the construction you are describing as been explicitely treated in the literature (though it very well could be).


What has been discused a lot in the litterature is special case where $M$ is the trivial monoid (the terminal object, or more generally the unit for the product). This is the construction of the "Free monoid on a pointed object". See for example this [paper](https://arxiv.org/pdf/0802.1946.pdf) of S.Lack and its references.


The construction in the paper of Lack do not seem to be quite the same as the one you are after though.
I suspect the construction you described can be extracted from [Kelly's transfinite paper](https://www.cambridge.org/core/journals/bulletin-of-the-australian-mathematical-society/article/unified-treatment-of-transfinite-constructions-for-free-algebras-free-monoids-colimits-associated-sheaves-and-so-on/FE2E25E4959E4D8B4DE721718E7F55EE).
Specifically, he shows in section 23 how to construct this free monoid using the construction of the free algebra on a pointed endofunctor, which I think gives exactly the construction you are describing, but it is not said so explicitely.


Now, the more general case you are talking about (with M non trivial) **can be recovered from this special case** as follows: The construction I described above do not assume that we work with the cartesian product: any monoidal structure (with some colimit preservation properties) will suffice.


Because of this, you can work in the category of $M$-bimodule, with the tensor product $A \otimes\_M B$ (which use the right $M$-module structure on $A$ and the left $M$-module structure on $B$ to define the tensor product, and the other two to endow the tensor product with a bimodule structure).


The unit object of $M$ with its obvious bimodule structure.


A "pointed object" here is exactly a bimodule $X$ with a bimodule morphism $M \to X$ as you describe.


A monoid in this monoidal category is the same as a monoid $N$ with a morphism of monoid $M \to N$. So what you are after is the construction of the free monoid on a pointed object in this category of bimodules, which can be constructed using Kelly's or Lack's paper (and probably other references).


In terms of assumption, you need some assumption of existence of colimits (to define the tensor product of bimodule and to perform your construction) and of preservation of colimits under products for the construction itself to work (and maybe also for the tensor product of $M$-bimodule to be a monoidal structure ?). The precise assumption you need depends on which construction exactly you are using, but the safe thing to do is to assume that you work in a cartesian (or monoidal) closed category.


