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:
- Open the SQL editor and write your JenQL query.
- Choose Save as endpoint....
- Give it an Endpoint name and, optionally, a description.
From an insight:
- Open Endpoints and choose New endpoint.
- 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:readscope, or - a project secret API key, made for your servers. Create one under Settings → Project → Project secret API keys with the Endpoint execution preset.
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 '{}'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
| Field | Description |
|---|---|
variables | Values for the query's variables, by name. Unknown names are rejected with 400 |
limit | The most rows to return. Without it, all rows are returned |
offset | Rows to skip; needs limit, and works for SQL endpoints only |
version | Run 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>}:
SELECT count() FROM events
WHERE event = {variables.event_name} AND timestamp > now() - INTERVAL 7 DAYThen pass a value when you call it:
{ "variables": { "event_name": "order completed" } }For an endpoint made from an insight, date_from and date_to are built-in variables:
{ "variables": { "date_from": "2026-09-01", "date_to": "2026-09-30" } }The response
| Field | Description |
|---|---|
results | The rows, each a list of values in the order of columns |
columns | The column names |
hasMore | true when more rows exist beyond the limit |
endpoint_version | The version that ran |
execution_id | An 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