We are facing dashboard-url/api/apis/{api_id} not found while clicking on the synchronize button in the developer portal, also please let me know admin/providers/1/synchronize do developer portal apis need admin/ in the base path ? and how to auth it is it Authorization: Bearer token ?
We have fixed that by removing a policy having that deleted API but we didn’t get how it was deleted from the dashboard and having reference in the policy ?
How did you delete the API definition? Via dashboard UI, REST API or Operator?
I don’t recall there being a built-in safety measure to check if an API definition that’s about to be deleted has a policy linked to it. However, you can use a custom OPA rule to enforce it
deny["Unsafe API Deletion - denied!"] {
# Checks the request intent is to delete the API
request_permission[_] == "apis"
request_intent == "delete"
# Get original API object, before delete
api := TykAPIGet(input.request.path)
# List all policies
policies := json.marshal(TykAPIGet("/api/portal/policies?p=0"))
# Simply checks if api_id found in policies string
# Is it possible that a policy could have the same id as api_id?
# Would be better to "walk" the json and check within the access_rights or access_rights_array
contains(policies, api.api_definition.api_id)
}