Had to reinstall Windows 10 but didn't write down the license key, what are my options? [duplicate]

Do you login with a Microsoft account or a local account?
If you use a Microsoft account the key is stored in that account and will automatically be re-applied when you try to activate using that same Microsoft account.
If it doesn't re-activate by itself (sometimes Windows thinks it isn't the same computer that you re-installed) the Microsoft helpdesk can help in that case.

If you never used a Microsoft account it is your responsibility to make sure you have retained the key...
In that case you will have to buy a new Windows 10 license.

It may actually be cheaper, depending on were you live and what is available, to buy a very cheap second-hand PC from someone that has a Win7 or Win8 license key that you can re-use. I purchased a couple of (not-working) Core2Duo PC's with a Win7 license just for that purpose some years ago.
The 2 scrap-PC's together cost me less than half of a new Windows 10 Pro license.

PS.
Make sure you get the correct Win 10 license. You can re-activate a Win10 Home with a Pro license, but not the other way around.