Hi
@Anas1212,
It's not clear to me from your question which type of residence permit you held until now. All I could find about a STK exam was a security procedure for medical devices. Anyway, regardless which type of permit you had up to now, it is generally possible to change from most types of permits to one for an Ausbildung.
The issue in your case is that your visa has expired and I assume you have not applied to renew it? In this case you do not have a legal status in Germany. You need to clarify this as soon as possible. The ideal situation would be that you manage to find an Ausbildung, fulfil all the other requirements (for example being able to support yourself financially) and the Ausländerbehörde allows you to renew your permit and begin your Ausbildung.
Another possibility is that even with an Ausbildung, you are told to first return to your home country and apply for a new Ausbildung visa there, because you overstayed your visa. Here you would probably be given a period of about 30 days to leave the country.
If you are required to leave the country and do not do so, then you could be deported. In this situation, where you have the offer of an Ausbildung but no residence permit, there is the possibility to get a special type of Duldung called an Ausbildungsduldung. With this you could remain in Germany to do the Ausbildung and upon successfully completing it would receive a regular residence permit.
However, to get an Ausbildungsduldung a person has to at least have had a regular Duldung for three months before it starts. From what I can tell, there are no clear grounds for you to be issued with a Duldung. It can certainly be argued, that if an Ausbildung has been secured and will begin soon, then it is sufficient reason to give someone a special type of discretionary Duldung for a few months (called Ermessensduldung, issued for a maximum of 3 months). It is a rather complicated procedure so let me know if there's anything you don't understand.
As I wrote above, it is very important to clarify your current status with the Ausländerbehörde. However, I recommend you do this after getting some advice, and ideally when you have an offer of an Ausbildung. If you do not know who to ask for help, we can find some support organisations if you tell us the region you are in. Perhaps there are also specific projects where you are that help migrants with finding an Ausbildung? They could help you to find one.
Here's a video about the Ausbildungsduldung:
https://handbookgermany.de/en/videos/faq-videos/faq-ausbildungsduldung.html
Kind regards,
Éanna