united-kingdom
I don't have any idea yet how this works in Swiss law, but here's what I've found for the UK. If the woman is married or in a civil partnership at the time of birth, this will affect how things play out initially as it establishes a rebuttable presumption that her husband is the father,* but ultimately a court may find the donor to be the father, apparently regardless of any prior agreements or contracts. As far as I can tell, there is so far no legal framework in the UK for recognizing a role of a "sperm donor by sexual intercourse". I found this article that states that the donor would in fact be the legal father in this circumstance (even if not initially known to be):
In unregulated arrangements, the sperm donor is not the legal father if he donates by artificial insemination to a married or civilly partnered couple (51). However, if there is no second legal parent (e.g., the non-birth mother is in an unmarried couple, or the recipient is single), the sperm donor will be the legal father, irrespective of what the parents agree or what is recorded on the birth certificate (51). Further, a sperm donor who donates through sexual intercourse (sometimes called “natural insemination”) is always the legal father of any child conceived, irrespective of what the parents agree or what is recorded on the birth certificate (51). For unmarried couples, single women and anyone who conceives via sexual intercourse, then, there is the possibility that the donor could make a claim for legal parenthood, which could later be established in court (52).
("Are UK Policies and Practices for Regulated Donor Insemination Forcing Women to Find Unregulated Sperm Donors Online? A Perspective on the Available Evidence", Francesca Taylor, Rhys Turner-Moore, Allan Pacey, Georgina Louise Jones; 2022)
Citation 51 goes to "NGA Law . Parenthood After Donor Conception: Sperm Donors Co-parent Fathers. (2019). Avalable online at: https://www.ngalaw.co.uk/knowledge-centre/parenthood-after-donor-conception-spermdonors-and-co-parent-fathers"; the link appears to be broken. Citation 52 also goes to a broken link. However, checking the NGA Law website reveals some currently available posts such as "Known donation arrangements (UK law)". And this post points us to a relevant court case:
In 2013, in the case of M v F and H (2013) a married woman had met a sperm donor via an Internet matching site and conceived a child. She pursued the donor for child support, and there was a dispute over whether conception took place by artificial insemination or ‘natural insemination’. After a fact-finding hearing, the court found that conception had taken place through intercourse and held the donor liable for child support and substantial legal costs.
It seems agreements have no legal force, per NGA Law ("Known donation arrangements (UK law)"):
Whether a known donor is financially responsible depends solely on whether he is the child’s legal father. It is often a surprise for a donor to learn that no account will be taken of any agreement (written or verbal) that he should be treated as a donor. It is also irrelevant whether the donor has had involvement with the child.
Overturning the presumption of paternity in case of marriage
In cases where someone else was married to the mother and is therefore presumed to be the father, any legal parental rights or responsibilities of the donor would have to be established in court.
It seems like in principle, the current prescribed standard for when a UK family court will overturn the presumption of parenthood, in cases where conception was not accomplished by artificial insemination, is simply whether “a balance of probabilities” supports someone else being the genetic father. (A genetic test is the clearest way of establishing this, but this generally requires consent of the persons being tested, or of a minor's legal parents. Inferences may be drawn from a party's refusal to undergo genetic testing.)
It appears that a judge ruled in the case A Local Authority v SB & Ors [2022] that a judicial determination of non-parentage does not necessarily terminate parental responsibility. Termination of parental responsibility is also possible as a matter of court order, but seemingly will involve factors such as a consideration of the child's welfare. (I found this case mentioned in "Justice for Thwarted Fathers? Problems for Retrospective Parental Rights Claims", T Baron, 2024, which also discusses the situation in the united-states.)
Likewise, going back to M v F and H (2013), the judge in that case ordered that the donor ("Mr F") be re-registered as the child's father, but did not at that time confer parental responsibility on the donor, though it was noted that "If Mr F wishes to apply for parental responsibility in future, it is open to him to do so."
The paper "Identifying the legal parent/child relationship and the biological prerogative" (Gillian Black, 2018) discusses a genetic father seeking to contest the parental rights and responsibilities of a presumed father as a hypothetical situation:
Alternatively, it can be instigated by a third party, perhaps seeking to prove that he is the genetic father, thereby supplanting the person who is currently filling that role. In this case, someone who is currently the legal father will be stripped of that status and, if he is also the social parent, providing day to day care, he risks being undermined or – worse – ejected from this social role by virtue of the change in legal status. In these cases, there is no limit as to who can raise an action for a declarator of non-parentage: it could be the man currently named as the legal father; it could be the man who claims the biological – and legal – connection instead; or it could be any other party seeking to remove the existing “father” from the child’s life. The fact that there is no limit on who can raise the action places biological truth at the heart of the legal parental status:
Other relevant quotations from that article:
the position of fathers and children where (ii) the conception has occurred through natural insemination. In such cases, the pater est presumption will apply. Now rendered in statutory form in s5(1)(a) of the Law Reform (Parent and Child) (Scotland) Act
1986 (the “1986 Act”), this is the presumption that pater est quem nuptiae demonstrant: the father is he whom the marriage points out, ie the father is the man married to the mother at the time of conception or birth.
[...] Section 7 of the 1986 Act simply talks about raising an action for a declarator of parentage or non-parentage, and sets down criteria regarding standing and title in terms of domicile of the pursuer and the child. The only definition of parent is provided in section 8, which states that a parent “includes a natural parent”, without further expanding on any element of this.
[...] Section 5 also states that the standard of proof for rebutting these presumptions is “a balance of probabilities”
Some of the relevant UK law is also discussed here: "Parental Responsibility and Declarations of Non-Parentage:
A Non-Biological Father Named on a Clild’s Birth Certificate" (Magdalen Chambers)
* See the blog post "The legal status of fatherhood", November 29, 2022, Major Family Law blog, for more details. I don't know how presumption of paternity works in the UK in the context of same-sex marriage and pregnancy not initiated by means of artificial insemination. Since the presumption seems to be one of genetic paternity, I assume a judge would not apply it in cases where it is evident that this is impossible. Parental responsibility is conferred on a same-sex spouse or civil partner in the case of artificial insemination.