def METHOD_NAME(key):
    key = ApiKey.find_by_id(key)
    if not key:
        raise ApiError('not found', 404)
    admin_audit_trail.send(current_app._get_current_object(), event='apikey-deleted', message='', user=g.login,
                           customers=g.customers, scopes=g.scopes, resource_id=key.id, type='apikey', request=request)
    if key.delete():
        return jsonify(status='ok')
    else:
        raise ApiError('failed to delete API key', 500)