How to generate api keys with expiration dates for sharing configs?

I want to have a config cloud shop so how could I make it so if someone buys for example a 1 day key on my website. a api key that will last 1 day will be generated and given to them.

Or maybe I can just generate like 100x 1 Day keys and the 1 day countdown doesn’t start till they have used it in openbullet?