The ninjutsu ability can be activated when a creature attacks and isn't blocked.
From the glossary of the Comprehensive Rules (November 8, 2024—Magic: The Gathering Foundations)
- Attacks and Isn’t Blocked
- An ability that triggers when a creature “attacks and isn’t blocked” triggers when the creature becomes an unblocked attacking creature. See rule 509.1h.