Problem
This article is intended to resolve a situation wherein API requests to the Terraform Cloud's Audit Trail API succeed with an HTTP 200 status code but also contain an empty JSON skeleton like below:
body: { "data": [], "pagination": { "current_page": 1, "page_size": 1000, "prev_page": null, "next_page": null, "total_pages": 0, "total_count": 0 }
Cause
This response only occurs when the API user is authenticated with the wrong token, such as a user API token. API requests to the Audit Trails API require the permissions of an organization token as noted in the documentation:
Solution
Generating a new organization API token and using this to authenticate the Terraform Cloud Audit Trails API should resolve the issue. These can be generated at https://app.terraform.io/app/<organization>/settings/authentication-tokens
or by going to Terraform Cloud, choosing your organization, and selecting Settings on the purple top bar, then selecting "API tokens" on the left bar.
Additional Information
Audit Trail API Documentation - https://www.terraform.io/cloud-docs/api-docs/audit-trails
API Token Documentation - https://www.terraform.io/cloud-docs/users-teams-organizations/api-tokens