You can use this online service to apply electronically for a settlement permit.
The settlement permit allows you to stay in Germany indefinitely. In principle, any foreigner who has held a residence permit for at least five years, is able to support themselves including health insurance cover, has paid contributions to the statutory pension insurance scheme for at least 60 months (five years) or expenses for an entitlement to comparable benefits, is in possession of the necessary permits to pursue gainful employment, has sufficient German language skills and is well integrated can apply for a settlement permit.