@datafire/twinehealth v6.0.0
@datafire/twinehealth
Client library for Fitbit Plus API
Installation and Usage
npm install --save @datafire/twinehealth
let twinehealth = require('@datafire/twinehealth').create({
access_token: "",
refresh_token: "",
client_id: "",
client_secret: "",
redirect_uri: ""
});
.then(data => {
console.log(data);
});
Description
Overview
The Fitbit Plus API is a RESTful API. The requests and responses are formated according to the JSON API specification.
In addition to this documentation, we also provide an OpenAPI "yaml" file describing the API: Fitbit Plus API Specification.
Authentication
Authentication for the Fitbit Plus API is based on the OAuth 2.0 Authorization Framework. Fitbit Plus currently supports grant types of client_credentials and refresh_token.
See POST /oauth/token for details on the request and response formats.
Building Integrations
We will provide customers with unique client credentials for each application/integration they build, allowing us to enforce appropriate access controls and monitor API usage. The client credentials will be scoped to the organization, and allow full access to all patients and related data within that organization.
These credentials are appropriate for creating an integration that does one of the following:
- background reporting/analysis
- synchronizing data with another system (such as an EMR)
The API credentials and oauth flows we currently support are not well suited for creating a user-facing application that allows a user (patient, coach, or admin) to login and have access to data which is appropriate to that specific user. It is possible to build such an application, but it is not possible to use Fitbit Plus as a federated identity provider. You would need to have a separate means of verifying a user's identity. We do not currently support the required password-based oauth flow to make this possible.
Paging
The Fitbit Plus API supports two different pagination strategies for GET collection endpoints.
Skip-based paging
Skip-based paging uses the query parameters page[size]
and page[number]
to specify the max number of resources returned and the page number. We default to skip-based paging if there are no page parameters. The response will include a links
object containing links to the first, last, prev, and next pages of data.
If the contents of the collection change while you are iterating through the collection, you will see duplicate or missing documents. For example, if you are iterating through the calender_event
resource via GET /pub/calendar_event?sort=start_at&page[size]=50&page[number]=1
, and a new calendar_event
is created that has a start_at
value before the first calendar_event
, when you fetch the next page at GET /pub/calendar_event?sort=start_at&page[size]=50&page[number]=2
, the first entry in the second response will be a duplicate of the last entry in the first response.
Cursor-based paging
Cursor-based paging uses the query parameters page[limit]
and page[after]
to specify the max number of entries returned and identify where to begin the next page. Add page[limit]
to the parameters to use cursor-based paging. The response will include a links
object containing a link to the next page of data, if the next page exists.
Cursor-based paging is not subject to duplication if new resources are added to the collection. For example, if you are iterating through the calender_event
resource via GET /pub/calendar_event?sort=start_at&page[limit]=50
, and a new calendar_event
is created that has a start_at
value before the first calendar_event
, you will not see a duplicate entry when you fetch the next page at GET /pub/calendar_event?sort=start_at&page[limit]=50&page[after]=<cursor>
.
We encourage the use of cursor-based paging for performance reasons.
In either form of paging, you can determine whether any resources were missed by comparing the number of fetched resources against meta.count
. Set page[size]
or page[limit]
to 0 to get only the count.
It is not valid to mix the two strategies.
Actions
oauthCallback
Exchange the code passed to your redirect URI for an access_token
twinehealth.oauthCallback({
"code": ""
}, context)
Input
- input
object
- code required
string
- code required
Output
- output
object
- access_token
string
- refresh_token
string
- token_type
string
- scope
string
- expiration
string
- access_token
oauthRefresh
Exchange a refresh_token for an access_token
twinehealth.oauthRefresh(null, context)
Input
This action has no parameters
Output
- output
object
- access_token
string
- refresh_token
string
- token_type
string
- scope
string
- expiration
string
- access_token
createAction
Create a plan action
twinehealth.createAction({
"body": {
"data": {
"type": "",
"id": ""
}
}
}, context)
Input
- input
object
- body required CreateActionRequest
Output
- output CreateActionResponse
fetchAction
Get a health action from a patient's plan.
twinehealth.fetchAction({
"id": ""
}, context)
Input
- input
object
- id required
string
: Action identifier
- id required
Output
- output FetchActionResponse
updateAction
Update a health action from a patient's plan.
twinehealth.updateAction({
"id": "",
"body": {
"data": {
"type": "",
"id": ""
}
}
}, context)
Input
- input
object
- id required
string
: Action identifier - body required UpdateActionRequest
- id required
Output
- output UpdateActionResponse
createBundle
Create a bundle in a patient's plan
twinehealth.createBundle({
"body": {
"data": {
"type": "",
"id": ""
}
}
}, context)
Input
- input
object
- body required CreateBundleRequest
Output
- output CreateBundleResponse
fetchBundle
Get a bundle from a patient's plan.
twinehealth.fetchBundle({
"id": ""
}, context)
Input
- input
object
- id required
string
: Bundle identifier
- id required
Output
- output FetchBundleResponse
updateBundle
Updte a bundle from a patient's plan.
twinehealth.updateBundle({
"id": "",
"body": {
"data": {
"type": "",
"id": ""
}
}
}, context)
Input
- input
object
- id required
string
: Bundle identifier - body required UpdateBundleRequest
- id required
Output
- output UpdateBundleResponse
fetchCalendarEvents
Get a list of calendar events
twinehealth.fetchCalendarEvents({}, context)
Input
- input
object
- filterpatient
string
: Patient id to fetch calendar event. Note that one of the following filters must be specified:filter[patient]
,filter[group]
,filter[organization]
, orfilter[attendees]
. - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[group]
,filter[organization]
, orfilter[attendees]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[group]
,filter[organization]
, orfilter[attendees]
. - filterattendees
string
: Comma-separated list of coach or patient ids. Note that one of the following filters must be specified:filter[patient]
,filter[group]
,filter[organization]
, orfilter[attendees]
. - filtertype
string
(values: plan-check-in, reminder, telephone-call, office-visit, video-call): Calendar event type - filtercompleted
boolean
: If not specified, return all calendar events. If set totrue
return only events marked as completed, if set tofalse
, return only events not marked as completed yet. - filterstart_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for events starting in November 2017 (America/New_York):filter[start_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- filterend_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for events ending in November 2017 (America/New_York):filter[end_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- filtercompleted_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for events completed in November 2017 (America/New_York):filter[completed_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- filtercreated_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for events created in November 2017 (America/New_York):filter[created_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- filterupdated_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for events updated in November 2017 (America/New_York):filter[updated_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- pagenumber
integer
: Page number - pagesize
integer
: Page size - pagelimit
integer
: Page limit - pagecursor
string
: Page cursor - include
string
(values: owner): List of related resources to include in the response
- filterpatient
Output
- output FetchCalendarEventsResponse
createCalendarEvent
Create a calendar event for a patient. Attribute all_day
must be set to true
and end_at
cannot be set for plan-check-in
event type.
twinehealth.createCalendarEvent({
"body": {
"data": {
"type": "",
"attributes": null,
"relationships": {}
}
}
}, context)
Input
- input
object
- body required CreateCalendarEventRequest
Output
- output CreateCalendarEventResponse
deleteCalendarEvent
Delete a calendar event by id
twinehealth.deleteCalendarEvent({
"id": ""
}, context)
Input
- input
object
- id required
string
: Calendar event identifier
- id required
Output
Output schema unknown
fetchCalendarEvent
Get a calendar event by id
twinehealth.fetchCalendarEvent({
"id": ""
}, context)
Input
- input
object
- id required
string
: Calendar event identifier
- id required
Output
- output FetchCalendarEventResponse
updateCalendarEvent
Update a calendar event for a patient. Attribute all_day
must be true and end_at
cannot be specified for plan-check-in
event type. To mark a calendar event as 'completed', set completed_at
and completed_by
to desired values. To mark a completed calendar event as 'not completed', set completed_at
and completed_by
to null
. Attendees can be added or removed, but response status cannot be updated. Use the calendar event response api for response status updates instead.
twinehealth.updateCalendarEvent({
"id": "",
"body": {}
}, context)
Input
- input
object
- id required
string
: Calendar event identifier - body required UpdateCalendarEventRequest
- id required
Output
- output UpdateCalendarEventResponse
createCalendarEventResponse
Create a calendar event response for an attendee of a calendar event, the attendee can be a coach or patient. Calendar event responses cannot be fetched, updated nor deleted. Use calendar event api to fetch the response status for attendees.
twinehealth.createCalendarEventResponse({
"body": {
"data": {
"type": "",
"attributes": null,
"relationships": {}
}
}
}, context)
Input
- input
object
- body required CreateCalendarEventResponseRequest
Output
fetchCoaches
Get a list of coaches matching the specified filters.
twinehealth.fetchCoaches({}, context)
Input
- input
object
- filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[groups]
,filter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[groups]
,filter[organization]
.
- filtergroups
Output
- output FetchCoachesResponse
fetchCoach
Get a coach record by id.
twinehealth.fetchCoach({
"id": ""
}, context)
Input
- input
object
- id required
string
: Coach identifier
- id required
Output
- output FetchCoachResponse
fetchEmailHistories
Get a list of email histories
twinehealth.fetchEmailHistories({}, context)
Input
- input
object
Output
- output FetchEmailHistoriesResponse
fetchEmailHistory
Get an email history by id
twinehealth.fetchEmailHistory({
"id": ""
}, context)
Input
- input
object
- id required
string
: Email history identifier
- id required
Output
- output FetchEmailHistoryResponse
fetchGroups
Get a list of groups matching the specified filters.
twinehealth.fetchGroups({
"filter[organization]": ""
}, context)
Input
- input
object
- filterorganization required
string
: Organization identifier - filtername
string
: Group name
- filterorganization required
Output
- output FetchGroupsResponse
createGroup
Create a group record.
twinehealth.createGroup({
"body": {
"data": {
"id": "",
"type": "",
"attributes": {
"name": ""
}
}
}
}, context)
Input
- input
object
- body required CreateGroupRequest
Output
- output CreateGroupResponse
fetchGroup
Get a group record by id.
twinehealth.fetchGroup({
"id": ""
}, context)
Input
- input
object
- id required
string
: Group identifier
- id required
Output
- output FetchGroupResponse
fetchHealthProfiles
Get a list of health profiles
twinehealth.fetchHealthProfiles({}, context)
Input
- input
object
- filterpatient
string
: Patient id to fetch health profile. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - pagenumber
integer
: Page number - pagesize
integer
: Page size - pagelimit
integer
: Page limit - pagecursor
string
: Page cursor - include
string
(values: patient, questions): List of related resources to include in the response
- filterpatient
Output
- output FetchHealthProfilesResponse
fetchHealthProfile
Get a health profile by id
twinehealth.fetchHealthProfile({
"id": ""
}, context)
Input
- input
object
- id required
string
: Health profile identifier - include
string
(values: patient, questions): List of related resources to include in the response
- id required
Output
- output FetchHealthProfileResponse
fetchHealthProfileAnswers
Get a list of health profile answers
twinehealth.fetchHealthProfileAnswers({}, context)
Input
- input
object
- filterpatient
string
: Patient id to fetch healt profile answers. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - pagenumber
integer
: Page number - pagesize
integer
: Page size - pagelimit
integer
: Page limit - pagecursor
string
: Page cursor - include
string
(values: patient): List of related resources to include in the response
- filterpatient
Output
fetchHealthProfileAnswer
Get a health profile answer by id
twinehealth.fetchHealthProfileAnswer({
"id": ""
}, context)
Input
- input
object
- id required
string
: Health profile answer identifier - include
string
(values: patient): List of related resources to include in the response
- id required
Output
fetchHealthProfileQuestions
Get a list of health profile questions
twinehealth.fetchHealthProfileQuestions({}, context)
Input
- input
object
- filterpatient
string
: Patient id to fetch healt profile questions. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[group]
, orfilter[organization]
. - include
string
(values: question_definition, answer): List of related resources to include in the response
- filterpatient
Output
fetchHealthProfileQuestion
Get a health profile by id
twinehealth.fetchHealthProfileQuestion({
"id": ""
}, context)
Input
- input
object
- id required
string
: Health profile question identifier - include
string
(values: question_definition, answer): List of related resources to include in the response
- id required
Output
fetchHealthQuestionDefinitions
Get a list of all health question definitions
twinehealth.fetchHealthQuestionDefinitions(null, context)
Input
This action has no parameters
Output
fetchHealthQuestionDefinition
Get a health question definition by id
twinehealth.fetchHealthQuestionDefinition({
"id": ""
}, context)
Input
- input
object
- id required
string
: Health question definition identifier
- id required
Output
createToken
Create an OAuth 2.0 Bearer token. A valid bearer token is required for all other API requests.
Be sure to set the header Content-Type: "application/vnd.api+json"
. Otherwise, you will get an error
403 Forbidden. Using Content-Type: "application/json"
is permitted (to support older oauth clients) but when
using application/json
the body should have a body in the following format instead of nesting under
data.attributes
:
{
"grant_type": "client_credentials",
"client_id": "95c78ab2-167f-40b8-8bec-8398d4b87454",
"client_secret": "35d18dc9-a3dd-4948-b787-063a490b9354"
}
twinehealth.createToken({
"body": {
"data": {
"attributes": {
"client_id": "",
"grant_type": ""
}
}
}
}, context)
Input
- input
object
- include
string
(values: groups, organization): List of related resources to include in the response - body required CreateTokenRequest
- include
Output
- output CreateTokenResponse
fetchTokenGroups
Get the list of groups a token can be used to access.
twinehealth.fetchTokenGroups({
"id": ""
}, context)
Input
- input
object
- id required
string
: Token identifier
- id required
Output
- output FetchGroupsResponse
fetchTokenOrganization
Get the organization a token can be used to access.
twinehealth.fetchTokenOrganization({
"id": ""
}, context)
Input
- input
object
- id required
string
: Token identifier
- id required
Output
- output FetchOrganizationResponse
fetchOrganization
Get an organization record by id.
twinehealth.fetchOrganization({
"id": ""
}, context)
Input
- input
object
- id required
string
: Organization identifier
- id required
Output
- output FetchOrganizationResponse
fetchPatients
Get a list of patients.
twinehealth.fetchPatients({}, context)
Input
- input
object
- filtergroups
string
: Comma-separated list of group ids. Note that eitherfilter[group]
orfilter[organization]
must be specified. - filterorganization
string
: Fitbit Plus organization id. Note that eitherfilter[group]
orfilter[organization]
must be specified. - filteridentifier
string
: Identifier system (example: "MyEHR") - requires a "filteridentifier" parameter - filteridentifier
string
: Identifier value (example: "12345") - requires a "filteridentifier" parameter - filterarchived
boolean
: If not specified, return all patients. If set to 'true' return only archived patients, if set to 'false', return only patients who are not archived. - filtercreated_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for patients created in November 2017 (America/New_York):filter[created_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- filterupdated_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for patients updated in November 2017 (America/New_York):filter[updated_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- pagenumber
integer
: Page number - pagesize
integer
: Page size - pagelimit
integer
: Page limit - pagecursor
string
: Page cursor
- filtergroups
Output
- output FetchPatientsResponse
createPatient
Create a patient record.
Example for creating a patient with a group specified using meta.query
instead of id
:
{
"data": {
"type": "patient",
"attributes": {
"first_name": "Andrew",
"last_name": "Smith"
},
"relationships": {
"groups": {
"data": [
{
"type": "group",
"meta": {
"query": {
"organization": "58c88de7c93eb96357a87033",
"name": "Patients Lead"
}
}
}
]
}
}
}
}
twinehealth.createPatient({
"body": {
"data": {
"type": "",
"attributes": {}
}
}
}, context)
Input
- input
object
- body required CreatePatientRequest
Output
- output CreatePatientResponse
upsertPatient
Create a new patient or update an existing patient
twinehealth.upsertPatient({
"body": {
"meta": {
"query": {
"identifier": {},
"groups": []
}
},
"data": {
"type": "",
"attributes": {}
}
}
}, context)
Input
- input
object
- body required UpsertPatientRequest
Output
- output CreatePatientResponse
fetchPatient
Gets a patient record by id.
twinehealth.fetchPatient({
"id": ""
}, context)
Input
- input
object
- id required
string
: Patient identifier
- id required
Output
- output FetchPatientResponse
updatePatient
Update a patient record.
twinehealth.updatePatient({
"id": "",
"body": {
"data": {
"type": "",
"attributes": {}
}
}
}, context)
Input
- input
object
- id required
string
: Patient identifier - body required UpdatePatientRequest
- id required
Output
- output UpdatePatientResponse
fetchPatientCoaches
Get the list of coaches for a patient.
twinehealth.fetchPatientCoaches({
"id": ""
}, context)
Input
- input
object
- id required
string
: Patient identifier
- id required
Output
- output FetchCoachesResponse
fetchPatientGroups
Get the list of groups for a patient.
twinehealth.fetchPatientGroups({
"id": ""
}, context)
Input
- input
object
- id required
string
: Patient identifier
- id required
Output
- output FetchGroupsResponse
fetchPatientHealthMetrics
Get a list of patient health metrics.
twinehealth.fetchPatientHealthMetrics({}, context)
Input
- input
object
- filterpatient
string
: Filter the patient health metrics for a specified patient. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - pagenumber
integer
: Page number - pagesize
integer
: Page size - pagelimit
integer
: Page limit - pagecursor
string
: Page cursor
- filterpatient
Output
createPatientHealthMetric
Create one or more patient health metrics.
Example for creating a patient health result with a patient specified using meta.query
instead of id
:
{
"data": {
"type": "patient_health_metric",
"attributes": {
"code": {
"system": "LOINC",
"value": "13457-7"
},
"type": "ldl_cholesterol",
"occurred_at": "2017-03-14T11:00:57.000Z",
"value": 121,
"unit": "mg/dl"
},
"relationships": {
"patient": {
"data": {
"type": "patient",
"meta": {
"query": {
"identifier": {
"system": "medical-record-number",
"value": "121212"
},
"organization": "58c4554710123c5c40dbab81"
}
}
}
}
}
}
}
twinehealth.createPatientHealthMetric({
"body": {
"data": {
"type": "",
"id": ""
}
}
}, context)
Input
- input
object
- body required CreatePatientHealthMetricRequest
Output
fetchPatientHealthMetric
Get the plan summary for a patient.
twinehealth.fetchPatientHealthMetric({
"id": ""
}, context)
Input
- input
object
- id required
string
: Patient health metric identifier
- id required
Output
fetchPatientPlanSummaries
Get a list of patient plan summaries
twinehealth.fetchPatientPlanSummaries({}, context)
Input
- input
object
- filterpatient
string
: Patient id to fetch plan summary for. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - include
string
(values: actions, bundles, patient, current_results): List of related resources to include in the response
- filterpatient
Output
fetchPatientPlanSummary
Get the plan summary for a patient.
twinehealth.fetchPatientPlanSummary({
"id": ""
}, context)
Input
- input
object
- id required
string
: Plan summary identifier - include
string
(values: actions, bundles, patient, current_results): List of related resources to include in the response
- id required
Output
updatePatientPlanSummary
Update a plan summary record for a patient.
twinehealth.updatePatientPlanSummary({
"id": "",
"body": {
"data": {
"id": "",
"type": ""
}
}
}, context)
Input
- input
object
- id required
string
: Plan summary identifier - body required UpdatePatientPlanSummaryRequest
- id required
Output
fetchPatientHealthResults
Get a list of patient health results.
twinehealth.fetchPatientHealthResults({
"filter[patient]": ""
}, context)
Input
- input
object
- filterpatient required
string
: Filter the patient health results for a specified patient - filteractions
string
: A comma-separated list of action identifiers - filterstart_at
string
: Filter results that occurred after the passed ISO date and time string - filterend_at
string
: Filter results that occurred before the passed ISO date and time string - filterthreads
string
: A comma-separated list of thread identifiers - filtercreated_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for results created in November 2017 (America/New_York):filter[created_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- filterupdated_at
string
: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by..
. Example for results updated in November 2017 (America/New_York):filter[updated_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
- pagenumber
integer
: Page number - pagesize
integer
: Page size - pagelimit
integer
: Page limit - pageafter
string
: Page cursor
- filterpatient required
Output
fetchPatientHealthResult
Get patient health result by id.
twinehealth.fetchPatientHealthResult({
"id": ""
}, context)
Input
- input
object
- id required
string
: Patient health result identifier
- id required
Output
fetchRewards
Get a list of rewards matching the specified filters.
twinehealth.fetchRewards({}, context)
Input
- input
object
- filterpatient
string
: Patient identifier. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filterreward_program_activation
string
: Reward program activation identifier - filterthread
string
: Thread identifier - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
.
- filterpatient
Output
- output FetchRewardsResponse
createReward
Create a reward for a patient.
twinehealth.createReward({
"body": {
"data": {
"type": ""
}
}
}, context)
Input
- input
object
- body required CreateRewardRequest
Output
- output CreateRewardResponse
fetchReward
Get a reward record by id.
twinehealth.fetchReward({
"id": ""
}, context)
Input
- input
object
- id required
string
: Reward identifier
- id required
Output
- output FetchRewardResponse
fetchRewardEarnings
Get a list of reward earnings matching the specified filters.
twinehealth.fetchRewardEarnings({
"filter[groups]": "",
"filter[patient]": ""
}, context)
Input
- input
object
- filtergroups required
string
: Group identifiers - filterpatient required
string
: Patient identifier - filterready_for_fulfillment
boolean
: If true, only returns those reward earnings for which ready_for_fulfillment is true and fulfilled_at is null. If false, only returns those reward earnings for which ready_for_fulfillment is false and fulfilled_at is null.
- filtergroups required
Output
- output FetchRewardEarningsResponse
createRewardEarning
Create a reward earning for a reward. There can only be one earning for a reward. It is possilble to create multiple reward earnings simultaneously by providing and array of reward earnings in the data property.
twinehealth.createRewardEarning({
"body": {
"data": {
"type": ""
}
}
}, context)
Input
- input
object
- body required CreateRewardEarningRequest
Output
- output CreateRewardEarningResponse
fetchRewardEarning
Get a reward earning record by id.
twinehealth.fetchRewardEarning({
"id": ""
}, context)
Input
- input
object
- id required
string
: Reward earning identifier
- id required
Output
- output FetchRewardEarningResponse
fetchRewardEarningFulfillments
Get a list of reward earning fulfillments matching the specified filters.
twinehealth.fetchRewardEarningFulfillments({
"filter[patient]": ""
}, context)
Input
- input
object
- filterpatient required
string
: Patient identifier
- filterpatient required
Output
createRewardEarningFulfillment
Create a reward earning fulfillment for a reward earning. There can only be one fulfillment for each earning.
twinehealth.createRewardEarningFulfillment({
"body": {
"data": {
"type": ""
}
}
}, context)
Input
- input
object
- body required CreateRewardEarningFulfillmentRequest
Output
fetchRewardEarningFulfillment
Get a reward earning fulfillment record by id.
twinehealth.fetchRewardEarningFulfillment({
"id": ""
}, context)
Input
- input
object
- id required
string
: Reward earning fulfillment identifier
- id required
Output
fetchRewardPrograms
Get a list of reward programs matching the specified filters.
twinehealth.fetchRewardPrograms({}, context)
Input
- input
object
- filtergroups
string
: Comma-separated list of group identifiers. Note that one of the following filters must be specified:filter[groups]
,filter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[groups]
,filter[organization]
.
- filtergroups
Output
- output FetchRewardProgramsResponse
createRewardProgram
Create a reward program for a group.
twinehealth.createRewardProgram({
"body": {
"data": {
"type": ""
}
}
}, context)
Input
- input
object
- body required CreateRewardProgramRequest
Output
- output CreateRewardProgramResponse
fetchRewardProgram
Get a reward program record by id.
twinehealth.fetchRewardProgram({
"id": ""
}, context)
Input
- input
object
- id required
string
: Reward program identifier
- id required
Output
- output FetchRewardProgramResponse
fetchRewardProgramGroup
Get the group related to a reward program.
twinehealth.fetchRewardProgramGroup({
"id": ""
}, context)
Input
- input
object
- id required
string
: Reward program identifier
- id required
Output
- output FetchGroupsResponse
fetchRewardProgramActivations
Get a list of reward program activations matching the specified filters.
twinehealth.fetchRewardProgramActivations({}, context)
Input
- input
object
- filterpatient
string
: Patient identifier. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filtergroups
string
: Comma-separated list of group ids. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
. - filterorganization
string
: Fitbit Plus organization id. Note that one of the following filters must be specified:filter[patient]
,filter[groups]
,filter[organization]
.
- filterpatient
Output
createRewardProgramActivation
Create a reward program activation for a patient. There can only be one activation for a patient for a given reward program.
twinehealth.createRewardProgramActivation({
"body": {
"data": {
"type": ""
}
}
}, context)
Input
- input
object
- body required CreateRewardProgramActivationRequest
Output
fetchRewardProgramActivation
Get a reward program activationrecord by id.
twinehealth.fetchRewardProgramActivation({
"id": ""
}, context)
Input
- input
object
- id required
string
: Reward program activation identifier
- id required
Output
Definitions
ActionMetric
- ActionMetric
object
- goal
object
- metric_type
string
- unit
string
- validations
object
- maximum
object
- unit
string
- value
number
- unit
- minimum
object
- unit
string
- value
number
- unit
- maximum
- goal
ActionResource
- ActionResource
object
- attributes
object
- _thread
string
- adherence
object
- complete
integer
- due
integer
- streak
object
- count
integer
- updated_at
string
- count
- complete
- details
object
- effective_from required
string
- effective_to
string
- frequency_goal
object
- weeks
object
- days
array
- items
integer
(values: 0, 1, 2, 3, 4, 5, 6): Days of week that the action is scheduled for. Zero-indexed, ex 0 represents Sunday, etc.
- items
- days
- weeks
- identifiers
array
- items Identifier
- intake
object
- metric_required
boolean
- metrics
array
- items ActionMetric
- static_title
string
- title required
string
- tracking
boolean
- type required
string
(values: other_lifestyle) - windows
array
- items ActionWindow
- _thread
- id required
string
- relationships
object
- plan
object
- data
object
- id
string
- type
string
- id
- links
object
- data
- plan
- type required
string
- attributes
ActionWindow
- ActionWindow
object
- _id
string
- title
string
- type required
string
- _id
Address
- Address
object
- city
string
- country
string
- district
string
- lines
array
- items
string
- items
- postal_code
string
- state
string
- text
string
- type
string
- use
string
- city
ArchiveHistory
- ArchiveHistory
object
- archived
boolean
- modified_at
string
- notes
string
- reason
string
- archived
BundleResource
- BundleResource
object
- attributes
object
- _thread
string
- effective_from required
string
- effective_to
string
- title required
string
- type required
string
- _thread
- id required
string
- relationships
object
- actions
object
- data
object
- id
string
- type
string
- id
- links
object
- data
- plan
object
- data
object
- id
string
- type
string
- id
- links
object
- data
- actions
- type required
string
- attributes
CalendarEventResource
- CalendarEventResource
object
- attributes
object
- all_day
boolean
: True if the calendar event is an all day event, false otherwise. Must be set to true forplan-check-in
event type. If it is true, thenstart_at
andend_at
must also be set to beginning of day, exceptplan-check-in
event type does not need anend_at
date. If it is false, thenstart_at
andend_at
must be on the same day. - attendees
array
: List of attendees for the calendar event- items
object
- response_status
string
(values: needsAction, declined, tentative, accepted): Status of responses from attendees - user
string
- response_status
- items
- completed_at
string
: The date and time when the calendar event is marked as completed. Only valid forplan-check-in
event type. - completed_by
object
: The coach who marked the calendar event as completed. Only valid forplan-check-in
event type. - description
string
- end_at
string
: The date and time when the calendar event ends. Not valid forplan-check-in
event type. - location
string
- start_at
string
: The date and time when the calendar event starts - time_zone
string
: The time zone in which the dates for the calendar event are specified - title
string
: The title of the calendar event. Must not be empty or null - type
string
(values: plan-check-in, reminder, telephone-call, office-visit, video-call): The type of calendar event. Immutable after event creation.
- all_day
- id
string
- links
object
- self
string
- self
- relationships
object
- owner
object
: The owner is the patient for whom the calendar event is created specificially for- data required
object
- id
string
- type
string
- id
- links
object
- related
string
- related
- data required
- owner
- type
string
(values: calendar_event)
- attributes
CalendarEventResponseResource
- CalendarEventResponseResource
object
- attributes
object
- attendee
object
: The attendee in the attendees list of the calendar event. - response_status
string
(values: accepted, declined, tentative): The response status for the attendee.
- attendee
- id
string
- links
object
- self
string
- self
- relationships
object
- calendar_event
object
: The calendar_event is the calendar event for which the calendar event response is created specificially for- data required
object
- id
string
- type
string
- id
- links
object
- related
string
- related
- data required
- user
object
: The user is the coach or patient for whom the calendar event response is created specificially for- data required
object
- id
string
- type
string
- id
- links
object
- related
string
- related
- data required
- calendar_event
- type
string
(values: calendar_event_response)
- attributes
CoachResource
- CoachResource
object
- attributes required
object
- first_name
string
- last_name
string
- first_name
- id required
string
- links
object
- self required
string
- self required
- type required
string
(values: coach)
- attributes required
CollectionResponseLinks
- CollectionResponseLinks
object
- last
string
- next
string
- prev
string
- self
string
- last
CreateActionRequest
- CreateActionRequest
object
- data required ActionResource
CreateActionResponse
- CreateActionResponse
object
- data required ActionResource
- meta CreateOrUpdateMetaResponse
CreateBundleRequest
- CreateBundleRequest
object
- data required BundleResource
CreateBundleResponse
- CreateBundleResponse
object
- data required BundleResource
- meta CreateOrUpdateMetaResponse
CreateCalendarEventRequest
- CreateCalendarEventRequest
object
- data required
object
- attributes required
- all_day
boolean
: True if the calendar event is an all day event, false otherwise. Must be set to true forplan-check-in
event type. If it is true, thenstart_at
andend_at
must also be set to beginning of day, exceptplan-check-in
event type does not need anend_at
date. If it is false, thenstart_at
andend_at
must be on the same day. - attendees
array
: List of attendees for the calendar event- items
object
- response_status
string
(values: needsAction, declined, tentative, accepted): Status of responses from attendees - user
string
- response_status
- items
- completed_at
string
: The date and time when the calendar event is marked as completed. Only valid forplan-check-in
event type. - completed_by
object
: The coach who marked the calendar event as completed. Only valid forplan-check-in
event type. - description
string
- end_at
string
: The date and time when the calendar event ends. Not valid forplan-check-in
event type. - location
string
- start_at
string
: The date and time when the calendar event starts - time_zone
string
: The time zone in which the dates for the calendar event are specified - title
string
: The title of the calendar event. Must not be empty or null - type
string
(values: plan-check-in, reminder, telephone-call, office-visit, video-call): The type of calendar event. Immutable after event creation.
- all_day
- relationships required
object
- owner
object
- owner
- type required CalendarEventResource/properties/type
- attributes required
- data required
CreateCalendarEventResponse
- CreateCalendarEventResponse
object
CreateCalendarEventResponseRequest
- CreateCalendarEventResponseRequest
object
- data required
object
- attributes required
- attendee
object
: The attendee in the attendees list of the calendar event. - response_status
string
(values: accepted, declined, tentative): The response status for the attendee.
- attendee
- relationships required
object
- calendar_event
object
- user
object
- calendar_event
- type required CalendarEventResponseResource/properties/type
- attributes required
- data required
CreateGroupRequest
- CreateGroupRequest
object
- data required GroupResource
CreateGroupResponse
- CreateGroupResponse
object
- data required GroupResource
- meta CreateOrUpdateMetaResponse
CreateOrUpdateErrorResponse
- CreateOrUpdateErrorResponse
object
- errors Error
- meta CreateOrUpdateMetaResponse
CreateOrUpdateMetaResponse
- CreateOrUpdateMetaResponse
object
- ignored
array
- items
string
- items
- req_id
string
- ignored
CreatePatientHealthMetricRequest
- CreatePatientHealthMetricRequest
object
- data required PatientHealthMetricCreateResource
- meta
object
- ignore_duplicates
boolean
: Iftrue
, the patient health metric will be ignored if there is an existing patient health metric for
- ignore_duplicates
CreatePatientHealthMetricResponse
- CreatePatientHealthMetricResponse
object
- data required PatientHealthMetricResource
- meta CreateOrUpdateMetaResponse
CreatePatientRequest
- CreatePatientRequest
object
- data required PatientCreateResource
- meta
object
- ignore_duplicates
boolean
: Iftrue
, patients with any conflicting identifiers (samesystem
andvalue
) will be ignored.
- ignore_duplicates
CreatePatientResponse
- CreatePatientResponse
object
- data required PatientResource
- meta CreateOrUpdateMetaResponse
CreateRewardEarningFulfillmentRequest
- CreateRewardEarningFulfillmentRequest
object
- data required RewardEarningFulfillmentResource
CreateRewardEarningFulfillmentResponse
- CreateRewardEarningFulfillmentResponse
object
- data required RewardEarningFulfillmentResource
- meta CreateOrUpdateMetaResponse
CreateRewardEarningRequest
- CreateRewardEarningRequest
object
- data required RewardEarningResource
CreateRewardEarningResponse
- CreateRewardEarningResponse
object
- data required RewardEarningResource
- meta CreateOrUpdateMetaResponse
CreateRewardProgramActivationRequest
- CreateRewardProgramActivationRequest
object
- data required RewardProgramActivationResource
CreateRewardProgramActivationResponse
- CreateRewardProgramActivationResponse
object
- data required RewardProgramActivationResource
- meta CreateOrUpdateMetaResponse
CreateRewardProgramRequest
- CreateRewardProgramRequest
object
- data required RewardProgramResource
CreateRewardProgramResponse
- CreateRewardProgramResponse
object
- data required RewardProgramResource
- meta CreateOrUpdateMetaResponse
CreateRewardRequest
- CreateRewardRequest
object
- data required RewardResource
CreateRewardResponse
- CreateRewardResponse
object
- data required RewardResource
- meta CreateOrUpdateMetaResponse
CreateTokenRequest
- CreateTokenRequest
object
- data required
object
- attributes required
object
- client_id required
string
: Contact Fitbit Plus API Support to get a client id and secret. - client_secret
string
: Contact Fitbit Plus API Support to get a client id and secret. Secret is required if grant_type is "client_credentials" - grant_type required
string
(values: refresh_token, client_credentials) - refresh_token
string
: Required if grant_type is "refresh_token"
- client_id required
- type
string
(values: token)
- attributes required
- data required
CreateTokenResponse
- CreateTokenResponse
object
- data required TokenResource
- included
array
- items GroupResource
- meta CreateOrUpdateMetaResponse
EmailHistoryResource
- EmailHistoryResource
object
- attributes
object
- email_address
string
: Address email was sent to. - email_type
string
: Type of email. - send_time
string
: Time email was sent. - status_times
object
: Status of email. Multiple statuses may be defined. The current status is the one with the most recent date.- bounce
string
: Time email was bounced. - click
string
: Time email was clicked. - deferred
string
: Time email was deferred. - delivered
string
: Time email was delivered. - dropped
string
: Time email was dropped. - open
string
: Time email was opened. - processed
string
: Time email was processed. - spamreport
string
: Time email was reported as spam. - unsubscribe
string
: Time email was unsubscribed from.
- bounce
- twine_email_id
string
: Unique identifier for this email.
- email_address
- id
string
- relationships
object
- receiver
object
- data
object
- id
string
- type
string
- id
- data
- sender
object
- data
object
- id
string
- type
string
- id
- data
- receiver
- type required
string
- attributes
Error
- Error
object
- code
string
(values: Forbidden, InvalidParameter, InvalidBodyParameter, ResourceNotFound, Unauthorized, InvalidCredentials, InvalidGrantType) - detail
string
- source
object
- parameter
string
- pointer
string
- parameter
- status
string
- title
string
- code
FetchActionResponse
- FetchActionResponse
object
- data required ActionResource
- meta FetchMetaResponse
FetchBundleResponse
- FetchBundleResponse
object
- data required BundleResource
- meta FetchMetaResponse
FetchCalendarEventResponse
- FetchCalendarEventResponse
object
- data CalendarEventResource
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- meta FetchMetaResponse
FetchCalendarEventsResponse
- FetchCalendarEventsResponse
object
- data
array
- items CalendarEventResource
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- links CollectionResponseLinks
- meta FetchMetaResponse
- data
FetchCoachResponse
- FetchCoachResponse
object
- data required CoachResource
- meta FetchMetaResponse
FetchCoachesResponse
- FetchCoachesResponse
object
- data required
array
- items CoachResource
- meta FetchMetaResponse
- data required
FetchEmailHistoriesResponse
- FetchEmailHistoriesResponse
object
- data required
array
- items EmailHistoryResource
- meta FetchMetaResponse
- data required
FetchEmailHistoryResponse
- FetchEmailHistoryResponse
object
- data required EmailHistoryResource
- meta FetchMetaResponse
FetchErrorResponse
- FetchErrorResponse
object
- errors Error
- meta FetchMetaResponse
FetchGroupResponse
- FetchGroupResponse
object
- data required GroupResource
- meta FetchMetaResponse
FetchGroupsResponse
- FetchGroupsResponse
object
- data required
array
- items GroupResource
- meta FetchMetaResponse
- data required
FetchHealthProfileAnswerResponse
- FetchHealthProfileAnswerResponse
object
- data required HealthProfileAnswerResource
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- meta FetchMetaResponse
FetchHealthProfileAnswersResponse
- FetchHealthProfileAnswersResponse
object
- data required
array
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- links CollectionResponseLinks
- meta FetchMetaResponse
- data required
FetchHealthProfileQuestionResponse
- FetchHealthProfileQuestionResponse
object
- data required HealthProfileQuestionResource
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- meta FetchMetaResponse
FetchHealthProfileQuestionsResponse
- FetchHealthProfileQuestionsResponse
object
- data required
array
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- links CollectionResponseLinks
- meta FetchMetaResponse
- data required
FetchHealthProfileResponse
- FetchHealthProfileResponse
object
- data required HealthProfileResource
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- meta FetchMetaResponse
FetchHealthProfilesResponse
- FetchHealthProfilesResponse
object
- data required
array
- items HealthProfileResource
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- links CollectionResponseLinks
- meta FetchMetaResponse
- data required
FetchHealthQuestionDefinitionResponse
- FetchHealthQuestionDefinitionResponse
object
- data required HealthQuestionDefinitionResource
- meta FetchMetaResponse
FetchHealthQuestionDefinitionsResponse
- FetchHealthQuestionDefinitionsResponse
object
- data required
array
- links CollectionResponseLinks
- meta FetchMetaResponse
- data required
FetchMetaResponse
- FetchMetaResponse
object
- count
integer
- req_id
string
- count
FetchOrganizationResponse
- FetchOrganizationResponse
object
- data required OrganizationResource
- meta FetchMetaResponse
FetchPatientHealthMetricResponse
- FetchPatientHealthMetricResponse
object
- data required
array
- links CollectionResponseLinks
- meta FetchMetaResponse
- data required
FetchPatientHealthResultResponse
- FetchPatientHealthResultResponse
object
- data required
array
- links CollectionResponseLinks
- meta FetchMetaResponse
- data required
FetchPatientPlanSummariesResponse
- FetchPatientPlanSummariesResponse
object
- data required
array
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- meta FetchMetaResponse
- data required
FetchPatientPlanSummaryResponse
- FetchPatientPlanSummaryResponse
object
- data required PatientPlanSummaryResource
- included
array
: Related resources which are included in the response based on theinclude
param.- items Resource
- meta FetchMetaResponse
FetchPatientResponse
- FetchPatientResponse
object
- data required PatientResource
- meta FetchMetaResponse
FetchPatientsResponse
- FetchPatientsResponse
object
- data required
array
- items PatientResource
- links CollectionResponseLinks
- meta FetchMetaResponse
- data required
FetchRewardEarningFulfillmentResponse
- FetchRewardEarningFulfillmentResponse
object
- data required RewardEarningFulfillmentResource
- meta FetchMetaResponse
FetchRewardEarningFulfillmentsResponse
- FetchRewardEarningFulfillmentsResponse
object
- data required
array
- meta FetchMetaResponse
- data required
FetchRewardEarningResponse
- FetchRewardEarningResponse
object
- data required RewardEarningResource
- meta FetchMetaResponse
FetchRewardEarningsResponse
- FetchRewardEarningsResponse
object
- data required
array
- items RewardEarningResource
- meta FetchMetaResponse
- data required
FetchRewardProgramActivationResponse
- FetchRewardProgramActivationResponse
object
- data required RewardProgramActivationResource
- meta FetchMetaResponse
FetchRewardProgramActivationsResponse
- FetchRewardProgramActivationsResponse
object
- data required
array
- meta FetchMetaResponse
- data required
FetchRewardProgramResponse
- FetchRewardProgramResponse
object
- data required RewardProgramResource
- meta FetchMetaResponse
FetchRewardProgramsResponse
- FetchRewardProgramsResponse
object
- data required
array
- items RewardProgramResource
- meta FetchMetaResponse
- data required
FetchRewardResponse
- FetchRewardResponse
object
- data required RewardResource
- meta FetchMetaResponse
FetchRewardsResponse
- FetchRewardsResponse
object
- data required
array
- items RewardResource
- meta FetchMetaResponse
- data required
GroupResource
- GroupResource
object
- attributes required
object
- bio
string
: A description of the group - name required
string
: The name of the group
- bio
- id required
string
- links
object
- self required
string
- self required
- type required
string
(values: group)
- attributes required
HealthProfileAnswerResource
- HealthProfileAnswerResource
object
- attributes
object
- history
array
: List of details of previous answers for a health profile question- items
object
: The details of a previous answer for a health profile question- _created_by
string
: The id of the patient or coach who answered the health profile question - answered_at
string
: The date when the health profile question is answered - value
string
: The value of the answer entered for the health profile question
- _created_by
- items
- latest
object
: The details of the latest answer for a health profile question- _created_by
string
: The id of the patient or coach who answered the health profile question - answered_at
string
: The date when the health profile question is answered - value
string
: The value of the answer entered for the health profile question
- _created_by
- question_id
string
- history
- id required
string
- links `o
- attributes