- Does anyone understand why the Security Audit API returns a 403 Forbidden when querying credential rotation events for our 15 BYOC trunks?
- The endpoint is /api/v2/audit/events with filter type=TRUNK_CREDENTIAL_UPDATE.
- Our service account has Org Admin and Security Admin roles.
- This blocks our compliance reporting for APAC regions.
- Standard error payload indicates missing scope, but scopes look correct.
Check your scope configuration for the OAuth client. The Org Admin role grants UI access, but the Audit API requires explicit OAuth scopes. The 403 error usually means the token lacks audit:read.
The service account needs these scopes:
{
"grant_type": "client_credentials",
"scope": "audit:read security:read"
}
Also, BYOC trunk events are indexed differently. The filter type=TRUNK_CREDENTIAL_UPDATE might be too specific. Use type=TRUNK with a search parameter for credential. This catches rotation events logged under TRUNK_UPDATE or TRUNK_CONFIG_CHANGE.
Example request:
curl -X GET \
"https://api.mypurecloud.com/api/v2/audit/events?type=TRUNK&search=credential&pageSize=100" \
-H "Authorization: Bearer <token>"
If the issue persists, check the environment tag. BYOC events include environment:BYOC in the payload. The API might filter these out if the client lacks byoc:read.
Add byoc:read to the scope:
{
"grant_type": "client_credentials",
"scope": "audit:read security:read byoc:read"
}
This resolves most 403s on BYOC audit trails. The API documentation is sparse on BYOC-specific scopes. The byoc:read scope is required for any trunk-related audit queries.
Test with a small pageSize first. Large queries on BYOC trunks can hit rate limits. The API returns 429 Too Many Requests if you exceed 1000 requests per minute.
Also, ensure the service account has access to the specific BYOC environment. If the account is restricted to a subset of environments, the audit query will fail. Use the environmentId parameter to target the correct BYOC instance.
curl -X GET \
"https://api.mypurecloud.com/api/v2/audit/events?type=TRUNK&search=credential&environmentId=<your-byoc-env-id>" \
-H "Authorization: Bearer <token>"
This should return the credential rotation logs. If not, check the audit:read scope permissions in the IAM settings. The role might be assigned, but the scope could be missing.