Skip to content

Endpoints

Save a query or insight as a named endpoint, then call it from your own apps with one simple request.

An endpoint is a saved query with a name. Instead of sending the full query text from your app every time, you save it once in My Journey Analytics and call it by name:

POST /api/projects/<project ID>/endpoints/<endpoint name>/run/

Endpoints suit dashboards in your own product, internal tools and scheduled jobs, anywhere the same query runs again and again with different inputs. Changing the query in the app changes what every caller gets, without redeploying your code.

Create an endpoint

You can create an endpoint from a SQL query or from an insight.

From a SQL query:

  1. Open the SQL editor and write your JenQL query.
  2. Choose Save as endpoint....
  3. Give it an Endpoint name and, optionally, a description.

From an insight:

  1. Open Endpoints and choose New endpoint.
  2. Pick an existing insight, or create a new one.

Endpoint names must start with a letter and use only letters, numbers, hyphens and underscores, up to 128 characters, for example weekly-signups or revenue_by_plan. The name is part of the address your app calls.

The Endpoints page lists every endpoint in the project, with its usage and recent runs.

Call an endpoint

Authenticate with either:

  • a personal API key with the endpoint:read scope, or
  • a project secret API key, made for your servers. Create one under Settings → Project → Project secret API keys with the Endpoint execution preset.
bash
curl -X POST https://app.myjourneyanalytics.com/api/projects/12345/endpoints/weekly-signups/run/ \
  -H "Authorization: Bearer <API key>" \
  -H "Content-Type: application/json" \
  -d '{}'
js
const res = await fetch(
  "https://app.myjourneyanalytics.com/api/projects/12345/endpoints/weekly-signups/run/",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MJ_SECRET_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ variables: { plan: "growth" } }),
  },
);
const { columns, results } = await res.json();

Keep both kinds of key on your servers. Never call an endpoint with a key from a browser or mobile app.

Request options

FieldDescription
variablesValues for the query's variables, by name. Unknown names are rejected with 400
limitThe most rows to return. Without it, all rows are returned
offsetRows to skip; needs limit, and works for SQL endpoints only
versionRun a specific saved version. Without it, the latest version runs

The same options can also be sent as query string parameters on a GET request.

Variables

For an endpoint made from a SQL query, define variables in the SQL editor and reference them in the query as {variables.<name>}:

sql
SELECT count() FROM events
WHERE event = {variables.event_name} AND timestamp > now() - INTERVAL 7 DAY

Then pass a value when you call it:

json
{ "variables": { "event_name": "order completed" } }

For an endpoint made from an insight, date_from and date_to are built-in variables:

json
{ "variables": { "date_from": "2026-09-01", "date_to": "2026-09-30" } }

The response

FieldDescription
resultsThe rows, each a list of values in the order of columns
columnsThe column names
hasMoretrue when more rows exist beyond the limit
endpoint_versionThe version that ran
execution_idAn ID for this run, to find it in the endpoint's logs

If the endpoint name does not exist or the endpoint is not active, the response is 404.

Versions

Saving a change to an endpoint's query creates a new version. Callers get the latest version by default; pass version to keep using an older one while you test a change.

Can't find what you need? Contact support