Hi
you just begin to install it, choose "i dont have a product key"...once installed you can simply activate/purchase a key there & then:
Open the Settings app and head to Update & Security > Activation. You’ll see a “Go to Store” button that will take you to the Windows Store if Windows isn’t licensed. (source: how to geek)
Or, you can purchase a code from various websites (make sure your buying from a genuine retailer) and on the same activation page above you can choose "change product key" and enter it