Create Continuous Query
curl --request POST \
--url https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query \
--header 'Content-Type: application/json' \
--header 'X-Management-Key: <api-key>' \
--data '
{
"export_preferences": {
"data_events": {
"enabled": true
}
},
"query": {
"group_by": [
{
"arg": {
"index": "sleep"
},
"date_trunc": {
"unit": "month",
"value": 1
}
}
],
"select": [
{
"group_key": "*"
},
{
"arg": {
"value_macro": "sleep_score",
"version": "automatic"
},
"func": "mean"
}
]
},
"query_config": {
"provider_priority_overrides": [
"oura"
]
},
"scheduling_preferences": {
"minimum_gap_duration_second": 3600
},
"slug": "weekly_mean_sleep_score",
"title": "Weekly Mean Sleep Score"
}
'import requests
url = "https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query"
payload = {
"export_preferences": { "data_events": { "enabled": True } },
"query": {
"group_by": [
{
"arg": { "index": "sleep" },
"date_trunc": {
"unit": "month",
"value": 1
}
}
],
"select": [
{ "group_key": "*" },
{
"arg": {
"value_macro": "sleep_score",
"version": "automatic"
},
"func": "mean"
}
]
},
"query_config": { "provider_priority_overrides": ["oura"] },
"scheduling_preferences": { "minimum_gap_duration_second": 3600 },
"slug": "weekly_mean_sleep_score",
"title": "Weekly Mean Sleep Score"
}
headers = {
"X-Management-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Management-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
export_preferences: {data_events: {enabled: true}},
query: {
group_by: [{arg: {index: 'sleep'}, date_trunc: {unit: 'month', value: 1}}],
select: [
{group_key: '*'},
{arg: {value_macro: 'sleep_score', version: 'automatic'}, func: 'mean'}
]
},
query_config: {provider_priority_overrides: ['oura']},
scheduling_preferences: {minimum_gap_duration_second: 3600},
slug: 'weekly_mean_sleep_score',
title: 'Weekly Mean Sleep Score'
})
};
fetch('https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'export_preferences' => [
'data_events' => [
'enabled' => true
]
],
'query' => [
'group_by' => [
[
'arg' => [
'index' => 'sleep'
],
'date_trunc' => [
'unit' => 'month',
'value' => 1
]
]
],
'select' => [
[
'group_key' => '*'
],
[
'arg' => [
'value_macro' => 'sleep_score',
'version' => 'automatic'
],
'func' => 'mean'
]
]
],
'query_config' => [
'provider_priority_overrides' => [
'oura'
]
],
'scheduling_preferences' => [
'minimum_gap_duration_second' => 3600
],
'slug' => 'weekly_mean_sleep_score',
'title' => 'Weekly Mean Sleep Score'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Management-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query"
payload := strings.NewReader("{\n \"export_preferences\": {\n \"data_events\": {\n \"enabled\": true\n }\n },\n \"query\": {\n \"group_by\": [\n {\n \"arg\": {\n \"index\": \"sleep\"\n },\n \"date_trunc\": {\n \"unit\": \"month\",\n \"value\": 1\n }\n }\n ],\n \"select\": [\n {\n \"group_key\": \"*\"\n },\n {\n \"arg\": {\n \"value_macro\": \"sleep_score\",\n \"version\": \"automatic\"\n },\n \"func\": \"mean\"\n }\n ]\n },\n \"query_config\": {\n \"provider_priority_overrides\": [\n \"oura\"\n ]\n },\n \"scheduling_preferences\": {\n \"minimum_gap_duration_second\": 3600\n },\n \"slug\": \"weekly_mean_sleep_score\",\n \"title\": \"Weekly Mean Sleep Score\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Management-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query")
.header("X-Management-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"export_preferences\": {\n \"data_events\": {\n \"enabled\": true\n }\n },\n \"query\": {\n \"group_by\": [\n {\n \"arg\": {\n \"index\": \"sleep\"\n },\n \"date_trunc\": {\n \"unit\": \"month\",\n \"value\": 1\n }\n }\n ],\n \"select\": [\n {\n \"group_key\": \"*\"\n },\n {\n \"arg\": {\n \"value_macro\": \"sleep_score\",\n \"version\": \"automatic\"\n },\n \"func\": \"mean\"\n }\n ]\n },\n \"query_config\": {\n \"provider_priority_overrides\": [\n \"oura\"\n ]\n },\n \"scheduling_preferences\": {\n \"minimum_gap_duration_second\": 3600\n },\n \"slug\": \"weekly_mean_sleep_score\",\n \"title\": \"Weekly Mean Sleep Score\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Management-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"export_preferences\": {\n \"data_events\": {\n \"enabled\": true\n }\n },\n \"query\": {\n \"group_by\": [\n {\n \"arg\": {\n \"index\": \"sleep\"\n },\n \"date_trunc\": {\n \"unit\": \"month\",\n \"value\": 1\n }\n }\n ],\n \"select\": [\n {\n \"group_key\": \"*\"\n },\n {\n \"arg\": {\n \"value_macro\": \"sleep_score\",\n \"version\": \"automatic\"\n },\n \"func\": \"mean\"\n }\n ]\n },\n \"query_config\": {\n \"provider_priority_overrides\": [\n \"oura\"\n ]\n },\n \"scheduling_preferences\": {\n \"minimum_gap_duration_second\": 3600\n },\n \"slug\": \"weekly_mean_sleep_score\",\n \"title\": \"Weekly Mean Sleep Score\"\n}"
response = http.request(request)
puts response.read_body{
"export_preferences": {
"data_events": {
"enabled": true
}
},
"id": "d25f4472-c679-4e7a-9442-2bce8c12afb1",
"query": {
"group_by": [
{
"arg": {
"index": "sleep"
},
"date_trunc": {
"unit": "month",
"value": 1
}
}
],
"select": [
{
"group_key": "*"
},
{
"arg": {
"value_macro": "sleep_score",
"version": "automatic"
},
"func": "mean"
}
]
},
"query_config": {
"provider_priority_overrides": [
"oura"
]
},
"resource_dependencies": [
"sleep"
],
"result_table_schema": {
"group_key.0": "string",
"sleep_score": "int64"
},
"scheduling_preferences": {
"minimum_gap_duration_second": 3600
},
"slug": "weekly_mean_sleep_score",
"title": "Weekly Mean Sleep Score"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Junction Management API
Create A Continuous Query
Post org team continuous query via the Junction API. Requires authentication with your team API key.
POST
/
v1
/
org
/
{org_id}
/
team
/
{team_id}
/
{environment}
/
continuous_query
Create Continuous Query
curl --request POST \
--url https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query \
--header 'Content-Type: application/json' \
--header 'X-Management-Key: <api-key>' \
--data '
{
"export_preferences": {
"data_events": {
"enabled": true
}
},
"query": {
"group_by": [
{
"arg": {
"index": "sleep"
},
"date_trunc": {
"unit": "month",
"value": 1
}
}
],
"select": [
{
"group_key": "*"
},
{
"arg": {
"value_macro": "sleep_score",
"version": "automatic"
},
"func": "mean"
}
]
},
"query_config": {
"provider_priority_overrides": [
"oura"
]
},
"scheduling_preferences": {
"minimum_gap_duration_second": 3600
},
"slug": "weekly_mean_sleep_score",
"title": "Weekly Mean Sleep Score"
}
'import requests
url = "https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query"
payload = {
"export_preferences": { "data_events": { "enabled": True } },
"query": {
"group_by": [
{
"arg": { "index": "sleep" },
"date_trunc": {
"unit": "month",
"value": 1
}
}
],
"select": [
{ "group_key": "*" },
{
"arg": {
"value_macro": "sleep_score",
"version": "automatic"
},
"func": "mean"
}
]
},
"query_config": { "provider_priority_overrides": ["oura"] },
"scheduling_preferences": { "minimum_gap_duration_second": 3600 },
"slug": "weekly_mean_sleep_score",
"title": "Weekly Mean Sleep Score"
}
headers = {
"X-Management-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Management-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
export_preferences: {data_events: {enabled: true}},
query: {
group_by: [{arg: {index: 'sleep'}, date_trunc: {unit: 'month', value: 1}}],
select: [
{group_key: '*'},
{arg: {value_macro: 'sleep_score', version: 'automatic'}, func: 'mean'}
]
},
query_config: {provider_priority_overrides: ['oura']},
scheduling_preferences: {minimum_gap_duration_second: 3600},
slug: 'weekly_mean_sleep_score',
title: 'Weekly Mean Sleep Score'
})
};
fetch('https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'export_preferences' => [
'data_events' => [
'enabled' => true
]
],
'query' => [
'group_by' => [
[
'arg' => [
'index' => 'sleep'
],
'date_trunc' => [
'unit' => 'month',
'value' => 1
]
]
],
'select' => [
[
'group_key' => '*'
],
[
'arg' => [
'value_macro' => 'sleep_score',
'version' => 'automatic'
],
'func' => 'mean'
]
]
],
'query_config' => [
'provider_priority_overrides' => [
'oura'
]
],
'scheduling_preferences' => [
'minimum_gap_duration_second' => 3600
],
'slug' => 'weekly_mean_sleep_score',
'title' => 'Weekly Mean Sleep Score'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Management-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query"
payload := strings.NewReader("{\n \"export_preferences\": {\n \"data_events\": {\n \"enabled\": true\n }\n },\n \"query\": {\n \"group_by\": [\n {\n \"arg\": {\n \"index\": \"sleep\"\n },\n \"date_trunc\": {\n \"unit\": \"month\",\n \"value\": 1\n }\n }\n ],\n \"select\": [\n {\n \"group_key\": \"*\"\n },\n {\n \"arg\": {\n \"value_macro\": \"sleep_score\",\n \"version\": \"automatic\"\n },\n \"func\": \"mean\"\n }\n ]\n },\n \"query_config\": {\n \"provider_priority_overrides\": [\n \"oura\"\n ]\n },\n \"scheduling_preferences\": {\n \"minimum_gap_duration_second\": 3600\n },\n \"slug\": \"weekly_mean_sleep_score\",\n \"title\": \"Weekly Mean Sleep Score\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Management-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query")
.header("X-Management-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"export_preferences\": {\n \"data_events\": {\n \"enabled\": true\n }\n },\n \"query\": {\n \"group_by\": [\n {\n \"arg\": {\n \"index\": \"sleep\"\n },\n \"date_trunc\": {\n \"unit\": \"month\",\n \"value\": 1\n }\n }\n ],\n \"select\": [\n {\n \"group_key\": \"*\"\n },\n {\n \"arg\": {\n \"value_macro\": \"sleep_score\",\n \"version\": \"automatic\"\n },\n \"func\": \"mean\"\n }\n ]\n },\n \"query_config\": {\n \"provider_priority_overrides\": [\n \"oura\"\n ]\n },\n \"scheduling_preferences\": {\n \"minimum_gap_duration_second\": 3600\n },\n \"slug\": \"weekly_mean_sleep_score\",\n \"title\": \"Weekly Mean Sleep Score\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.management.junction.com/v1/org/{org_id}/team/{team_id}/{environment}/continuous_query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Management-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"export_preferences\": {\n \"data_events\": {\n \"enabled\": true\n }\n },\n \"query\": {\n \"group_by\": [\n {\n \"arg\": {\n \"index\": \"sleep\"\n },\n \"date_trunc\": {\n \"unit\": \"month\",\n \"value\": 1\n }\n }\n ],\n \"select\": [\n {\n \"group_key\": \"*\"\n },\n {\n \"arg\": {\n \"value_macro\": \"sleep_score\",\n \"version\": \"automatic\"\n },\n \"func\": \"mean\"\n }\n ]\n },\n \"query_config\": {\n \"provider_priority_overrides\": [\n \"oura\"\n ]\n },\n \"scheduling_preferences\": {\n \"minimum_gap_duration_second\": 3600\n },\n \"slug\": \"weekly_mean_sleep_score\",\n \"title\": \"Weekly Mean Sleep Score\"\n}"
response = http.request(request)
puts response.read_body{
"export_preferences": {
"data_events": {
"enabled": true
}
},
"id": "d25f4472-c679-4e7a-9442-2bce8c12afb1",
"query": {
"group_by": [
{
"arg": {
"index": "sleep"
},
"date_trunc": {
"unit": "month",
"value": 1
}
}
],
"select": [
{
"group_key": "*"
},
{
"arg": {
"value_macro": "sleep_score",
"version": "automatic"
},
"func": "mean"
}
]
},
"query_config": {
"provider_priority_overrides": [
"oura"
]
},
"resource_dependencies": [
"sleep"
],
"result_table_schema": {
"group_key.0": "string",
"sleep_score": "int64"
},
"scheduling_preferences": {
"minimum_gap_duration_second": 3600
},
"slug": "weekly_mean_sleep_score",
"title": "Weekly Mean Sleep Score"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Junction Sense is available as an add-on to customers on our Enterprise plan. Get in touch with your Customer Success Manager to learn more.
Junction Management API is available for the Scale plan.
The base URL of this endpoint is
https://api.management.junction.com/.The endpoint accepts only Management Key (X-Management-Key).
Team API Key is not accepted.Path Parameters
Body
application/json
Response
Successful Response
Available options:
profile, activity, sleep, body, workouts, workout_stream, connection, order, result, match_review, appointment, result_table, glucose, heartrate, hrv, hrv, ige, igg, blood_oxygen, blood_pressure, cholesterol, device, device_legacy, weight, fat, body_temperature, body_temperature_delta, meal, water, caffeine, mindfulness_minutes, steps, calories_active, distance, floors_climbed, respiratory_rate, vo2_max, calories_basal, stress_level, menstrual_cycle, sleep_cycle, electrocardiogram, electrocardiogram_voltage, afib_burden, heart_rate_alert, stand_hour, stand_duration, sleep_apnea_alert, sleep_breathing_disturbance, wheelchair_push, forced_expiratory_volume_1, forced_vital_capacity, peak_expiratory_flow_rate, inhaler_usage, fall, uv_exposure, daylight_exposure, handwashing, basal_body_temperature, heart_rate_recovery_one_minute, body_mass_index, lean_body_mass, waist_circumference, workout_distance, workout_swimming_stroke, workout_duration, insulin_injection, carbohydrates, note, sleep_stream Was this page helpful?