delete key if not valid. introduce api.py