Some of the APIs are in Deleted State in Portal which cannot be removed, these APIs are not present on tenant gateway.
API Developer Portal 5.2.x
For the apis that have been removed from the gateways and having portal status as Deleted and deployment status as Error, you may run this sql statement (replace with the api names that has the status DELETED):
DELETE FROM portal.API WHERE PORTAL_STATUS = 'DELETED' AND NAME IN('apiName1', 'apiName2', 'apiName3');
Take VM snapshot of the Portal database server or portal database before performing the above changes.