Skip to content

Insights API

List, read, create and update saved insights through the API, and fetch their results.

An insight is a saved chart or table: a trend, funnel, retention table, SQL query and so on. The insights API manages saved insights and returns their latest results.

To calculate something without saving an insight, use the query API.

Reading needs a personal API key with insight:read; creating and changing insights needs insight:write.

List insights

GET /api/projects/<project ID>/insights/
ParameterDescription
short_idThe insight with this short ID
searchInsights whose name, description or tags contain this text
savedtrue for saved insights only
favoritedAny value to return only favourited insights
insightOne type only: TRENDS, FUNNELS, RETENTION, PATHS, STICKINESS, LIFECYCLE or SQL
basictrue to return names and settings without results, which is faster
limit, offsetPaging, see pagination
bash
curl "https://app.myjourneyanalytics.com/api/projects/12345/insights/?saved=true&basic=true" \
  -H "Authorization: Bearer <personal API key>"

Get an insight and its results

Every insight has a numeric id and a short_id. The short ID is the code in the insight's address in the app: in https://app.myjourneyanalytics.com/project/12345/insights/aB3dE9xY it is aB3dE9xY.

bash
curl "https://app.myjourneyanalytics.com/api/projects/12345/insights/?short_id=aB3dE9xY&refresh=blocking" \
  -H "Authorization: Bearer <personal API key>"

Or by numeric ID:

GET /api/projects/<project ID>/insights/<insight ID>/?refresh=blocking

The response includes the insight's query, its result and last_refresh, the time the result was calculated.

The refresh parameter decides whether results are recalculated:

ValueBehaviour
force_cacheReturn cached results only, never calculate. Fastest
blockingUse recent cached results if there are any; otherwise calculate and wait
force_blockingAlways recalculate and wait
asyncUse recent cached results, or start calculating in the background and return straight away
force_asyncAlways start a fresh calculation in the background

With async and force_async, check query_status in the response, then request the insight again once the calculation is complete.

Create an insight

An insight is defined by a query. This one is a daily trend of pageviews over the last 7 days:

bash
curl -X POST https://app.myjourneyanalytics.com/api/projects/12345/insights/ \
  -H "Authorization: Bearer <personal API key>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pageviews, last 7 days",
    "saved": true,
    "query": {
      "kind": "InsightVizNode",
      "source": {
        "kind": "TrendsQuery",
        "series": [{ "kind": "EventsNode", "event": "$pageview", "math": "total" }],
        "dateRange": { "date_from": "-7d" },
        "interval": "day"
      }
    }
  }'

The quickest way to get the query for anything more complex is to build the insight in the app, then read it back with the API and copy its query.

Older integrations may send a filters object instead of a query. That is no longer accepted: send a query.

Update an insight

Send only what you want to change:

bash
curl -X PATCH https://app.myjourneyanalytics.com/api/projects/12345/insights/<insight ID>/ \
  -H "Authorization: Bearer <personal API key>" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Pageviews (all sites), last 7 days" }'

Delete an insight

Insights are not deleted with DELETE, which returns 405. Mark them deleted instead:

bash
curl -X PATCH https://app.myjourneyanalytics.com/api/projects/12345/insights/<insight ID>/ \
  -H "Authorization: Bearer <personal API key>" \
  -H "Content-Type: application/json" \
  -d '{ "deleted": true }'

Can't find what you need? Contact support