@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api Fitbit Plus API
@base https://api.twinehealth.com/pub
@version v7.78.1
@auth OAuth2
@endpoints 62
@hint download_for_search
@toc oauth(3), organization(1), group(3), coach(2), reward_program(4), action(3), bundle(3), calendar_event(5), calendar_event_response(1), email_history(2), health_profile(2), health_profile_question(2), health_profile_answer(2), health_question_definition(2), patient_health_metric(3), patient(7), patient_plan_summary(3), result(2), reward(3), reward_earning(3), reward_earning_fulfillment(3), reward_program_activation(3)

@group oauth
@endpoint POST /oauth/token
@desc Create an oauth token
@required {body: map}
@optional {include: any # List of related resources to include in the response}
@returns(201) Created
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /oauth/token/{id}/groups
@desc Get the groups for a token
@required {id: any # Token identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /oauth/token/{id}/organization
@desc Get the organization for a token
@required {id: any # Token identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group organization
@endpoint GET /organization/{id}
@desc Get an organization
@required {id: any # Organization identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group group
@endpoint POST /group
@desc Create a group
@required {body: map}
@returns(201) Created
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /group
@desc List groups
@required {filter[organization]: any # Organization identifier}
@optional {filter[name]: any # Group name}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /group/{id}
@desc Get a group
@required {id: any # Group identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group coach
@endpoint GET /coach
@desc List coaches
@optional {filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`.}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /coach/{id}
@desc Get a coach
@required {id: any # Coach identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group reward_program
@endpoint POST /reward_program
@desc Create a reward program
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /reward_program
@desc List reward programs
@optional {filter[groups]: any # Comma-separated list of group identifiers. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`.}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /reward_program/{id}
@desc Get a reward program
@required {id: any # Reward program identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /reward_program/{id}/group
@desc Get group for a reward program
@required {id: any # Reward program identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group action
@endpoint POST /action
@desc Create action
@required {body: map}
@returns(201) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /action/{id}
@desc Get an action
@required {id: any # Action identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint PATCH /action/{id}
@desc Update an action
@required {id: any # Action identifier, body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endgroup

@group bundle
@endpoint POST /bundle
@desc Create bundle
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /bundle/{id}
@desc Get a bundle
@required {id: any # Bundle identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint PATCH /bundle/{id}
@desc Update a bundle
@required {id: any # Bundle identifier, body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endgroup

@group calendar_event
@endpoint POST /calendar_event
@desc Create calendar event
@required {body: map}
@returns(201) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /calendar_event
@desc List calendar events
@optional {filter[patient]: any # Patient id to fetch calendar event. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, `filter[organization]`, or `filter[attendees]`., filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, `filter[organization]`, or `filter[attendees]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, `filter[organization]`, or `filter[attendees]`., filter[attendees]: any # Comma-separated list of coach or patient ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, `filter[organization]`, or `filter[attendees]`., filter[type]: any # Calendar event type, filter[completed]: any # If not specified, return all calendar events. If set to `true` return only events marked as completed, if set to `false`, return only events not marked as completed yet., filter[start_at]: any # 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`, filter[end_at]: any # 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`, filter[completed_at]: any # 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`, filter[created_at]: any # 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`, filter[updated_at]: any # 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`, page[number]: any # Page number, page[size]: any # Page size, page[limit]: any # Page limit, page[cursor]: any # Page cursor, include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /calendar_event/{id}
@desc Get a calendar event
@required {id: any # Calendar event identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint PATCH /calendar_event/{id}
@desc Update a calendar event
@required {id: any # Calendar event identifier, body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint DELETE /calendar_event/{id}
@desc Delete a calendar event
@required {id: any # Calendar event identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group calendar_event_response
@endpoint POST /calendar_event_response
@desc Create calendar event response
@required {body: map}
@returns(201) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endgroup

@group email_history
@endpoint GET /email_history
@desc List email histories
@optional {filter[receiver]: any # Fitbit Plus user id of email recipient. Required if filter[sender] is not defined., filter[sender]: any # Fitbit Plus user id of email sender. Required if filter[receiver] is not defined., filter[emailType]: any # Type of email, sort: any # valid sorts:   * send_time - ascending by send_time   * -send_time - descending by send_time}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /email_history/{id}
@desc Get an email history
@required {id: any # Email history identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group health_profile
@endpoint GET /health_profile
@desc List health profiles
@optional {filter[patient]: any # Patient id to fetch health profile. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., page[number]: any # Page number, page[size]: any # Page size, page[limit]: any # Page limit, page[cursor]: any # Page cursor, include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /health_profile/{id}
@desc Get a health profile
@required {id: any # Health profile identifier}
@optional {include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group health_profile_question
@endpoint GET /health_profile_question
@desc List health profile questions
@optional {filter[patient]: any # Patient id to fetch healt profile questions. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /health_profile_question/{id}
@desc Get a health profile question
@required {id: any # Health profile question identifier}
@optional {include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group health_profile_answer
@endpoint GET /health_profile_answer
@desc List health profile answers
@optional {filter[patient]: any # Patient id to fetch healt profile answers. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`., page[number]: any # Page number, page[size]: any # Page size, page[limit]: any # Page limit, page[cursor]: any # Page cursor, include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /health_profile_answer/{id}
@desc Get a health profile answer
@required {id: any # Health profile answer identifier}
@optional {include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group health_question_definition
@endpoint GET /health_question_definition
@desc List health question definitions
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /health_question_definition/{id}
@desc Get a health question definition
@required {id: any # Health question definition identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group patient_health_metric
@endpoint POST /patient_health_metric
@desc Create patient health metrics
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /patient_health_metric
@desc List patient health metrics
@optional {filter[patient]: any # 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]`., filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., page[number]: any # Page number, page[size]: any # Page size, page[limit]: any # Page limit, page[cursor]: any # Page cursor}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /patient_health_metric/{id}
@desc Get a patient health metric
@required {id: any # Patient health metric identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group patient
@endpoint POST /patient
@desc Create a patient
@required {body: map}
@returns(201) Created
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /patient
@desc List patients
@optional {filter[groups]: any # Comma-separated list of group ids. Note that either `filter[group]` or `filter[organization]` must be specified., filter[organization]: any # Fitbit Plus organization id. Note that either `filter[group]` or `filter[organization]` must be specified., filter[identifier][system]: any # Identifier system (example: "MyEHR") - requires a "filter[identifier][value]" parameter, filter[identifier][value]: any # Identifier value (example: "12345") - requires a "filter[identifier][system]" parameter, filter[archived]: any # 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., filter[created_at]: any # 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`, filter[updated_at]: any # 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`, page[number]: any # Page number, page[size]: any # Page size, page[limit]: any # Page limit, page[cursor]: any # Page cursor}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint PUT /patient
@desc Upsert patient
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /patient/{id}
@desc Get a patient
@required {id: any # Patient identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint PATCH /patient/{id}
@desc Update a patient
@required {id: any # Patient identifier, body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /patient/{id}/groups
@desc List groups for a patient
@required {id: any # Patient identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /patient/{id}/coaches
@desc List coaches for a patient
@required {id: any # Patient identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group patient_plan_summary
@endpoint GET /patient_plan_summary
@desc List patient plan summaries
@optional {filter[patient]: any # Patient id to fetch plan summary for. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /patient_plan_summary/{id}
@desc Get the plan summary for a patient
@required {id: any # Plan summary identifier}
@optional {include: any # List of related resources to include in the response}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint PATCH /patient_plan_summary/{id}
@desc Update a plan summary
@required {id: any # Plan summary identifier, body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endgroup

@group result
@endpoint GET /result
@desc List patient health results
@required {filter[patient]: any # Filter the patient health results for a specified patient}
@optional {filter[actions]: any # A comma-separated list of action identifiers, filter[start_at]: any # Filter results that occurred after the passed ISO date and time string, filter[end_at]: any # Filter results that occurred before the passed ISO date and time string, filter[threads]: any # A comma-separated list of thread identifiers, filter[created_at]: any # 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`, filter[updated_at]: any # 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`, page[number]: any # Page number, page[size]: any # Page size, page[limit]: any # Page limit, page[after]: any # Page cursor}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /result/{id}
@desc Get a patient health result
@required {id: any # Patient health result identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group reward
@endpoint POST /reward
@desc Create a reward
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /reward
@desc List rewards
@optional {filter[patient]: any # Patient identifier. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., filter[reward_program_activation]: any # Reward program activation identifier, filter[thread]: any # Thread identifier, filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /reward/{id}
@desc Get a reward
@required {id: any # Reward identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group reward_earning
@endpoint POST /reward_earning
@desc Create a reward earning
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /reward_earning
@desc List reward earnings
@required {filter[groups]: any # Group identifiers, filter[patient]: any # Patient identifier}
@optional {filter[ready_for_fulfillment]: any # 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.}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /reward_earning/{id}
@desc Get a reward earning
@required {id: any # Reward earning identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group reward_earning_fulfillment
@endpoint POST /reward_earning_fulfillment
@desc Create a reward earning fulfillment
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /reward_earning_fulfillment
@desc List reward earning fulfillments
@required {filter[patient]: any # Patient identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /reward_earning_fulfillment/{id}
@desc Get a reward earning fulfillment
@required {id: any # Reward earning fulfillment identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@group reward_program_activation
@endpoint POST /reward_program_activation
@desc Create a reward program activation
@required {body: map}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden, 409: Invalid Request}

@endpoint GET /reward_program_activation
@desc List reward program activations
@optional {filter[patient]: any # Patient identifier. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., filter[groups]: any # Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`., filter[organization]: any # Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endpoint GET /reward_program_activation/{id}
@desc Get a reward program activation
@required {id: any # Reward program activation identifier}
@returns(200) OK
@errors {401: Unauthorized, 403: Forbidden}

@endgroup

@end
