You generally need to be an institutional investor or a preferred customer of one of the brokers that is issued shares by the IPO underwriter. Here's a good general writeup
https://money.usnews.com/investing/stock-market-news/article... and Fidelity's eligibility requirements
https://www.fidelity.com/customer-service/how-to-participate....
Note that even if you meet the eligibility requirements, if the IPO is sufficiently popular you may still not get a chance to participate, as the institutions and people in line before you may have already bought all the shares.