In short, foreign persons can own a condominium or apartment in a building where foreign ownership does not exceed 49%.
Long text from https://www.thailandlawonline.com/thai-real-estate-law
Foreigners and foreign “legal persons” can own a unit in a building registered and licensed under the Condominium Act of Thailand. Section 19 of this law regulates foreign ownership of condominiums, which, among other things, limits foreign ownership of a condominium building and that no more than 49% of all units in a condominium development be foreign-owned.
Condominium Act
If the total usable area of all units together is 6000 square meters, 2940 square meters can be foreign-owned, or in the case of 100 equal units in a condominium building, up to 49 of the units can be foreign-owned, 51 or more must be Thai-owned. In addition, foreigners must qualify for Section 19 ownership, which usually means that the foreigner must have brought foreign currency into Thailand equal to at least the total purchase of the condominium and converted that amount into Thai baht. The recipient bank in Thailand will provide documents for foreign currency transfer and exchange, and this evidence must be presented to the Land Department to register foreign property. It should be noted that foreign ownership is an individual personal right of the alien who has qualified under section 19 and therefore foreign ownership of the unit is not transferable to another alien unless that alien (including foreign heirs) is also qualified for property according to Section 19 of the Residential Property Act.
If foreign condominium units are no longer available in a condominium project, the remaining units can be rented to foreigners. Normal tenancy law applies to the rental of a condominium by foreigners. There is no separate law governing the renting or renting of condominiums by foreigners as opposed to the purchase of a condominium.
Foreign ownership exists only in a condominium registered and licensed under the Thailand Condominium Act. In the tourist areas of Thailand, apartment buildings that are not registered and licensed as condominiums are common. These apartment buildings are basically like any other building and the owner can rent out parts of his building on his own terms. For example, unregistered apartment buildings could be sold as a form of time-share, where the units are sold through leases to many different parties, each with a specific block of time in which to use the apartment.