The callout couldn't access the endpoint. You might not have the required permissions, or the named credential "Named_Credential_API_Name" might not exist exception in Salesforce

The callout couldn't access the endpoint. You might not have the required permissions, or the named credential "Named_Credential_API_Name" might not exist exception in Salesforce

Please check the following to resolve the issue

1. If you are using "Identity Type" as "Per User", make sure the users have access to the Named Credential. Check the following link to grant access to the users via Profile or Permission Set.
https://help.salesforce.com/s/articleView?id=sf.named_credentials_permsets_profiles.htm&type=5

2. If you are using "Identity Type" as "Named Principal", then make sure the Named Credential API Name used in the Apex Code is correct and matches. Named credential name is case-sensitive while using it in the Apex Code.