Below is a checklist of the main areas to investigate and adjust based on our current understanding of the Postmaster Tools API:
1. Required Date Parameters
The Postmaster Tools API expects you to pass a date or date range when querying for traffic stats. In many cases, omitting required parameters like the start and end dates can lead to a "Requested entity was not found" error—even if the dashboard shows data for the domain.
What to do:
Include the required date-related query parameters (for example, start and end dates) in your call. According to the documentation, you’d structure your request like this:
const details = await gmailpostmaster.domains.trafficStats.list({
parent: "domains/example.com",
// Specify the date range. Adjust the values to represent a valid date range for which data exists.
startDate: { year: 2023, month: 1, day: 1 },
endDate: { year: 2023, month: 1, day: 1 },
});
Make sure these dates cover a period for which Postmaster data is available. Without them, the API may not know which data to return.
2. Verifying Domain Access & API Enablement
The fact that you retrieve the domain list successfully confirms that the authentication is mostly correct; however, double-check the following:
-
Domain Ownership / Verification:
Ensure that the domain in question is properly verified and registered in Postmaster Tools. The API might return a “notFound” error for domains that haven’t been fully verified for API access even if they appear in the dashboard.
-
API Enablement in GCP:
Confirm that the Postmaster Tools API is enabled for your Google Cloud project. An account might have valid credentials, but if the API isn’t enabled on the console, it may cause issues.
3. Review OAuth Scopes
You’re using the “postmaster.readonly” scope, which is correct for fetching read-only data. Just ensure that the authenticated user indeed has access to the requested domain's metrics. If the domain is among many, verify that no other access controls are interfering.
4. Testing via API Playground
Since you mentioned the error occurs even in the API Playground despite data showing on the dashboard, it’s a strong indication that the error is related to the request parameters (most notably the missing date range) or the verification status of the domain.
Summary
Most likely, the error is due to missing required date parameters. Adjust your API call to include a valid “startDate” and “endDate” (or other required date parameters), and then verify that the domain has been correctly set up and verified for Postmaster Tools.
If you continue to experience issues even after including the date parameters, double‑check domain verification and API enablement, or review any updates to the API requirements in the latest official documentation.