Barrett et al. (2013) distinguish between accidental/unauthorised, inadvertent, and deliberate nuclear launches or detonations:
"In an accidental or unauthorized launch or detonation, system safeguards or procedures to maintain control over nuclear weapons fail in such a way that a nuclear weapon or missile launches or explodes without direction from leaders."
"In an inadvertent detonation, the attacking nation mistakenly concludes that it is under nuclear attack and launches one or more nuclear weapons in what it believes is a counterattack."
In a deliberate detonation, the attacking nation decides to launch one or more nuclear weapons either in response to a genuine nuclear attack or without believing that it is under nuclear attack.
The only non-test nuclear weapons to date, by the US in 1945, were both deliberate. But a future nuclear conflict could in theory begin with any of those three types of detonations, which could then be followed by detonations from the same or other types.