ODIN Data API.
Export study data and definitions, submit forecasts, and send participant notifications from a research script.
On this page
Set up access for a test study
- Open the test study in the Researcher website. In About → API Key, copy the value shown under Your base URL is, including the port if shown. Append
/DataAnalysisService/restto that value. - Use your study’s API key. If an authorized team member needs to create one, choose Generate New in the same panel. The key is shown once. Store it securely and coordinate any replacement with your team because generating a key invalidates the previous one.
- Use the exact study name assigned for API requests. The six study operations take it as the
studyIdquery parameter. Ask your study administrator if you only know the display name. The numericstudyIdreturned by study discovery serves a different purpose.
The examples use Bash and curl with --url-query support. Replace the host and study-name placeholders before running them. Start with the exports, then use forecast and message examples only with test records and a test phone.
API_BASE='https://YOUR-ODIN-HOST/DataAnalysisService/rest'
STUDY_NAME='REPLACE_WITH_API_STUDY_NAME'
read -r -s -p 'Study API key: ' ODIN_API_KEY
printf '\n'Send the key in the Authorization: Bearer … request header. Keep keys, session responses, and study files in approved storage and out of shared logs, notebooks and repositories.
Download collected study data
POST /exportData/exportStudy returns a study-level ZIP. It takes the studyId query parameter and an empty request body.
curl --silent --show-error --fail --request POST \
--header "Authorization: Bearer $ODIN_API_KEY" \
--url-query "studyId=$STUDY_NAME" \
--output study-data.zip \
"$API_BASE/exportData/exportStudy"The API ZIP is unencrypted. Save it directly to approved study storage. The protected ZIP described in the website export reference is a separate download.
After a successful request, verify that the ZIP opens and that it contains the intended study’s records. Record the study version and retrieval time with the file. If the API returns HTTP 429, wait for the study’s export cooldown before trying again.
See the full-data ZIP schema for the archive’s file types, columns and join keys.
Save the study definition
GET /exportData/exportStudyModel returns a JSON snapshot of the study definition, including its questions, settings, and configured sensors. Save it alongside your export to track which protocol was in use. Use the data ZIP for participant observations.
curl --silent --show-error --fail \
--header "Authorization: Bearer $ODIN_API_KEY" \
--url-query "studyId=$STUDY_NAME" \
--output study-definition.json \
"$API_BASE/exportData/exportStudyModel"Check that the response contains the expected study definition before archiving it. Handle it as a study file because it can include study contact and researcher information.
Find the forecast rule to use
GET /forecast/getForecastTargets returns enabled forecast-rule targets. Each target includes ruleId, questionId, createdDate, and the rule’s configuration when present. Use the ruleId for the intended test rule in the next two examples.
curl --silent --show-error --fail \
--header "Authorization: Bearer $ODIN_API_KEY" \
--url-query "studyId=$STUDY_NAME" \
"$API_BASE/forecast/getForecastTargets"If the expected target is missing, check the study and that the rule is enabled. Confirm output labels, units and comparison behavior with your forecasting collaborator. See forecast-dependent message delivery for rule setup.
Submit forecast values
POST /forecast/postForecastResults accepts a JSON object with the rule ID, forecast status, and forecastData. The example uses a fictional rule and coupon. Replace them with values from your test study. In each analyzedResults entry, supply the duration string expected by your configured integration and the numeric value for that output.
curl --silent --show-error --fail \
--header "Authorization: Bearer $ODIN_API_KEY" \
--header 'Content-Type: application/json' \
--url-query "studyId=$STUDY_NAME" \
--data-binary @- "$API_BASE/forecast/postForecastResults" <<'JSON'
{
"ruleId": 123,
"statusCode": 200,
"statusMessage": "OK",
"forecastData": [
{
"results": [
{
"couponNumber": "REPLACE_WITH_TEST_COUPON",
"analyzedResults": [
{"duration": "REPLACE_WITH_CONFIGURED_OUTPUT", "value": 0.42}
],
"extras": {}
}
]
}
]
}
JSONInspect the JSON response’s code and message even when HTTP reports success. A response code of 200 indicates the submission was stored. Then check that the test rule uses the forecast as expected.
Attach a forecast report
POST /forecast/postForecastReports takes a JSON array. Each entry identifies a rule, supplies a Base64-encoded UTF-8 HTML report, and can include string key/value details in kvMap. The example encodes the HTML <p>Test forecast report.</p>.
curl --silent --show-error --fail \
--header "Authorization: Bearer $ODIN_API_KEY" \
--header 'Content-Type: application/json' \
--url-query "studyId=$STUDY_NAME" \
--data-binary @- "$API_BASE/forecast/postForecastReports" <<'JSON'
[
{
"ruleId": 123,
"htmlReport": "PHA+VGVzdCBmb3JlY2FzdCByZXBvcnQuPC9wPg==",
"kvMap": {"label": "Synthetic test report"}
}
]
JSONCheck the JSON code and message. Use a synthetic report for this test and leave participant identifiers and observations out of the HTML and metadata.
Send a test notification
POST /messages/sendNotifications accepts a couponToMessage array with a coupon number and message for each recipient. Use the registration coupon from your own test study and verify that it belongs to the test phone before sending.
curl --silent --show-error --fail \
--header "Authorization: Bearer $ODIN_API_KEY" \
--header 'Content-Type: application/json' \
--url-query "studyId=$STUDY_NAME" \
--data-binary @- "$API_BASE/messages/sendNotifications" <<'JSON'
{
"couponToMessage": [
{
"couponNumber": "REPLACE_WITH_TEST_COUPON",
"message": "This is a test notification."
}
]
}
JSONCheck each recipient’s returned status and confirm what appears on the test phone. A successful send status reports the send attempt. Confirm receipt or viewing separately. On HTTP 429, wait for the study’s messaging cooldown and check the prior attempt before sending again.
Sign in, discover studies, or refresh a session
Use a researcher session key for the two session-based requests below. Continue to use the study API key for the six study operations above.
Start a researcher session
POST /auth/login takes JSON with username and password. The example uses Python 3 to prompt for the password. A successful login includes a sessionKey cookie in the response headers. Check the JSON result as well, because a login failure can return HTTP 200 with an error in the body. The response contains a credential, so keep it private.
python3 -c 'import getpass, json, sys; print(json.dumps({"username": sys.argv[1], "password": getpass.getpass()}))' \
'REPLACE_WITH_RESEARCHER_USERNAME' |
curl --silent --show-error --include \
--header 'Content-Type: application/json' \
--data-binary @- "$API_BASE/auth/login"List your studies
GET /studies/getParticipatingStudies uses your session key as a Bearer credential. It returns study aliases, numeric study IDs, study duration and state, and active coupon counts.
read -r -s -p 'Researcher session key: ' ODIN_SESSION_KEY
printf '\n'
curl --silent --show-error --fail \
--header "Authorization: Bearer $ODIN_SESSION_KEY" \
"$API_BASE/studies/getParticipatingStudies"Refresh an active session
GET /auth/refreshSession refreshes an active session and returns HTTP 200 with an empty body. Sign in again if the key has expired.
curl --silent --show-error --fail --write-out '%{http_code}\n' \
--header "Authorization: Bearer $ODIN_SESSION_KEY" \
"$API_BASE/auth/refreshSession"Check a failed request
- HTTP 401. Check the Bearer header, the intended study name and the credential for that route. If the study’s key was replaced, use the current one. For session calls, sign in again if needed.
- HTTP 429 on an export or message send. Wait for the study’s cooldown. Confirm the previous outcome before retrying a message.
- Unexpected success response. Open the ZIP or check the JSON fields for the intended study and operation. Forecast submissions and logins can report errors in the response body.
If the request still fails, report a problem with the operation, response status and time. Keep credentials and study records out of the report.