Making an appointment at SEF
The SEF is an organization that deals with the legalization of migrants in Portugal. To apply there, you have to have an appointment in advance. You have to go to the Portuguese consulate in the country where you live (it is assumed that you are either a citizen of that country or have a residence permit). Most likely, you will need to make an appointment there. You need to bring them the documents, they will review them and give you a type D visa. This visa entitles you to enter Portugal for further legalization. The visa is valid for 180 days. Along with this visa, you will have a appointment at AIMA. However, you should keep in mind that the list of required documents includes a rental agreement for a year and an account in a Portuguese bank. It turns out that to apply to the consulate, you need to go to Portugal, open an account there, find a place to live, gather all documents and apply to AIMA.