Env: Genesys Cloud EU West, Pulumi 3.92.0, TypeScript 4.9
Auth: Service Account (Client Credentials)
Endpoint: POST /api/v2/analytics/conversations/aggregates
Error: 400 Bad Request - Invalid value for 'interval'
Can anyone clarify why the Analytics API rejects my interval configuration when deployed via Pulumi?
I’m building a custom interval report to track queue handle times. The Pulumi genesyscloud provider maps the genesyscloud_analytics_view resource to the underlying REST API. When I define the interval block, the generated JSON payload looks correct, but the API returns a 400.
The Pulumi preview shows the resource creation, but the apply fails with: Error creating Analytics View: 400 Bad Request { "errors": [ { "message": "Invalid value for 'interval'", "field": "filter.interval.custom.intervals" } ] }
I’ve verified the ISO 8601 timestamps are valid. I also tested the equivalent JSON payload directly against the /api/v2/analytics/conversations/aggregates endpoint using Postman, and it works fine. The issue seems specific to how the Pulumi provider serializes the filter object or validates the interval type schema.
Is there a known issue with the genesyscloud provider handling custom interval arrays in the filter block? Or am I missing a required nested property like unit or resolution in the Pulumi resource definition? The docs are sparse on custom interval constraints for IaC.
TL;DR: The Analytics API expects ISO 8601 duration strings for the interval field, not numeric values.
You might want to look at using the PureCloudPlatformClientV2.AnalyticsApi SDK to generate the correct payload structure instead of constructing it manually in TypeScript.
const body = new platformClient.AnalyticsApi().createAggregateBody({
interval: 'PT1H', // ISO 8601 duration
dateFrom: '2023-10-01T00:00:00Z',
dateTo: '2023-10-02T00:00:00Z'
});
This happens because the strict schema validation on the POST endpoint, which rejects non-string types for the interval parameter. While the previous suggestions correctly identify the ISO 8601 requirement, the root cause in your Pulumi deployment is likely TypeScript type coercion during the JSON serialization process.
In my Angular enterprise desktop applications, I enforce explicit string typing to prevent this exact issue when constructing API payloads via the PureCloudPlatformClientV2 SDK. You must ensure your Pulumi resource definition explicitly casts the value to a string before passing it to the createAggregateBody method.
// Explicit cast to prevent TS coercion to number
const aggregateBody = {
interval: String('PT1H'), // Forces string type
dateFrom: '2023-10-01T00:00:00.000Z',
dateTo: '2023-10-02T00:00:00.000Z'
};
Verify your service account possesses the analytics:conversation:read scope. Without this, the API may return ambiguous 400 errors. I recommend logging the raw JSON payload sent by Pulumi to confirm the interval field is not being serialized as an integer.