V3 Charts

Runs an unsaved chart and returns its rows, so a caller can check it shows what was meant before saving it. Saves nothing. The chart query is checked by the chart query validator first: a field outside the catalog, a refused Cube option, a timezone, a bound exceeded or an invalid date range answers 422 naming each problem in invalid_params. On a chart grouped by time alone, a date range wider than 10,000 buckets of its granularity is one such bound (limit_exceeded).

Needs read access to the workspace and the Feedback Dataset. Counts against the chart-query budget (600 per minute, 20 at once, per user or API key), not the v3 default.

post/api/v3/charts/preview

Request

  • Base URL
    https://app.formbricks.com
  • URL
    https://app.formbricks.com/api/v3/charts/preview
  • Auth
    • API key in cookie next-auth.session-token
    • or API key in header x-api-key
    • or HTTP bearer

Request body

workspaceIdstring cuid2 required
datasetIdstring cuid2 required

The Feedback Dataset to read; needs read access to it from workspaceId.

type'area' | 'bar' | 'pie' | 'big_number' | 'matrix' required

The chart type. A big_number shows one value, so its grouping is dropped.

Example request

{
  "query": {
    "measures": [
      "FeedbackRecords.npsScore"
    ],
    "dimensions": [
      "FeedbackRecords.sourceName"
    ],
    "timeDimensions": [
      {
        "dimension": "FeedbackRecords.collectedAt",
        "dateRange": "last 30 days"
      }
    ],
    "filters": [
      {
        "member": "FeedbackRecords.sourceType"
      }
    ]
  },
  "dateRange": "last 7 days"
}

Response

The chart's rows

Example response

{
  "data": {
    "rows": [
      {
        "FeedbackRecords.sourceName": "Web",
        "FeedbackRecords.count": 42
      }
    ]
  }
}

Changes