{"openapi":"3.1.0","info":{"title":"dFDA Tracking API","version":"2026-08-14","description":"Personal health tracking over the shared dFDA database: measurements (doses, foods, symptoms, moods, sleep, labs, vitals), tracking reminders, reminder notifications, and per-user variable settings. Every endpoint operates on the authenticated user's own data."},"servers":[{"url":"https://dfda.earth"}],"tags":[{"name":"Measurements"},{"name":"Tracking Reminders"},{"name":"Notifications"},{"name":"Variables"}],"paths":{"/api/v1/measurements":{"get":{"tags":["Measurements"],"summary":"List the user's measurements, newest first","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"name":"globalVariableId","in":"query","schema":{"type":"string"}},{"name":"variableName","in":"query","schema":{"type":"string"},"description":"Variable name, matched case-insensitively. An unknown variable is an error, not an empty result."},{"name":"startTimeAfter","in":"query","schema":{"type":"string"},"description":"ISO date/time. Only measurements at or after this time."},{"name":"startTimeBefore","in":"query","schema":{"type":"string"},"description":"ISO date/time. Only measurements at or before this time."},{"name":"limit","in":"query","description":"Page size. Default 100, maximum 500.","schema":{"type":"integer","minimum":1,"maximum":500}},{"name":"cursor","in":"query","description":"nextCursor from the previous page. Repeat the same filters until nextCursor is null.","schema":{"type":"string"}}],"responses":{"200":{"description":"measurements, nextCursor, and the filtered variable (when one was named)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Measurements"],"summary":"Record a measurement","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"globalVariableId":{"type":"string"},"variableName":{"type":"string"},"categoryName":{"type":"string","description":"Required when variableName does not already exist. Examples: Treatment, Food, Drink, Nutrient, Symptom, Emotion, Sleep, Activity, Vital Sign, or Biomarker."},"value":{"type":"number"},"unitId":{"type":"string"},"unitAbbreviation":{"type":"string","description":"Short unit such as mg, IU, servings, count, or 1-5. serving and {serving} are accepted aliases for servings."},"unitName":{"type":"string","description":"Full unit name; matched case-insensitively."},"startTime":{"type":"string","description":"ISO date/time."},"duration":{"type":"number","description":"Duration in seconds."},"note":{"type":"string"},"sourceName":{"type":"string"},"combinationOperation":{"type":"string","enum":["SUM","MEAN"]},"fillingType":{"type":"string","enum":["ZERO","NONE","INTERPOLATION","VALUE"]},"latitude":{"type":"number"},"longitude":{"type":"number"}},"required":["value"]}}}},"responses":{"201":{"description":"result: the recorded measurement with its variable and unit","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/measurements/{id}":{"patch":{"tags":["Measurements"],"summary":"Correct one of the user's measurements","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/measurementId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["value"],"properties":{"value":{"type":"number"},"originalValue":{"type":"number","description":"Corrected value in the existing original unit. Required when originalUnitId differs from unitId; otherwise defaults to value."},"duration":{"type":["number","null"],"description":"Duration in seconds. Null clears it."},"note":{"type":["string","null"]},"sourceName":{"type":["string","null"]},"latitude":{"type":["number","null"]},"longitude":{"type":["number","null"]}}}}}},"responses":{"200":{"description":"measurement: the corrected measurement","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Measurements"],"summary":"Soft-delete one of the user's measurements","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/measurementId"}],"responses":{"200":{"description":"measurement: the soft-deleted measurement","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/tracking-reminders":{"get":{"tags":["Tracking Reminders"],"summary":"List the user's tracking reminders, active by default","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"name":"includeInactive","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"reminders: the user's tracking reminders","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Tracking Reminders"],"summary":"Create or edit a tracking reminder","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","anyOf":[{"required":["trackingReminderId"]},{"required":["reminderStartTime"]}],"properties":{"trackingReminderId":{"type":"string","description":"Existing reminder ID to edit in place. Patchable: active, defaultValue, instructions, reminderStartTime, reminderEndTime, reminderFrequency, startTrackingDate, stopTrackingDate, unit fields, and fillingType. Fixed at creation: the tracked variable (variableName, globalVariableId, categoryName, combinationOperation) — to change it, create a new reminder and set active: false on this one."},"globalVariableId":{"type":"string"},"variableName":{"type":"string"},"categoryName":{"type":"string","description":"Required when variableName does not already exist. Examples: Treatment, Food, Drink, Nutrient, Symptom, Emotion, Sleep, Activity, Vital Sign, or Biomarker."},"defaultValue":{"type":["number","null"],"description":"Pre-filled value, such as a normal medication dose or symptom rating. Pass null to clear it when editing."},"unitId":{"type":"string"},"unitAbbreviation":{"type":"string","description":"Short unit such as mg, IU, servings, count, or 1-5. serving and {serving} are accepted aliases for servings. Sets your personal recording unit for this variable, on create or on edit."},"unitName":{"type":"string","description":"Full unit name; matched case-insensitively."},"reminderStartTime":{"type":"string","description":"Local wall-clock time in HH:mm, for example 08:00."},"reminderEndTime":{"type":["string","null"],"description":"Optional local end/quiet time in HH:mm. Pass null to clear it when editing."},"reminderFrequency":{"type":"number","description":"Seconds between reminders. Default 86400."},"active":{"type":"boolean"},"instructions":{"type":["string","null"]},"startTrackingDate":{"type":["string","null"],"description":"ISO date/time, or null to clear it when editing."},"stopTrackingDate":{"type":["string","null"],"description":"ISO date/time, or null to clear it when editing."},"combinationOperation":{"type":"string","enum":["SUM","MEAN"]},"fillingType":{"type":"string","enum":["ZERO","NONE","INTERPOLATION","VALUE"]}}}}}},"responses":{"200":{"description":"result: the created or updated reminder","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/tracking-reminders/{id}":{"delete":{"tags":["Tracking Reminders"],"summary":"Archive a tracking reminder","description":"Sets active to false. The reminder is archived, not hard-deleted, matching the MCP surface; past notifications and measurements stay intact.","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/trackingReminderId"}],"responses":{"200":{"description":"result: the archived reminder","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/notifications":{"get":{"tags":["Notifications"],"summary":"List the user's reminder notification queue for a day or date range","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"name":"dateKey","in":"query","schema":{"type":"string"},"description":"One local date in YYYY-MM-DD. Defaults to today. Do not combine with startDateKey or endDateKey."},{"name":"startDateKey","in":"query","schema":{"type":"string"},"description":"First local date in an inclusive range."},{"name":"endDateKey","in":"query","schema":{"type":"string"},"description":"Last local date in an inclusive range. Ranges may include at most 31 days."},{"name":"status","in":"query","schema":{"type":"string"},"description":"Return only this effective status: PENDING, SENT, TRACKED, SKIPPED, SNOOZED, or OVERDUE."},{"name":"trackingReminderId","in":"query","schema":{"type":"string"},"description":"Return occurrences for only this reminder."},{"name":"compact","in":"query","schema":{"type":"boolean"},"description":"Return trackingReminderId as id, plus name, due, and status."},{"name":"includeCompleted","in":"query","schema":{"type":"boolean"},"description":"Include answered TRACKED or legacy SKIPPED occurrences."}],"responses":{"200":{"description":"notifications for the requested day or range, with the user's time zone","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/notifications/respond":{"post":{"tags":["Notifications"],"summary":"Answer reminder notifications","description":"With a top-level trackingReminderId the body answers one reminder; without it the body is a batch of defaultStatus and/or except entries.","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"trackingReminderId":{"type":"string"},"status":{"type":"string","enum":["TRACKED","SNOOZED"],"description":"TRACKED records a measurement; pass value 0 for a not-taken day. SNOOZED defers the notification. SKIPPED is accepted but retired and records a zero."},"snoozeMinutes":{"type":"number","description":"Set the snooze duration. The default is 30 minutes. The server caps the deferred time at the local day's end."},"value":{"type":"number","description":"Override dose/rating/value. If omitted for TRACKED, the reminder defaultValue is used."},"unitId":{"type":"string"},"unitAbbreviation":{"type":"string"},"unitName":{"type":"string"},"trackedAt":{"type":"string","description":"ISO date/time the measurement actually happened. Also anchors the target day when dateKey is omitted."},"dateKey":{"type":"string","description":"Local date in YYYY-MM-DD of the occurrence to answer. Defaults from trackedAt when given, else to the most recent unanswered due occurrence."},"note":{"type":"string"},"sourceName":{"type":"string"}},"required":["trackingReminderId","status"]},{"type":"object","properties":{"dateKey":{"type":"string","description":"Local date in YYYY-MM-DD. Defaults to today."},"defaultStatus":{"type":"string","enum":["TRACKED","SNOOZED"],"description":"Optional. Apply this status to every due and unanswered notification without an exception. Omit it to answer only the except entries. Already-answered notifications are never touched by the default."},"except":{"type":"array","description":"Answer or correct individual notifications by trackingReminderId. Each entry needs a status when defaultStatus is omitted.","items":{"type":"object","properties":{"trackingReminderId":{"type":"string"},"status":{"type":"string","enum":["TRACKED","SNOOZED"]},"value":{"type":"number"},"snoozeMinutes":{"type":"number"},"note":{"type":"string"}},"required":["trackingReminderId"]}},"note":{"type":"string"},"snoozeMinutes":{"type":"number","description":"Set the snooze duration. The default is 30 minutes. The server caps the deferred time at the local day's end."}}}]}}}},"responses":{"200":{"description":"result for a single response; answered/failed/skipped counts for a batch","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/variables":{"get":{"tags":["Variables"],"summary":"List the user's tracked variables","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"name":"query","in":"query","schema":{"type":"string"},"description":"Case-insensitive substring filter on the variable name."},{"name":"limit","in":"query","description":"Page size. Default 100, maximum 500.","schema":{"type":"integer","minimum":1,"maximum":500}},{"name":"cursor","in":"query","description":"nextCursor from the previous page. Repeat the same filters until nextCursor is null.","schema":{"type":"string"}}],"responses":{"200":{"description":"variables and nextCursor","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/variables/{globalVariableId}":{"patch":{"tags":["Variables"],"summary":"Update per-user settings for one tracked variable","security":[{"OptimitronOAuth":["tasks:personal"]},{"BearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/globalVariableId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Per-user overrides for one tracked variable. The canonical variable definition is never modified.","properties":{"fillingType":{"type":"string","enum":["ZERO","NONE","INTERPOLATION","VALUE"]},"fillingValue":{"type":["number","null"]},"minimumAllowedValue":{"type":["number","null"]},"maximumAllowedValue":{"type":["number","null"]},"onsetDelay":{"type":["integer","null"],"description":"Personal onset-delay override in seconds."},"durationOfAction":{"type":["integer","null"],"description":"Personal duration-of-action override in seconds."},"unitId":{"type":"string"},"unitAbbreviation":{"type":"string","description":"Short unit such as mg, IU, servings, count, or 1-5."},"unitName":{"type":"string","description":"Full unit name; matched case-insensitively."}}}}}},"responses":{"200":{"description":"variable: the updated per-user settings","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid argument","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials. WWW-Authenticate points at the protected-resource metadata for OAuth discovery.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"OptimitronOAuth":{"type":"oauth2","description":"OAuth 2.1 authorization code + PKCE on the canonical authorization server.","flows":{"authorizationCode":{"authorizationUrl":"https://optimitron.com/api/mcp/oauth/authorize","tokenUrl":"https://optimitron.com/api/mcp/oauth/token","refreshUrl":"https://optimitron.com/api/mcp/oauth/token","scopes":{"tasks:personal":"Read and write the signed-in user's own tracking data"}}}},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Access token minted by the optimitron.com OAuth server, sent as Authorization: Bearer <token>."}},"parameters":{"measurementId":{"name":"id","in":"path","required":true,"description":"Measurement ID from GET /api/v1/measurements.","schema":{"type":"string"}},"trackingReminderId":{"name":"id","in":"path","required":true,"description":"Tracking reminder ID from GET /api/v1/tracking-reminders.","schema":{"type":"string"}},"globalVariableId":{"name":"globalVariableId","in":"path","required":true,"description":"Variable ID from GET /api/v1/variables.","schema":{"type":"string"}}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}}}}}}}}