i have a company in thailand and work abroad as a freelancer. contracts are signed up between my thai company and the foreign company. I did this because certain countries hold companies accountable for the tax the freelancer need to pay. the Netherlands being such a country. So my taxes are payed in thailand.
Since you're not working in thailand, a work permit is not needed. If you work under 180 days a year, your tax is also quite low... (but then you also have to stay in thailand over 180 days)