Analytics API 400 on Custom Segment Export via ServiceNow

Just noticed that the analytics export endpoint is rejecting our ServiceNow payload with a 400 Bad Request. The segment filters look valid in the UI, but the API fails.

  1. Constructed the POST to /api/v2/analytics/conversations/details/query.
  2. Included a custom segment ID in the filters array.
  3. Received 400 stating ‘Invalid segment definition’.

Cross-referenced the docs, and the syntax seems correct. Any ideas on why the API rejects this specific segment?

If I remember correctly…

  • The Invalid segment definition error often stems from how the API handles custom segment expansion versus static filter arrays. The UI expands these automatically, but the raw API call requires explicit filter objects rather than just an ID reference.
  • Verify the group_by and interval parameters. If a custom segment relies on specific time-bound attributes, missing these can cause the query engine to reject the payload as undefined.
  • Check for deprecated metric keys within the segment. Older segments might reference legacy call flow metrics that have been retired in recent platform updates.
  • Inspect the dateFrom and dateTo formatting. They must be ISO 8601 strings with timezone offsets (e.g., 2023-10-27T08:00:00+08:00). Using local server time without the offset often triggers a 400.
  • Enable debug logging on the analytics service account. This usually reveals the specific filter node causing the validation failure, which is often hidden in the generic 400 response.