openapi: 3.0.0
servers:
  - url: https://api.twinehealth.com/pub
info:
  contact:
    email: apiteam@twinehealth.com
  description: |
    # Overview
    The Fitbit Plus API is a RESTful API. The requests and responses are formated according to the
    [JSON API](http://jsonapi.org/format/1.0/) specification.

    In addition to this documentation, we also provide an
    [OpenAPI](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) "yaml" file describing the API:
    [Fitbit Plus API Specification](swagger.yaml).

    # Authentication
    Authentication for the Fitbit Plus API is based on the
    [OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749). Fitbit Plus currently supports grant
    types of **client_credentials** and **refresh_token**.

    See [POST /oauth/token](#operation/createToken) for details on the request and response formats.
    <!-- ReDoc-Inject: <security-definitions> -->

    ## 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.
  title: Fitbit Plus API
  version: v7.78.1
  x-apisguru-categories:
    - support
  x-logo:
    url: http://developer.twinehealth.com/images/Fitbit_Plus_lockup_2C_RGB-32.png
  x-origin:
    - format: openapi
      url: https://raw.githubusercontent.com/TwineHealth/TwineDeveloperDocs/master/spec/swagger.yaml
      version: "3.0"
  x-providerName: twinehealth.com
tags:
  - description: Authentication operations
    name: oauth
  - description: An organization is a Fitbit Plus customer. No data is accessible across organizations.
    name: organization
  - description: A group is a cohort of patients within an organization. The creation of groups allows for the segmentation of dashboards and analytics. For example, a group might correspond to the patients in a particular practice or the employees of a particular employer.
    name: group
  - description: A coach is a person that supports a patient
    name: coach
  - description: A reward program provides the details for a rewards program for a group. Different rewards programs can be created for different periods of time specified by the start_at and end_at dates. A reward program can activated for a patient any time between these dates. An activated reward program for a patient is called a reward program activation.
    name: reward program
  - description: An action is an actionable item in a patient's plan.
    name: action
  - description: A bundle is a collection of actions (an action plan) in a patient's plan summary.
    name: bundle
  - description: A calendar event represents an event involving or relevant to a patient which will or has occurred on a specific date or during a specific period of time.
    name: calendar event
  - description: A calendar event response indicates the attendee's response to a calendar event.  Only `POST` for creation is allowed as the responses are updated into the corresponding calendar events.
    name: calendar event response
  - description: Email history represents a single email that was sent using Fitbit Plus.
    name: email history
  - description: A health profile contains a set of health questions and answers for a patient.
    name: health profile
  - description: A health profile answer is the answer to a question for a patient.
    name: health profile answer
  - description: A health profile question contains a health question and the corresponding answer for a patient.
    name: health profile question
  - description: A health question definition specifies a health question and the corresponding answer choices.
    name: health question definition
  - description: A metric is a quantitative result for a patient. For example, vital signs, lab results, etc. are all metrics.
    name: metric
  - description: A patient is the core user of Fitbit Plus.
    name: patient
  - description: A plan is the set of actions and associated goals for a patient.
    name: plan
  - description: A patient health result is a quantitative result for a patient.
    name: result
  - description: A reward allocates a portion of the budget from the reward program activation for achieving a particular goal and sets a target date.
    name: reward
  - description: A reward earning specifies the portion of a reward that was earned and at what date.
    name: reward earning
  - description: A reward earning fulfillment specifies the portion of a reward earning that was fulfilled and at what date.
    name: reward earning fulfillment
  - description: A reward program activation is the activation of a reward program for a specific patient.
    name: reward program activation
paths:
  /action:
    post:
      description: Create a plan action
      operationId: createAction
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateActionRequest"
        required: true
      responses:
        "201":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateActionResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create action
      tags:
        - action
  "/action/{id}":
    get:
      description: Get a health action from a patient's plan.
      operationId: fetchAction
      parameters:
        - description: Action identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchActionResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get an action
      tags:
        - action
    patch:
      description: Update a health action from a patient's plan.
      operationId: updateAction
      parameters:
        - description: Action identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/UpdateActionRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/UpdateActionResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Update an action
      tags:
        - action
  /bundle:
    post:
      description: Create a bundle in a patient's plan
      operationId: createBundle
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateBundleRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateBundleResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create bundle
      tags:
        - bundle
  "/bundle/{id}":
    get:
      description: Get a bundle from a patient's plan.
      operationId: fetchBundle
      parameters:
        - description: Bundle identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchBundleResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a bundle
      tags:
        - bundle
    patch:
      description: Updte a bundle from a patient's plan.
      operationId: updateBundle
      parameters:
        - description: Bundle identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/UpdateBundleRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/UpdateBundleResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Update a bundle
      tags:
        - bundle
  /calendar_event:
    get:
      description: Get a list of calendar events
      operationId: fetchCalendarEvents
      parameters:
        - description: |
            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]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: |
            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]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, `filter[organization]`, or `filter[attendees]`.
          in: query
          name: filter[organization]
          schema:
            type: string
        - description: |
            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]`.
          in: query
          name: filter[attendees]
          schema:
            type: string
        - description: Calendar event type
          in: query
          name: filter[type]
          schema:
            enum:
              - plan-check-in
              - reminder
              - telephone-call
              - office-visit
              - video-call
            type: string
        - description: 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.
          in: query
          name: filter[completed]
          schema:
            type: boolean
        - description: |
            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`
          in: query
          name: filter[start_at]
          schema:
            type: string
        - description: |
            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`
          in: query
          name: filter[end_at]
          schema:
            type: string
        - description: |
            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`
          in: query
          name: filter[completed_at]
          schema:
            type: string
        - description: |
            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`
          in: query
          name: filter[created_at]
          schema:
            type: string
        - description: |
            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`
          in: query
          name: filter[updated_at]
          schema:
            type: string
        - description: Page number
          in: query
          name: page[number]
          required: false
          schema:
            default: 1
            type: integer
        - description: Page size
          in: query
          name: page[size]
          required: false
          schema:
            default: 10
            maximum: 50
            minimum: 0
            type: integer
        - description: Page limit
          in: query
          name: page[limit]
          required: false
          schema:
            default: 50
            minimum: 0
            type: integer
        - description: Page cursor
          in: query
          name: page[cursor]
          required: false
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - owner
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchCalendarEventsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List calendar events
      tags:
        - calendar event
    post:
      description: 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.
      operationId: createCalendarEvent
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateCalendarEventRequest"
        required: true
      responses:
        "201":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateCalendarEventResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create calendar event
      tags:
        - calendar event
  "/calendar_event/{id}":
    delete:
      description: Delete a calendar event by id
      operationId: deleteCalendarEvent
      parameters:
        - description: Calendar event identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Delete a calendar event
      tags:
        - calendar event
    get:
      description: Get a calendar event by id
      operationId: fetchCalendarEvent
      parameters:
        - description: Calendar event identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchCalendarEventResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a calendar event
      tags:
        - calendar event
    patch:
      description: 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.
      operationId: updateCalendarEvent
      parameters:
        - description: Calendar event identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/UpdateCalendarEventRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/UpdateCalendarEventResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Update a calendar event
      tags:
        - calendar event
  /calendar_event_response:
    post:
      description: 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.
      operationId: createCalendarEventResponse
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateCalendarEventResponseRequest"
        required: true
      responses:
        "201":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateCalendarEventResponseRequest"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create calendar event response
      tags:
        - calendar event response
  /coach:
    get:
      description: Get a list of coaches matching the specified filters.
      operationId: fetchCoaches
      parameters:
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchCoachesResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List coaches
      tags:
        - coach
  "/coach/{id}":
    get:
      description: Get a coach record by id.
      operationId: fetchCoach
      parameters:
        - description: Coach identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchCoachResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a coach
      tags:
        - coach
  /email_history:
    get:
      description: Get a list of email histories
      operationId: fetchEmailHistories
      parameters:
        - description: Fitbit Plus user id of email recipient. Required if filter[sender] is not defined.
          in: query
          name: filter[receiver]
          schema:
            type: string
        - description: Fitbit Plus user id of email sender. Required if filter[receiver] is not defined.
          in: query
          name: filter[sender]
          schema:
            type: string
        - description: Type of email
          in: query
          name: filter[emailType]
          schema:
            type: string
        - description: |
            valid sorts:
              * send_time - ascending by send_time
              * -send_time - descending by send_time
          in: query
          name: sort
          schema:
            enum:
              - send_time
              - -send_time
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchEmailHistoriesResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List email histories
      tags:
        - email history
  "/email_history/{id}":
    get:
      description: Get an email history by id
      operationId: fetchEmailHistory
      parameters:
        - description: Email history identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchEmailHistoryResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get an email history
      tags:
        - email history
  /group:
    get:
      description: Get a list of groups matching the specified filters.
      operationId: fetchGroups
      parameters:
        - description: Organization identifier
          in: query
          name: filter[organization]
          required: true
          schema:
            type: string
        - description: Group name
          in: query
          name: filter[name]
          required: false
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchGroupsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List groups
      tags:
        - group
    post:
      description: Create a group record.
      operationId: createGroup
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateGroupRequest"
        required: true
      responses:
        "201":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateGroupResponse"
          description: Created
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create a group
      tags:
        - group
  "/group/{id}":
    get:
      description: Get a group record by id.
      operationId: fetchGroup
      parameters:
        - description: Group identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchGroupResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a group
      tags:
        - group
  /health_profile:
    get:
      description: Get a list of health profiles
      operationId: fetchHealthProfiles
      parameters:
        - description: |
            Patient id to fetch health profile. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
        - description: Page number
          in: query
          name: page[number]
          required: false
          schema:
            default: 1
            type: integer
        - description: Page size
          in: query
          name: page[size]
          required: false
          schema:
            default: 10
            maximum: 50
            minimum: 0
            type: integer
        - description: Page limit
          in: query
          name: page[limit]
          required: false
          schema:
            default: 50
            minimum: 0
            type: integer
        - description: Page cursor
          in: query
          name: page[cursor]
          required: false
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - patient
              - questions
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthProfilesResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List health profiles
      tags:
        - health profile
  "/health_profile/{id}":
    get:
      description: Get a health profile by id
      operationId: fetchHealthProfile
      parameters:
        - description: Health profile identifier
          in: path
          name: id
          required: true
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - patient
              - questions
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthProfileResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a health profile
      tags:
        - health profile
  /health_profile_answer:
    get:
      description: Get a list of health profile answers
      operationId: fetchHealthProfileAnswers
      parameters:
        - description: |
            Patient id to fetch healt profile answers. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
        - description: Page number
          in: query
          name: page[number]
          required: false
          schema:
            default: 1
            type: integer
        - description: Page size
          in: query
          name: page[size]
          required: false
          schema:
            default: 50
            maximum: 100
            minimum: 0
            type: integer
        - description: Page limit
          in: query
          name: page[limit]
          required: false
          schema:
            default: 50
            minimum: 0
            type: integer
        - description: Page cursor
          in: query
          name: page[cursor]
          required: false
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - patient
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthProfileAnswersResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List health profile answers
      tags:
        - health profile answer
  "/health_profile_answer/{id}":
    get:
      description: Get a health profile answer by id
      operationId: fetchHealthProfileAnswer
      parameters:
        - description: Health profile answer identifier
          in: path
          name: id
          required: true
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - patient
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthProfileAnswerResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a health profile answer
      tags:
        - health profile answer
  /health_profile_question:
    get:
      description: Get a list of health profile questions
      operationId: fetchHealthProfileQuestions
      parameters:
        - description: |
            Patient id to fetch healt profile questions. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[group]`, or `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - question_definition
              - answer
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthProfileQuestionsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List health profile questions
      tags:
        - health profile question
  "/health_profile_question/{id}":
    get:
      description: Get a health profile by id
      operationId: fetchHealthProfileQuestion
      parameters:
        - description: Health profile question identifier
          in: path
          name: id
          required: true
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - question_definition
              - answer
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthProfileQuestionResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a health profile question
      tags:
        - health profile question
  /health_question_definition:
    get:
      description: Get a list of all health question definitions
      operationId: fetchHealthQuestionDefinitions
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthQuestionDefinitionsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List health question definitions
      tags:
        - health question definition
  "/health_question_definition/{id}":
    get:
      description: Get a health question definition by id
      operationId: fetchHealthQuestionDefinition
      parameters:
        - description: Health question definition identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchHealthQuestionDefinitionResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a health question definition
      tags:
        - health question definition
  /oauth/token:
    post:
      description: |
        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"
        }
        ```
      operationId: createToken
      parameters:
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - groups
              - organization
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTokenRequest"
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateTokenRequest"
        required: true
      responses:
        "201":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateTokenResponse"
          description: Created
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      security:
        - OAuth2:
            - group
            - organization
      summary: Create an oauth token
      tags:
        - oauth
  "/oauth/token/{id}/groups":
    get:
      description: Get the list of groups a token can be used to access.
      operationId: fetchTokenGroups
      parameters:
        - description: Token identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchGroupsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      security:
        - OAuth2:
            - group
            - organization
      summary: Get the groups for a token
      tags:
        - oauth
  "/oauth/token/{id}/organization":
    get:
      description: Get the organization a token can be used to access.
      operationId: fetchTokenOrganization
      parameters:
        - description: Token identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchOrganizationResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get the organization for a token
      tags:
        - oauth
  "/organization/{id}":
    get:
      description: Get an organization record by id.
      operationId: fetchOrganization
      parameters:
        - description: Organization identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchOrganizationResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get an organization
      tags:
        - organization
  /patient:
    get:
      description: Get a list of patients.
      operationId: fetchPatients
      parameters:
        - description: Comma-separated list of group ids. Note that either `filter[group]` or `filter[organization]` must be specified.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: Fitbit Plus organization id. Note that either `filter[group]` or `filter[organization]` must be specified.
          in: query
          name: filter[organization]
          schema:
            type: string
        - description: 'Identifier system (example: "MyEHR") - requires a "filter[identifier][value]" parameter'
          in: query
          name: filter[identifier][system]
          schema:
            type: string
        - description: 'Identifier value (example: "12345") - requires a "filter[identifier][system]" parameter'
          in: query
          name: filter[identifier][value]
          schema:
            type: string
        - description: 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.
          in: query
          name: filter[archived]
          schema:
            type: boolean
        - description: |
            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`
          in: query
          name: filter[created_at]
          schema:
            type: string
        - description: |
            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`
          in: query
          name: filter[updated_at]
          schema:
            type: string
        - description: Page number
          in: query
          name: page[number]
          required: false
          schema:
            default: 1
            type: integer
        - description: Page size
          in: query
          name: page[size]
          required: false
          schema:
            default: 10
            maximum: 50
            minimum: 0
            type: integer
        - description: Page limit
          in: query
          name: page[limit]
          required: false
          schema:
            default: 50
            minimum: 0
            type: integer
        - description: Page cursor
          in: query
          name: page[cursor]
          required: false
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List patients
      tags:
        - patient
    post:
      description: |
        Create a patient record.

        Example for creating a patient with a group specified using `meta.query` instead of `id`:

        ```JSON
        {
          "data": {
            "type": "patient",
            "attributes": {
              "first_name": "Andrew",
              "last_name": "Smith"
            },
            "relationships": {
              "groups": {
                "data": [
                  {
                    "type": "group",
                    "meta": {
                      "query": {
                        "organization": "58c88de7c93eb96357a87033",
                        "name": "Patients Lead"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
        ```
      operationId: createPatient
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreatePatientRequest"
        required: true
      responses:
        "201":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreatePatientResponse"
          description: Created
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create a patient
      tags:
        - patient
    put:
      description: Create a new patient or update an existing patient
      operationId: upsertPatient
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/UpsertPatientRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreatePatientResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Upsert patient
      tags:
        - patient
  "/patient/{id}":
    get:
      description: Gets a patient record by id.
      operationId: fetchPatient
      parameters:
        - description: Patient identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a patient
      tags:
        - patient
    patch:
      description: Update a patient record.
      operationId: updatePatient
      parameters:
        - description: Patient identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/UpdatePatientRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/UpdatePatientResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Update a patient
      tags:
        - patient
  "/patient/{id}/coaches":
    get:
      description: Get the list of coaches for a patient.
      operationId: fetchPatientCoaches
      parameters:
        - description: Patient identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchCoachesResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List coaches for a patient
      tags:
        - patient
  "/patient/{id}/groups":
    get:
      description: Get the list of groups for a patient.
      operationId: fetchPatientGroups
      parameters:
        - description: Patient identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchGroupsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List groups for a patient
      tags:
        - patient
  /patient_health_metric:
    get:
      description: Get a list of patient health metrics.
      operationId: fetchPatientHealthMetrics
      parameters:
        - description: |
            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]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
        - description: Page number
          in: query
          name: page[number]
          required: false
          schema:
            default: 1
            type: integer
        - description: Page size
          in: query
          name: page[size]
          required: false
          schema:
            default: 10
            maximum: 50
            minimum: 0
            type: integer
        - description: Page limit
          in: query
          name: page[limit]
          required: false
          schema:
            default: 50
            minimum: 0
            type: integer
        - description: Page cursor
          in: query
          name: page[cursor]
          required: false
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientHealthMetricResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List patient health metrics
      tags:
        - metric
    post:
      description: |
        Create one or more patient health metrics.

        Example for creating a patient health result with a patient specified using `meta.query` instead of `id`:

        ```JSON
          {
            "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"
                      }
                    }
                  }
                }
              }
            }
          }
        ```
      operationId: createPatientHealthMetric
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreatePatientHealthMetricRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreatePatientHealthMetricResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create patient health metrics
      tags:
        - metric
  "/patient_health_metric/{id}":
    get:
      description: Get the plan summary for a patient.
      operationId: fetchPatientHealthMetric
      parameters:
        - description: Patient health metric identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientHealthMetricResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a patient health metric
      tags:
        - metric
  /patient_plan_summary:
    get:
      description: Get a list of patient plan summaries
      operationId: fetchPatientPlanSummaries
      parameters:
        - description: |
            Patient id to fetch plan summary for. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - actions
              - bundles
              - patient
              - current_results
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientPlanSummariesResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List patient plan summaries
      tags:
        - plan
  "/patient_plan_summary/{id}":
    get:
      description: Get the plan summary for a patient.
      operationId: fetchPatientPlanSummary
      parameters:
        - description: Plan summary identifier
          in: path
          name: id
          required: true
          schema:
            type: string
        - description: List of related resources to include in the response
          in: query
          name: include
          required: false
          schema:
            enum:
              - actions
              - bundles
              - patient
              - current_results
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientPlanSummaryResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get the plan summary for a patient
      tags:
        - plan
    patch:
      description: Update a plan summary record for a patient.
      operationId: updatePatientPlanSummary
      parameters:
        - description: Plan summary identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/UpdatePatientPlanSummaryRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/UpdatePatientPlanSummaryResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Update a plan summary
      tags:
        - plan
  /result:
    get:
      description: Get a list of patient health results.
      operationId: fetchPatientHealthResults
      parameters:
        - description: Filter the patient health results for a specified patient
          in: query
          name: filter[patient]
          required: true
          schema:
            type: string
        - description: A comma-separated list of action identifiers
          in: query
          name: filter[actions]
          schema:
            type: string
        - description: Filter results that occurred after the passed ISO date and time string
          in: query
          name: filter[start_at]
          schema:
            format: dateTime
            type: string
        - description: Filter results that occurred before the passed ISO date and time string
          in: query
          name: filter[end_at]
          schema:
            format: dateTime
            type: string
        - description: A comma-separated list of thread identifiers
          in: query
          name: filter[threads]
          schema:
            type: string
        - description: |
            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`
          in: query
          name: filter[created_at]
          schema:
            type: string
        - description: |
            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`
          in: query
          name: filter[updated_at]
          schema:
            type: string
        - description: Page number
          in: query
          name: page[number]
          required: false
          schema:
            default: 1
            type: integer
        - description: Page size
          in: query
          name: page[size]
          required: false
          schema:
            default: 10
            maximum: 50
            minimum: 0
            type: integer
        - description: Page limit
          in: query
          name: page[limit]
          required: false
          schema:
            default: 50
            minimum: 0
            type: integer
        - description: Page cursor
          in: query
          name: page[after]
          required: false
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientHealthResultResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Invalid Request
      summary: List patient health results
      tags:
        - result
  "/result/{id}":
    get:
      description: Get patient health result by id.
      operationId: fetchPatientHealthResult
      parameters:
        - description: Patient health result identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchPatientHealthResultResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a patient health result
      tags:
        - result
  /reward:
    get:
      description: Get a list of rewards matching the specified filters.
      operationId: fetchRewards
      parameters:
        - description: |
            Patient identifier. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: Reward program activation identifier
          in: query
          name: filter[reward_program_activation]
          schema:
            type: string
        - description: Thread identifier
          in: query
          name: filter[thread]
          schema:
            type: string
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List rewards
      tags:
        - reward
    post:
      description: Create a reward for a patient.
      operationId: createReward
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateRewardRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateRewardResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create a reward
      tags:
        - reward
  "/reward/{id}":
    get:
      description: Get a reward record by id.
      operationId: fetchReward
      parameters:
        - description: Reward identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a reward
      tags:
        - reward
  /reward_earning:
    get:
      description: Get a list of reward earnings matching the specified filters.
      operationId: fetchRewardEarnings
      parameters:
        - description: Group identifiers
          in: query
          name: filter[groups]
          required: true
          schema:
            type: string
        - description: Patient identifier
          in: query
          name: filter[patient]
          required: true
          schema:
            type: string
        - description: 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.
          in: query
          name: filter[ready_for_fulfillment]
          schema:
            type: boolean
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardEarningsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List reward earnings
      tags:
        - reward earning
    post:
      description: 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.
      operationId: createRewardEarning
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateRewardEarningRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateRewardEarningResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create a reward earning
      tags:
        - reward earning
  "/reward_earning/{id}":
    get:
      description: Get a reward earning record by id.
      operationId: fetchRewardEarning
      parameters:
        - description: Reward earning identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardEarningResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a reward earning
      tags:
        - reward earning
  /reward_earning_fulfillment:
    get:
      description: Get a list of reward earning fulfillments matching the specified filters.
      operationId: fetchRewardEarningFulfillments
      parameters:
        - description: Patient identifier
          in: query
          name: filter[patient]
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardEarningFulfillmentsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List reward earning fulfillments
      tags:
        - reward earning fulfillment
    post:
      description: Create a reward earning fulfillment for a reward earning. There can only be one fulfillment for each earning.
      operationId: createRewardEarningFulfillment
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateRewardEarningFulfillmentRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateRewardEarningFulfillmentResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create a reward earning fulfillment
      tags:
        - reward earning fulfillment
  "/reward_earning_fulfillment/{id}":
    get:
      description: Get a reward earning fulfillment record by id.
      operationId: fetchRewardEarningFulfillment
      parameters:
        - description: Reward earning fulfillment identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardEarningFulfillmentResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a reward earning fulfillment
      tags:
        - reward earning fulfillment
  /reward_program:
    get:
      description: Get a list of reward programs matching the specified filters.
      operationId: fetchRewardPrograms
      parameters:
        - description: |
            Comma-separated list of group identifiers. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardProgramsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List reward programs
      tags:
        - reward program
    post:
      description: Create a reward program for a group.
      operationId: createRewardProgram
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateRewardProgramRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateRewardProgramResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create a reward program
      tags:
        - reward program
  "/reward_program/{id}":
    get:
      description: Get a reward program record by id.
      operationId: fetchRewardProgram
      parameters:
        - description: Reward program identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardProgramResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a reward program
      tags:
        - reward program
  "/reward_program/{id}/group":
    get:
      description: Get the group related to a reward program.
      operationId: fetchRewardProgramGroup
      parameters:
        - description: Reward program identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchGroupsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get group for a reward program
      tags:
        - reward program
  /reward_program_activation:
    get:
      description: Get a list of reward program activations matching the specified filters.
      operationId: fetchRewardProgramActivations
      parameters:
        - description: |
            Patient identifier. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[patient]
          schema:
            type: string
        - description: |
            Comma-separated list of group ids. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[groups]
          schema:
            type: string
        - description: |
            Fitbit Plus organization id. Note that one of the following filters must be specified: `filter[patient]`, `filter[groups]`, `filter[organization]`.
          in: query
          name: filter[organization]
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardProgramActivationsResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: List reward program activations
      tags:
        - reward program activation
    post:
      description: Create a reward program activation for a patient. There can only be one activation for a patient for a given reward program.
      operationId: createRewardProgramActivation
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: "#/components/schemas/CreateRewardProgramActivationRequest"
        required: true
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateRewardProgramActivationResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Forbidden
        "409":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/CreateOrUpdateErrorResponse"
          description: Invalid Request
      summary: Create a reward program activation
      tags:
        - reward program activation
  "/reward_program_activation/{id}":
    get:
      description: Get a reward program activationrecord by id.
      operationId: fetchRewardProgramActivation
      parameters:
        - description: Reward program activation identifier
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchRewardProgramActivationResponse"
          description: OK
        "401":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Unauthorized
        "403":
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/FetchErrorResponse"
          description: Forbidden
      summary: Get a reward program activation
      tags:
        - reward program activation
components:
  schemas:
    ActionMetric:
      properties:
        goal:
          type: object
        metric_type:
          type: string
        unit:
          type: string
        validations:
          properties:
            maximum:
              properties:
                unit:
                  type: string
                value:
                  type: number
              type: object
            minimum:
              properties:
                unit:
                  type: string
                value:
                  type: number
              type: object
          type: object
      type: object
    ActionResource:
      properties:
        attributes:
          properties:
            _thread:
              type: string
            adherence:
              properties:
                complete:
                  type: integer
                due:
                  type: integer
                streak:
                  properties:
                    count:
                      type: integer
                    updated_at:
                      format: dateTime
                      type: string
                  type: object
              readOnly: true
              type: object
            details:
              additionalProperties: true
              type: object
            effective_from:
              format: dateTime
              type: string
            effective_to:
              format: dateTime
              type: string
            frequency_goal:
              properties:
                weeks:
                  properties:
                    days:
                      items:
                        description: Days of week that the action is scheduled for. Zero-indexed, ex 0 represents Sunday, etc.
                        enum:
                          - 0
                          - 1
                          - 2
                          - 3
                          - 4
                          - 5
                          - 6
                        maxItems: 7
                        type: integer
                      type: array
                  type: object
              type: object
            identifiers:
              items:
                $ref: "#/components/schemas/Identifier"
              type: array
            intake:
              additionalProperties: true
              type: object
            metric_required:
              type: boolean
            metrics:
              items:
                $ref: "#/components/schemas/ActionMetric"
              type: array
            static_title:
              readOnly: true
              type: string
            title:
              type: string
            tracking:
              type: boolean
            type:
              enum:
                - other_lifestyle
              type: string
            windows:
              items:
                $ref: "#/components/schemas/ActionWindow"
              type: array
          required:
            - type
            - title
            - effective_from
          type: object
        id:
          type: string
        relationships:
          properties:
            plan:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  type: object
              type: object
          type: object
        type:
          type: string
      required:
        - type
        - id
      type: object
    ActionWindow:
      properties:
        _id:
          type: string
        title:
          type: string
        type:
          type: string
      required:
        - type
      type: object
    Address:
      properties:
        city:
          example: Cambridge
          type: string
        country:
          type: string
        district:
          type: string
        lines:
          example:
            - 1234 Any St.
          items:
            type: string
          type: array
        postal_code:
          example: "02138"
          type: string
        state:
          example: MA
          type: string
        text:
          type: string
        type:
          type: string
        use:
          type: string
      type: object
    ArchiveHistory:
      properties:
        archived:
          example: true
          type: boolean
        modified_at:
          example: 2016-06-03T13:15:22.000Z
          format: dateTime
          type: string
        notes:
          example: Patient called requesting opt out of coaching
          type: string
        reason:
          example: Opted out of coaching
          type: string
      type: object
    BundleResource:
      properties:
        attributes:
          properties:
            _thread:
              type: string
            effective_from:
              format: dateTime
              type: string
            effective_to:
              format: dateTime
              type: string
            title:
              type: string
            type:
              type: string
          required:
            - type
            - title
            - effective_from
          type: object
        id:
          type: string
        relationships:
          properties:
            actions:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  type: object
              type: object
            plan:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  type: object
              type: object
          type: object
        type:
          type: string
      required:
        - type
        - id
      type: object
    CalendarEventResource:
      example:
        attributes:
          all_day: true
          attendees:
            - _id: 5ac7e74679f6868274a42e28
              response_status: needsAction
              user: 5a0c8e27a9d454cc150997c9
            - _id: 5ac7e74679f6868274a42e27
              response_status: needsAction
              user: 5a0c8e27a9d454cc150997f7
          completed_at: 2017-11-03T06:17:34.652Z
          completed_by: 5a0c8e27a9d454cc150997c9
          created_at: 2017-10-20T10:59:40.000Z
          created_by: 5a0c8e27a9d454cc150997c9
          end_at: 2017-11-03T08:00:00.000Z
          start_at: 2017-11-03T04:00:00.000Z
          time_zone: America/New_York
          title: Plan Check-In
          type: plan-check-in
          updated_at: 2017-10-20T10:59:40.000Z
          updated_by: 5a0c8e27a9d454cc150997c9
        id: 5a0c8e2aa9d454cc1509a142
        links:
          self: /pub/calendar_event/5a0c8e2aa9d454cc1509a142
        relationships:
          owner:
            data:
              id: 5a0c8e27a9d454cc150997f7
              type: patient
            links:
              related: /pub/calendar_event/5a0c8e2aa9d454cc1509a142/owner
        type: calendar_event
      properties:
        attributes:
          properties:
            all_day:
              description: True if the calendar event is an all day event, false otherwise. Must be set to true for `plan-check-in` event type. If it is true, then `start_at` and `end_at` must also be set to beginning of day, except `plan-check-in` event type does not need an `end_at` date. If it is false, then `start_at` and `end_at` must be on the same day.
              type: boolean
            attendees:
              description: List of attendees for the calendar event
              items:
                properties:
                  response_status:
                    description: Status of responses from attendees
                    enum:
                      - needsAction
                      - declined
                      - tentative
                      - accepted
                    type: string
                  user:
                    type: string
                type: object
              type: array
            completed_at:
              description: The date and time when the calendar event is marked as completed. Only valid for `plan-check-in` event type.
              example: 2017-11-03T06:17:34.652Z
              format: ISODate
              type: string
            completed_by:
              description: The coach who marked the calendar event as completed. Only valid for `plan-check-in` event type.
              type: object
            description:
              type: string
            end_at:
              description: The date and time when the calendar event ends. Not valid for `plan-check-in` event type.
              example: 2017-11-03T08:00:00.000Z
              format: ISODate
              type: string
            location:
              type: string
            start_at:
              description: The date and time when the calendar event starts
              example: 2017-11-03T04:00:00.000Z
              format: ISODate
              type: string
            time_zone:
              description: The time zone in which the dates for the calendar event are specified
              example: America/New_York
              type: string
            title:
              description: The title of the calendar event. Must not be empty or null
              type: string
            type:
              description: The type of calendar event. Immutable after event creation.
              enum:
                - plan-check-in
                - reminder
                - telephone-call
                - office-visit
                - video-call
              type: string
          type: object
        id:
          type: string
        links:
          properties:
            self:
              example: /calendar_event/5a0c8e2aa9d454cc1509a142
              pattern: /calendar_event/[0-9a-z]+
              type: string
          type: object
        relationships:
          properties:
            owner:
              description: The owner is the patient for whom the calendar event is created specificially for
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    related:
                      example: /pub/calendar_event/5a0c8e2aa9d454cc1509a142/owner
                      pattern: /pub/calendar_event/[0-9a-z]+
                      type: string
                  type: object
              required:
                - data
              type: object
          type: object
        type:
          enum:
            - calendar_event
          type: string
      type: object
    CalendarEventResponseResource:
      example:
        attributes:
          attendee: 5ac7e74679f6868274a42e28
          response_status: accepted
        id: 5ad0f966ceb0909e4bfa84dd
        links:
          self: /pub/calendar_event_response/5ad0f966ceb0909e4bfa84dd
        relationships:
          calendar_event:
            data:
              id: 5755db2a3db4179179999acf
              type: calendar_event
            links:
              related: /pub/calendar_event_response/5ad0f966ceb0909e4bfa84dd/calendar_event
          user:
            data:
              id: 5a0c8e27a9d454cc150997f7
              type: user
            links:
              related: /pub/calendar_event_response/5ad0f966ceb0909e4bfa84dd/user
        type: calendar_event_response
      properties:
        attributes:
          properties:
            attendee:
              description: The attendee in the attendees list of the calendar event.
              type: object
            response_status:
              description: The response status for the attendee.
              enum:
                - accepted
                - declined
                - tentative
              type: string
          type: object
        id:
          type: string
        links:
          properties:
            self:
              example: /calendar_event_response/5ad0f966ceb0909e4bfa84dd
              pattern: /calendar_event_response/[0-9a-z]+
              type: string
          type: object
        relationships:
          properties:
            calendar_event:
              description: The calendar_event is the calendar event for which the calendar event response is created specificially for
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    related:
                      example: /pub/calendar_event_response/5ad0f966ceb0909e4bfa84dd/calendar_event
                      pattern: /pub/calendar_event_response/[0-9a-z]+
                      type: string
                  type: object
              required:
                - data
              type: object
            user:
              description: The user is the coach or patient for whom the calendar event response is created specificially for
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    related:
                      example: /pub/calendar_event_response/5ad0f966ceb0909e4bfa84dd/user
                      pattern: /pub/calendar_event_response/[0-9a-z]+
                      type: string
                  type: object
              required:
                - data
              type: object
          type: object
        type:
          enum:
            - calendar_event_response
          type: string
      type: object
    CoachResource:
      properties:
        attributes:
          properties:
            first_name:
              example: Clarisa
              type: string
            last_name:
              example: Rivera
              type: string
          type: object
        id:
          example: 57b36e3c04ad8c2224f2af38
          type: string
        links:
          properties:
            self:
              example: /coach/57b36e3c04ad8c2224f2af38
              pattern: /coach/[0-9a-z]+
              type: string
          readOnly: true
          required:
            - self
          type: object
        type:
          enum:
            - coach
          example: coach
          type: string
      required:
        - id
        - type
        - attributes
      type: object
    CollectionResponseLinks:
      properties:
        last:
          type: string
        next:
          type: string
        prev:
          type: string
        self:
          type: string
      type: object
    CreateActionRequest:
      example:
        data:
          attributes:
            effective_from: 2017-02-20T11:12:13.000Z
            frequency_goal:
              weeks:
                days:
                  - 0
            metrics:
              - goal:
                  data:
                    diastolic:
                      unit: mmHg
                      value: 95
                    systolic:
                      unit: mmHg
                      value: 150
                metric_type: blood_pressure
                unit: mmHg
            title: Record Blood Pressure
            type: blood_pressure
          relationships:
            bundles:
              data:
                - id: 58aacf0d076adcef394bac30
                  type: bundle
            plan:
              data:
                id: 58aacf0d076adcef394bac35
                type: patient_plan_summary
          type: action
      properties:
        data:
          $ref: "#/components/schemas/ActionResource"
      required:
        - data
      type: object
    CreateActionResponse:
      example:
        data:
          attributes:
            _thread: blood_pressure
            adherence:
              complete: 0
              due: 0
              streak:
                count: 0
            created_at: 2017-02-20T11:12:13.000Z
            created_by: 596541ec076adcef394bac2d
            effective_from: 2017-02-20T11:12:13.000Z
            frequency_goal:
              weeks:
                days:
                  - 0
            frequency_goal_prorated: 0
            identifiers: []
            metric_required: false
            metrics:
              - _id: 58aacf0d076adcef394bac37
                accepted_values: []
                goal:
                  data:
                    diastolic:
                      unit: mmHg
                      value: 95
                    systolic:
                      unit: mmHg
                      value: 150
                metric_type: blood_pressure
                unit: mmHg
            options: []
            title: Record Blood Pressure
            tracking: true
            type: blood_pressure
            updated_at: 2017-02-20T11:12:13.000Z
            updated_by: 596541ec076adcef394bac2d
            windows: []
          id: 58aacf0d076adcef394bac36
          links:
            self: /action/58aacf0d076adcef394bac36
          relationships:
            bundles:
              data:
                - id: 58aacf0d076adcef394bac30
                  type: bundle
              links:
                related: /action/58aacf0d076adcef394bac36/bundles
            plan:
              data:
                id: 58aacf0d076adcef394bac35
                type: patient_plan_summary
              links:
                related: /action/58aacf0d076adcef394bac36/plan
          type: action
        included: []
        meta:
          req_id: 014ea6d2-4717-4915-b4bc-98454180614e
      properties:
        data:
          $ref: "#/components/schemas/ActionResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateBundleRequest:
      properties:
        data:
          $ref: "#/components/schemas/BundleResource"
      required:
        - data
      type: object
    CreateBundleResponse:
      properties:
        data:
          $ref: "#/components/schemas/BundleResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateCalendarEventRequest:
      example:
        data:
          attributes:
            all_day: true
            attendees:
              - user: 5a0c8e27a9d454cc150997c9
              - user: 5a0c8e27a9d454cc150997f7
            start_at: 2018-02-20T00:00:00Z
            time_zone: America/New_York
            title: Plan Check-In
            type: plan-check-in
          relationships:
            owner:
              data:
                id: 5a0c8e27a9d454cc150997f7
                type: patient
          type: calendar_event
      properties:
        data:
          properties:
            attributes:
              allOf:
                - $ref: "#/components/schemas/CalendarEventResource/properties/attributes"
              required:
                - type
                - start_at
                - title
                - attendees
            relationships:
              properties:
                owner:
                  properties:
                    data:
                      $ref: "#/components/schemas/CalendarEventResource/properties/relationships/properties/owner/properties/data"
                  required:
                    - data
                  type: object
              type: object
            type:
              $ref: "#/components/schemas/CalendarEventResource/properties/type"
          required:
            - type
            - attributes
            - relationships
          type: object
      required:
        - data
      type: object
    CreateCalendarEventResponse:
      properties:
        data:
          $ref: "#/components/schemas/CalendarEventResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      type: object
    CreateCalendarEventResponseRequest:
      example:
        data:
          attributes:
            attendee: 5ac7e74679f6868274a42e28
            response_status: accepted
          relationships:
            calendar_event:
              data:
                id: 5755db2a3db4179179999acf
                type: calendar_event
            user:
              data:
                id: 5a0c8e27a9d454cc150997f7
                type: user
          type: calendar_event_response
      properties:
        data:
          properties:
            attributes:
              allOf:
                - $ref: "#/components/schemas/CalendarEventResponseResource/properties/attributes"
              required:
                - attendee
                - response_status
            relationships:
              properties:
                calendar_event:
                  properties:
                    data:
                      $ref: "#/components/schemas/CalendarEventResponseResource/properties/relationships/properties/calendar_event/properties/data"
                  required:
                    - data
                  type: object
                user:
                  properties:
                    data:
                      $ref: "#/components/schemas/CalendarEventResponseResource/properties/relationships/properties/user/properties/data"
                  required:
                    - data
                  type: object
              type: object
            type:
              $ref: "#/components/schemas/CalendarEventResponseResource/properties/type"
          required:
            - type
            - attributes
            - relationships
          type: object
      required:
        - data
      type: object
    CreateGroupRequest:
      example:
        data:
          attributes:
            name: New Group
          type: group
      properties:
        data:
          $ref: "#/components/schemas/GroupResource"
      required:
        - data
      type: object
    CreateGroupResponse:
      example:
        data:
          attributes:
            name: New Group
          id: 5817acae6f5316c0d05ba8b8
          links:
            self: /pub/group/5817acae6f5316c0d05ba8b8
          type: group
        meta:
          req_id: 6ac6d0f2-00b2-4031-8c35-97b2bfb0aced
      properties:
        data:
          $ref: "#/components/schemas/GroupResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateOrUpdateErrorResponse:
      example:
        errors:
          - code: Unauthorized
            detail: A valid bearer token is required
            status: "401"
        meta:
          req_id: d07c8b12-c95e-4a06-8424-92aac94bb445
      properties:
        errors:
          $ref: "#/components/schemas/Error"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      type: object
    CreateOrUpdateMetaResponse:
      properties:
        ignored:
          items:
            type: string
          type: array
        req_id:
          type: string
      type: object
    CreatePatientHealthMetricRequest:
      properties:
        data:
          $ref: "#/components/schemas/PatientHealthMetricCreateResource"
        meta:
          properties:
            ignore_duplicates:
              description: |
                If `true`, the patient health metric will be ignored if there is an existing patient health metric for
                the same patient, with the same `type` and same `occurred_at`.
              type: boolean
          type: object
      required:
        - data
      type: object
    CreatePatientHealthMetricResponse:
      properties:
        data:
          $ref: "#/components/schemas/PatientHealthMetricResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreatePatientRequest:
      example:
        data:
          attributes:
            first_name: Jack
            last_name: Frost
          relationships:
            groups:
              data:
                - id: 5755db2a3db4179179999acf
                  type: group
          type: patient
      properties:
        data:
          $ref: "#/components/schemas/PatientCreateResource"
        meta:
          properties:
            ignore_duplicates:
              default: false
              description: |
                If `true`, patients with any conflicting identifiers (same `system` and `value`) will be ignored.
                Useful for gracefully skipping duplicates after errors occur during bulk create.
              type: boolean
          type: object
      required:
        - data
      type: object
    CreatePatientResponse:
      example:
        data:
          attributes:
            addresses: []
            archive_history: []
            archived: false
            first_name: Jack
            identifiers: []
            last_name: Frost
            phone_numbers: []
            updated_at: 2016-11-01T01:07:33.121Z
          id: 5817ead56f5316c0d05ba8bf
          links:
            self: /pub/patient/5817ead56f5316c0d05ba8bf
            twine_web_app: http://10.0.1.55:9000/#/coach/patient/5817ead56f5316c0d05ba8bf
          relationships:
            coaches:
              data: []
              links:
                related: /pub/patient/5817ead56f5316c0d05ba8bf/coaches
            groups:
              data:
                - id: 5755db2a3db4179179999acf
                  type: group
              links:
                related: /pub/patient/5817ead56f5316c0d05ba8bf/groups
          type: patient
        included: []
        meta:
          req_id: 5b813ad3-cabc-418f-add4-1e53bc69f7cb
      properties:
        data:
          $ref: "#/components/schemas/PatientResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateRewardEarningFulfillmentRequest:
      properties:
        data:
          $ref: "#/components/schemas/RewardEarningFulfillmentResource"
      required:
        - data
      type: object
    CreateRewardEarningFulfillmentResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardEarningFulfillmentResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateRewardEarningRequest:
      properties:
        data:
          $ref: "#/components/schemas/RewardEarningResource"
      required:
        - data
      type: object
    CreateRewardEarningResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardEarningResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateRewardProgramActivationRequest:
      properties:
        data:
          $ref: "#/components/schemas/RewardProgramActivationResource"
      required:
        - data
      type: object
    CreateRewardProgramActivationResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardProgramActivationResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateRewardProgramRequest:
      properties:
        data:
          $ref: "#/components/schemas/RewardProgramResource"
      required:
        - data
      type: object
    CreateRewardProgramResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardProgramResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateRewardRequest:
      properties:
        data:
          $ref: "#/components/schemas/RewardResource"
      required:
        - data
      type: object
    CreateRewardResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    CreateTokenRequest:
      example:
        data:
          attributes:
            client_id: 95c78ab2-167f-40b8-8bec-8398d4b87454
            client_secret: 35d18dc9-a3dd-4948-b787-063a490b9354
            grant_type: client_credentials
          type: oauth/token
      properties:
        data:
          properties:
            attributes:
              properties:
                client_id:
                  description: Contact Fitbit Plus API Support to get a client id and secret.
                  example: 19391dc5-8af8-4152-93e8-74ff9361607e
                  type: string
                client_secret:
                  description: Contact Fitbit Plus API Support to get a client id and secret. Secret is required if grant_type is "client_credentials"
                  example: 63eca384-7a65-42e2-872b-afd3e8659d0a
                  type: string
                grant_type:
                  enum:
                    - refresh_token
                    - client_credentials
                  example: client_credentials
                  type: string
                refresh_token:
                  description: Required if grant_type is "refresh_token"
                  example: b7dcc4a4-593b-4410-a0c5-97ae48939396
                  type: string
              required:
                - client_id
                - grant_type
              type: object
            type:
              enum:
                - token
              example: token
              type: string
          required:
            - attributes
          type: object
      required:
        - data
      type: object
    CreateTokenResponse:
      example:
        data:
          attributes:
            access_token: c1b83534-76c1-4a27-b1d4-8140e24dd7c6
            expires_in: 3601
            refresh_token: a38d192a-76fd-4b1d-954c-893c9d29c8f4
            token_type: bearer
          id: 5817a24d678a7c2cbf5df3ee
          relationships:
            groups:
              data:
                - id: 5755db2a3db4179179999acf
                  type: group
              links:
                related: /pub/oauth/token/5817a24d678a7c2cbf5df3ee/groups
          type: oauth/token
        meta:
          req_id: 2de51f1a-bafa-4e48-a0d0-cd8d4a9ffb28
      properties:
        data:
          $ref: "#/components/schemas/TokenResource"
        included:
          items:
            $ref: "#/components/schemas/GroupResource"
          type: array
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    EmailHistoryResource:
      example:
        attributes:
          created_at: 2017-07-07T19:15:56.229Z
          created_by: 595fd88ef4be5b1a797ff19b
          email_address: tony@example.com
          email_type: invite
          send_time: 2017-02-25T13:35:01.000Z
          status_times:
            delivered: 2017-02-25T13:35:03.000Z
            open: 2017-02-25T14:20:00.000Z
            processed: 2017-02-25T13:35:02.000Z
          twine_email_id: 576226e5-7e25-4469-b10d-2bc6a725bfbc
          updated_at: 2017-07-07T19:15:56.229Z
          updated_by: 595fd88ef4be5b1a797ff19b
        id: 595fddec28c5041b84467592
        links:
          self: /pub/email_history/595fddec28c5041b84467592
        relationships:
          receiver:
            data:
              id: 595fddea28c5041b84466bbe
              type: patient
            links:
              related: /pub/email_history/595fddec28c5041b84467592/receiver
          sender:
            links:
              related: /pub/email_history/595fddec28c5041b84467592/sender
        type: email_history
      properties:
        attributes:
          properties:
            email_address:
              description: Address email was sent to.
              type: string
            email_type:
              description: Type of email.
              type: string
            send_time:
              description: Time email was sent.
              format: dateTime
              type: string
            status_times:
              description: Status of email. Multiple statuses may be defined. The current status is the one with the most recent date.
              properties:
                bounce:
                  description: Time email was bounced.
                  format: dateTime
                  type: string
                click:
                  description: Time email was clicked.
                  format: dateTime
                  type: string
                deferred:
                  description: Time email was deferred.
                  format: dateTime
                  type: string
                delivered:
                  description: Time email was delivered.
                  format: dateTime
                  type: string
                dropped:
                  description: Time email was dropped.
                  format: dateTime
                  type: string
                open:
                  description: Time email was opened.
                  format: dateTime
                  type: string
                processed:
                  description: Time email was processed.
                  format: dateTime
                  type: string
                spamreport:
                  description: Time email was reported as spam.
                  format: dateTime
                  type: string
                unsubscribe:
                  description: Time email was unsubscribed from.
                  format: dateTime
                  type: string
              type: object
            twine_email_id:
              description: Unique identifier for this email.
              type: string
          type: object
        id:
          type: string
        relationships:
          properties:
            receiver:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
            sender:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
          type: object
        type:
          type: string
      required:
        - type
      type: object
    Error:
      properties:
        code:
          enum:
            - Forbidden
            - InvalidParameter
            - InvalidBodyParameter
            - ResourceNotFound
            - Unauthorized
            - InvalidCredentials
            - InvalidGrantType
          type: string
        detail:
          type: string
        source:
          properties:
            parameter:
              type: string
            pointer:
              type: string
          type: object
        status:
          type: string
        title:
          type: string
      type: object
    FetchActionResponse:
      example:
        data:
          attributes:
            _thread: weight
            adherence:
              complete: 1
              due: 1
              streak:
                count: 1
                updated_at: 2017-07-11T21:13:13.215Z
            details:
              some: mixed value
            effective_from: 2017-07-10T21:13:13.212Z
            effective_to: 2017-07-11T21:13:13.215Z
            frequency_goal:
              weeks:
                days:
                  - 0
            frequency_goal_prorated: 0
            identifiers:
              - _id: 59653f699fc8be3938f04494
                label: Super Health Actions
                system: http://super.health.example.com
                value: action-0123
            metric_required: true
            metrics:
              - _id: 59653f699fc8be3938f04493
                accepted_values: []
                goal:
                  data:
                    unit: lb
                    value: 210
                metric_type: weight
                unit: lb
                validations:
                  maximum:
                    unit: lb
                    value: 999
                  minimum:
                    unit: lb
                    value: 0
            options: []
            title: Measure Weight
            tracking: true
            type: weight
            windows:
              - _id: 59653f699fc8be3938f04492
                title: Morning
                type: morning
          id: 59653f699fc8be3938f04491
          links:
            self: /action/59653f699fc8be3938f04491
          relationships:
            bundles:
              data: []
              links:
                related: /action/59653f699fc8be3938f04491/bundles
            plan:
              links:
                related: /action/59653f699fc8be3938f04491/plan
          type: action
        included: []
        meta:
          req_id: 63bf4340-f256-400e-b391-d801d2a251f6
      properties:
        data:
          $ref: "#/components/schemas/ActionResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchBundleResponse:
      example:
        data:
          attributes:
            _actions:
              - 596535d9608f63d531b7e344
            _thread: "123"
            effective_from: 2017-07-11T20:31:25.000Z
            effective_to: 2017-07-11T20:32:25.000Z
            title: Weight
            type: weight
          id: 596535d9608f63d531b7e34a
          links:
            self: /bundle/596535d9608f63d531b7e34a
          relationships:
            actions:
              data:
                - id: 596535d9608f63d531b7e344
                  type: action
              links:
                related: /bundle/596535d9608f63d531b7e34a/actions
            plan:
              links:
                related: /bundle/596535d9608f63d531b7e34a/plan
          type: bundle
        included: []
        meta:
          req_id: c0f8d53a-d763-4beb-b0b1-9ec6da146a14
      properties:
        data:
          $ref: "#/components/schemas/BundleResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchCalendarEventResponse:
      properties:
        data:
          $ref: "#/components/schemas/CalendarEventResource"
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [patient](#operation/fetchPatient)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      type: object
    FetchCalendarEventsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/CalendarEventResource"
          type: array
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [patient](#operation/fetchPatient)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      type: object
    FetchCoachResponse:
      example:
        data:
          attributes:
            first_name: Clarisa
            last_name: Rivera
          id: 581630c3237d84a9403533c6
          links:
            self: /pub/coach/581630c3237d84a9403533c6
          type: coach
        included: []
        meta:
          req_id: b928037e-98ed-434f-b0c4-d74b1a38a560
      properties:
        data:
          $ref: "#/components/schemas/CoachResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchCoachesResponse:
      example:
        data:
          - attributes:
              first_name: Clarisa
              last_name: Rivera
            id: 581630c3237d84a9403533c6
            links:
              self: /pub/coach/581630c3237d84a9403533c6
            type: coach
        included: []
        links:
          self: /pub/patient/58163112237d84a94035f78b/coaches
        meta:
          count: 1
          req_id: 48c47326-0c8b-4c5e-85da-7fc0d00f1e4d
      properties:
        data:
          items:
            $ref: "#/components/schemas/CoachResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchEmailHistoriesResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/EmailHistoryResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchEmailHistoryResponse:
      properties:
        data:
          $ref: "#/components/schemas/EmailHistoryResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchErrorResponse:
      example:
        errors:
          - code: Unauthorized
            detail: A valid bearer token is required
            status: "401"
        meta:
          req_id: d07c8b12-c95e-4a06-8424-92aac94bb445
      properties:
        errors:
          $ref: "#/components/schemas/Error"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      type: object
    FetchGroupResponse:
      example:
        data:
          attributes:
            name: Patients Lead
          id: 5755db2a3db4179179999acf
          links:
            self: /pub/group/5755db2a3db4179179999acf
          type: group
        meta:
          req_id: 2b59851e-0f6c-4a8f-a8a6-15bd7c0346e7
      properties:
        data:
          $ref: "#/components/schemas/GroupResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchGroupsResponse:
      example:
        data:
          - attributes:
              name: Patients Lead
            id: 5755db2a3db4179179999acf
            links:
              self: /pub/group/5755db2a3db4179179999acf
            type: group
        links:
          self: /pub/oauth/token/5817a24d678a7c2cbf5df3ee/groups
        meta:
          count: 1
          req_id: ab554093-6081-4d37-aa7b-ca6312367ca4
      properties:
        data:
          items:
            $ref: "#/components/schemas/GroupResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthProfileAnswerResponse:
      properties:
        data:
          $ref: "#/components/schemas/HealthProfileAnswerResource"
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [patient](#operation/fetchPatient)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthProfileAnswersResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/HealthProfileAnswerResource"
          type: array
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [patient](#operation/fetchPatient)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthProfileQuestionResponse:
      properties:
        data:
          $ref: "#/components/schemas/HealthProfileQuestionResource"
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [question_definition](#operation/fetchHealthQuestionDefinition), [answer](#operation/fetchHealthProfileAnswer)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthProfileQuestionsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/HealthProfileQuestionResource"
          type: array
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [question_definition](#operation/fetchHealthQuestionDefinition), [answer](#operation/fetchHealthProfileAnswer)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthProfileResponse:
      properties:
        data:
          $ref: "#/components/schemas/HealthProfileResource"
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [patient](#operation/fetchPatient), [question](#operation/fetchHealthProfileQuestion)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthProfilesResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/HealthProfileResource"
          type: array
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [patient](#operation/fetchPatient), [question](#operation/fetchHealthProfileQuestion)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthQuestionDefinitionResponse:
      properties:
        data:
          $ref: "#/components/schemas/HealthQuestionDefinitionResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchHealthQuestionDefinitionsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/HealthQuestionDefinitionResource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchMetaResponse:
      properties:
        count:
          type: integer
        req_id:
          type: string
      type: object
    FetchOrganizationResponse:
      example:
        data:
          attributes:
            name: Health Activation Partners
          id: 5873b63605376e337a89d64a
          links:
            self: /pub/organization/5873b63605376e337a89d64a
          type: organization
        meta:
          req_id: aeb94ed8-d7f9-4e72-a78f-e276c4f52c2a
      properties:
        data:
          $ref: "#/components/schemas/OrganizationResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchPatientHealthMetricResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/PatientHealthMetricResource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchPatientHealthResultResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/PatientHealthResultResource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchPatientPlanSummariesResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/PatientPlanSummaryResource"
          type: array
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [action](#operation/fetchAction), [bundle](#operation/fetchBundle) and [patient](#operation/fetchPatient)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchPatientPlanSummaryResponse:
      example:
        data:
          attributes:
            adherence:
              complete: 0
              due: 0
              streak:
                count: 0
            critical:
              blood_glucose:
                data:
                  maximum:
                    unit: mg/dL
                    value: 300
                  minimum:
                    unit: mg/dL
                    value: 70
              effective_from: 2017-07-01T04:00:00.000Z
            effective_from: 2017-07-01T04:00:00.000Z
            window_notification_times:
              afternoon: 43200
              evening: 64800
              morning: 25200
              night: 75600
            window_order: []
          id: 5964f831f65725bf25558b50
          links:
            self: /patient_plan_summary/5964f831f65725bf25558b50
          relationships:
            actions:
              data:
                - id: 5964f831f65725bf25558b4b
                  type: action
              links:
                related: /patient_plan_summary/5964f831f65725bf25558b50/actions
            bundles:
              data: []
              links:
                related: /patient_plan_summary/5964f831f65725bf25558b50/bundles
            current_results:
              data: []
              links:
                related: /patient_plan_summary/5964f831f65725bf25558b50/current_results
            patient:
              data:
                id: 5964f831f65725bf25558b4f
                type: patient
              links:
                related: /patient_plan_summary/5964f831f65725bf25558b50/patient
          type: patient_plan_summary
        included:
          - attributes:
              _thread: blood_pressure
              adherence:
                complete: 0
                due: 0
                streak:
                  count: 0
              effective_from: 2017-07-01T04:00:00.000Z
              frequency_goal:
                weeks:
                  days:
                    - 0
                    - 1
                    - 2
                    - 3
                    - 4
                    - 5
                    - 6
              frequency_goal_prorated: 0
              identifiers: []
              metric_required: false
              metrics:
                - _id: 5964f831f65725bf25558b51
                  accepted_values: []
                  goal:
                    data:
                      diastolic:
                        unit: mmHg
                        value: 95
                      systolic:
                        unit: mmHg
                        value: 150
                  metric_type: blood_pressure
                  unit: mmHg
              options: []
              title: Record Blood Pressure
              tracking: true
              type: blood_pressure
              windows: []
            id: 5964f831f65725bf25558b4b
            links:
              self: /action/5964f831f65725bf25558b4b
            relationships:
              bundles:
                data: []
                links:
                  related: /action/5964f831f65725bf25558b4b/bundles
              plan:
                links:
                  related: /action/5964f831f65725bf25558b4b/plan
            type: action
        meta:
          req_id: e0e78ef5-c0fd-415b-9b9f-a1b5c77c1198
      properties:
        data:
          $ref: "#/components/schemas/PatientPlanSummaryResource"
        included:
          description: |
            Related resources which are included in the response based on the `include` param.
            Attributes of each resource will vary depending on the type.
            See [action](#operation/fetchAction), [bundle](#operation/fetchBundle) and [patient](#operation/fetchPatient)
          items:
            $ref: "#/components/schemas/Resource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchPatientResponse:
      example:
        data:
          attributes:
            addresses: []
            archive_history: []
            archived: false
            birth_date: 1938-10-04
            first_name: Lucy
            identifiers:
              - label: Fitbit Plus Sample Data Filler Patient
                system: twine-filler-patient
                value: filler-92
            last_name: Bernhard
            phone_numbers:
              - primary: true
                value: 880-136-7979 x6183
              - primary: false
                value: 919.814.3552 x40123
            statement:
              updated_at: 2016-03-16T13:32:57.000Z
              updated_by: 5c509cc2f60e34018180b57c
              value: Enjoying nature.
            updated_at: 2016-03-16T13:32:57.000Z
          id: 58163112237d84a94035f78b
          links:
            self: /pub/patient/58163112237d84a94035f78b
            twine_web_app: http://10.0.1.55:9000/#/coach/admin/coaches/58163112237d84a94035f78b/profile
          relationships:
            coaches:
              data:
                - id: 581630c3237d84a9403533c6
                  meta:
                    primary: true
                  type: coach
              links:
                related: /pub/patient/58163112237d84a94035f78b/coaches
            groups:
              data:
                - id: 5755db2a3db4179179999acf
                  type: group
              links:
                related: /pub/patient/58163112237d84a94035f78b/groups
          type: patient
        included: []
        meta:
          req_id: 23001d51-669b-4948-b9fa-11dbffdf8ced
      properties:
        data:
          $ref: "#/components/schemas/PatientResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchPatientsResponse:
      example:
        data:
          - attributes:
              addresses: []
              archive_history: []
              archived: false
              birth_date: 1938-10-04
              first_name: Lucy
              identifiers:
                - label: Fitbit Plus Sample Data Filler Patient
                  system: twine-filler-patient
                  value: filler-92
              last_name: Bernhard
              phone_numbers:
                - primary: true
                  value: 880-136-7979 x6183
                - primary: false
                  value: 919.814.3552 x40123
              statement:
                updated_at: 2016-03-16T13:32:57.000Z
                updated_by: 5c509cc2f60e34018180b57c
                value: Enjoying nature.
              updated_at: 2016-03-16T13:32:57.000Z
            id: 58163112237d84a94035f78b
            links:
              self: /pub/patient/58163112237d84a94035f78b
              twine_web_app: http://10.0.1.55:9000/#/coach/admin/coaches/58163112237d84a94035f78b/profile
            relationships:
              coaches:
                data:
                  - id: 581630c3237d84a9403533c6
                    meta:
                      primary: true
                    type: coach
                links:
                  related: /pub/patient/58163112237d84a94035f78b/coaches
              groups:
                data:
                  - id: 5755db2a3db4179179999acf
                    type: group
                links:
                  related: /pub/patient/58163112237d84a94035f78b/groups
            type: patient
          - attributes:
              addresses: []
              birth_date: 1983-03-16
              email_address: annette.parisian@example.com
              first_name: Annette
              identifiers:
                - label: Fitbit Plus Sample Data Filler Patient
                  system: twine-filler-patient
                  value: filler-5
              last_name: Parisian
              phone_numbers:
                - primary: true
                  value: 044.758.5704 x1965
              updated_at: 2016-02-04T12:55:03.000Z
            id: 58163103237d84a94035f0b3
            links:
              self: /pub/patient/58163103237d84a94035f0b3
              twine_web_app: http://10.0.1.55:9000/#/coach/admin/coaches/58163103237d84a94035f0b3/profile
            relationships:
              coaches:
                data:
                  - id: 581630c3237d84a9403533c6
                    meta:
                      primary: true
                    type: coach
                links:
                  related: /pub/patient/58163103237d84a94035f0b3/coaches
              groups:
                data:
                  - id: 5755db2a3db4179179999acf
                    type: group
                links:
                  related: /pub/patient/58163103237d84a94035f0b3/groups
            type: patient
          - attributes:
              addresses: []
              birth_date: 1932-04-06
              email_address: lexi.thompson@example.com
              first_name: Lexi
              identifiers:
                - label: Fitbit Plus Sample Data Filler Patient
                  system: twine-filler-patient
                  value: filler-3
              last_name: Thompson
              phone_numbers:
                - primary: true
                  value: 1-977-830-6179 x26334
              updated_at: 2016-01-23T16:12:07.000Z
            id: 58163103237d84a94035f043
            links:
              self: /pub/patient/58163103237d84a94035f043
              twine_web_app: http://10.0.1.55:9000/#/coach/admin/coaches/58163103237d84a94035f043/profile
            relationships:
              coaches:
                data:
                  - id: 581630c3237d84a9403533c6
                    meta:
                      primary: true
                    type: coach
                links:
                  related: /pub/patient/58163103237d84a94035f043/coaches
              groups:
                data:
                  - id: 5755db2a3db4179179999acf
                    type: group
                links:
                  related: /pub/patient/58163103237d84a94035f043/groups
            type: patient
        links:
          last: /pub/patient?filter[groups]=5755db2a3db4179179999acf&page[number]=88&page[size]=3
          next: /pub/patient?filter[groups]=5755db2a3db4179179999acf&page[number]=2&page[size]=3
          self: /pub/patient?filter[groups]=5755db2a3db4179179999acf&page[number]=1&page[size]=3
        meta:
          count: 263
          req_id: 155c690b-50b2-4ff2-8abe-b809a8a51e53
      properties:
        data:
          items:
            $ref: "#/components/schemas/PatientResource"
          type: array
        links:
          $ref: "#/components/schemas/CollectionResponseLinks"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardEarningFulfillmentResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardEarningFulfillmentResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardEarningFulfillmentsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/RewardEarningFulfillmentResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardEarningResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardEarningResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardEarningsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/RewardEarningResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardProgramActivationResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardProgramActivationResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardProgramActivationsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/RewardProgramActivationResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardProgramResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardProgramResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardProgramsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/RewardProgramResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardResponse:
      properties:
        data:
          $ref: "#/components/schemas/RewardResource"
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    FetchRewardsResponse:
      properties:
        data:
          items:
            $ref: "#/components/schemas/RewardResource"
          type: array
        meta:
          $ref: "#/components/schemas/FetchMetaResponse"
      required:
        - data
      type: object
    GroupResource:
      properties:
        attributes:
          properties:
            bio:
              description: A description of the group
              example: Team Health is all about the patient experience.
              type: string
            name:
              description: The name of the group
              example: Team Health
              type: string
          required:
            - name
          type: object
        id:
          example: 57b36e3c04ad8c2224f2af38
          type: string
        links:
          properties:
            self:
              example: /group/57b36e3c04ad8c2224f2af38
              pattern: /group/[0-9a-z]+
              type: string
          readOnly: true
          required:
            - self
          type: object
        type:
          enum:
            - group
          example: group
          type: string
      required:
        - id
        - type
        - attributes
      type: object
    HealthProfileAnswerResource:
      example:
        attributes:
          created_at: 2017-07-07T19:15:56.229Z
          history:
            - _created_by: 59d4d7dcd843ee01be71fcf8
              _id: 59d4d7dcd843ee01be71fcfb
              answered_at: 2017-10-03T12:45:16.720Z
              value: "2"
          latest:
            _created_by: 59d4d7dcd843ee01be71fcf8
            answered_at: 2017-10-04T12:45:16.720Z
            value: "1"
          question_id: "4"
          updated_at: 2017-07-07T19:15:56.229Z
        id: 59d441ac21741161bbe266b5
        links:
          self: /pub/health_profile_answer/59d441ac21741161bbe266b5
        relationships:
          patient:
            data:
              id: 595fddea28c5041b84466bbe
              type: patient
            links:
              related: /pub/health_profile_answer/59d441ac21741161bbe266b5/patient
        type: health_profile_answer
      properties:
        attributes:
          properties:
            history:
              description: List of details of previous answers for a health profile question
              items:
                description: The details of a previous answer for a health profile question
                properties:
                  _created_by:
                    description: The id of the patient or coach who answered the health profile question
                    type: string
                  answered_at:
                    description: The date when the health profile question is answered
                    format: dateTime
                    type: string
                  value:
                    description: The value of the answer entered for the health profile question
                    type: string
                type: object
              type: array
            latest:
              description: The details of the latest answer for a health profile question
              properties:
                _created_by:
                  description: The id of the patient or coach who answered the health profile question
                  type: string
                answered_at:
                  description: The date when the health profile question is answered
                  format: dateTime
                  type: string
                value:
                  description: The value of the answer entered for the health profile question
                  type: string
              type: object
            question_id:
              type: string
          type: object
        id:
          type: string
        links:
          properties:
            self:
              example: /health_profile_answer/59d441ac21741161bbe266b5
              pattern: /health_profile_answer/[0-9a-z]+
              type: string
          readOnly: true
          required:
            - self
          type: object
        relationships:
          properties:
            patient:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    related:
                      example: /pub/health_profile_answer/59d441ac21741161bbe266b5/patient
                      pattern: /pub/health_profile_answer/[0-9a-z]+
                      type: string
                  readOnly: true
                  type: object
              readOnly: true
              type: object
          type: object
        type:
          type: string
      required:
        - type
        - id
      type: object
    HealthProfileQuestionResource:
      example:
        attribute: {}
        id: 52b36e3c04ad8c2224f2aa67
        links:
          self: /pub/health_profile_question/59d435931d078505ba744e88
        relationships:
          answer:
            data:
              id: 595fddea28c5041b84466bbe
              type: health_profile_answer
            links:
              related: /pub/health_profile_question/59d435931d078505ba744e88/answer
          profile:
            links:
              related: /pub/health_profile_question/59d435931d078505ba744e88/profile
          question_definition:
            data:
              id: "4"
              type: health_question_definition
            links:
              related: /pub/health_profile_question/59d435931d078505ba744e88/question_definition
        type: health_profile_question
      properties:
        attributes:
          description: |
            A health profile question does not have any attribute since it only relates an answer to the corresponding question definition.
          type: object
        id:
          type: string
        links:
          properties:
            self:
              example: /pub/health_profile_question/59d435931d078505ba744e88
              pattern: /pub/health_profile_question/[0-9a-z]+
              type: string
          readOnly: true
          required:
            - self
          type: object
        relationships:
          properties:
            answer:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    related:
                      example: /pub/health_profile_question/59d435931d078505ba744e88/answer
                      pattern: /pub/health_profile_question/[0-9a-z]+/answer
                      type: string
                  readOnly: true
                  type: object
              type: object
            profile:
              properties:
                links:
                  properties:
                    related:
                      example: /pub/health_profile_question/59d435931d078505ba744e88/profile
                      pattern: /pub/health_profile_question/[0-9a-z]+/profile
                      type: string
                  readOnly: true
                  type: object
              type: object
            question_definition:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    links:
                      properties:
                        related:
                          example: /pub/health_profile_question/59d435931d078505ba744e88/question_definition
                          pattern: /pub/health_profile_question/[0-9a-z]+/question_definition
                          type: string
                      readOnly: true
                      type: object
                  readOnly: true
              type: object
          type: object
        type:
          type: string
      required:
        - type
        - id
      type: object
    HealthProfileResource:
      example:
        attributes:
          created_at: 2017-07-07T19:15:56.229Z
          stats:
            - answered: 5
              category: lifestyle_behaviors
              total: 11
            - answered: 3
              category: mental_wellbeing
              total: 5
            - answered: 1
              category: preventative_care
              total: 3
            - answered: 9
              category: overall
              total: 19
          updated_at: 2017-07-07T19:15:56.229Z
        id: 59d441ac21741161bbe266b5
        links:
          self: /pub/health_profile/59d441ac21741161bbe266b5
        relationships:
          patient:
            data:
              id: 595fddea28c5041b84466bbe
              type: patient
            links:
              related: /pub/health_profile/59d441ac21741161bbe266b5/patient
          questions:
            data:
              - id: 595fddea28c5041b84466bbe
                type: health_profile_question
            links:
              related: /pub/health_profile/59d441ac21741161bbe266b5/questions
        type: health_profile
      properties:
        attributes:
          properties:
            stats:
              description: List of category, answered and total counts for questions in the health profile
              items:
                description: The category, answered and total counts for questions in the health profile
                properties:
                  answered:
                    type: number
                  category:
                    enum:
                      - lifestyle_behaviors
                      - mental_wellbeing
                      - preventative_care
                      - overall
                    type: string
                  total:
                    type: number
                type: object
              type: array
          type: object
        id:
          type: string
        links:
          properties:
            self:
              example: /health_profile/59d441ac21741161bbe266b5
              pattern: /health_profile/[0-9a-z]+
              type: string
          readOnly: true
          required:
            - self
          type: object
        relationships:
          properties:
            patient:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    related:
                      example: /pub/health_profile/59d441ac21741161bbe266b5/patient
                      pattern: /pub/health_profile/[0-9a-z]+
                      type: string
                  readOnly: true
                  type: object
              readOnly: true
              type: object
            questions:
              properties:
                data:
                  items:
                    properties:
                      id:
                        type: string
                      type:
                        type: string
                    type: object
                  type: array
                links:
                  properties:
                    related:
                      example: /pub/health_profile/59d441ac21741161bbe266b5/questions
                      pattern: /pub/health_profile/[0-9a-z]+
                      type: string
                  readOnly: true
                  type: object
              readOnly: true
              type: object
          type: object
        type:
          type: string
      required:
        - type
      type: object
    HealthQuestionDefinitionResource:
      example:
        attributes:
          category: preventative_care
          format:
            data:
              - label: I Don't know
                value: "0"
              - label: I've never had a colonoscopy
                value: "1"
            type: last_occurrence
          requirements:
            - property: age
              shouldBeGreaterThan: 49
              shouldBeLessThan: 76
          text: When was your last colonoscopy?
        id: "21"
        links:
          self: /pub/health_question_definition/21
        type: health_question_definition
      properties:
        attributes:
          properties:
            category:
              description: The category for the health profile definition
              enum:
                - lifestyle_behaviors
                - mental_wellbeing
                - preventative_care
              type: string
            format:
              description: The list of formats for the health profile definition
              properties:
                data:
                  items:
                    description: The label, value and icon for the answer choices for the question
                    properties:
                      icon:
                        type: string
                      label:
                        type: string
                      value:
                        type: string
                    type: object
                  type: array
                type:
                  type: string
              type: object
            requirements:
              description: The lsit of age and gender requirements for the question to be included
              items:
                description: The age and gender requirement for the question to be included
                properties:
                  property:
                    type: string
                  shouldBeEqual:
                    description: Specifies if the value in property should be equal to the one in value
                    type: boolean
                  shouldBeGreaterThan:
                    description: Specifies if the value in property should be greater than the one in value
                    type: number
                  shouldBeLessThan:
                    description: Specifies if the value in property should be less than the one in value
                    type: number
                  value:
                    description: The value to be compared with the one in property, based on shouldBeEqual, shouldBeGreaterThan, or shouldBeLessThan
                    type: string
                type: object
              type: array
            text:
              description: The question text which corresponds to the answer choices
              type: string
          type: object
        id:
          type: string
        links:
          properties:
            self:
              example: /health_question_definition/4
              pattern: /health_question_definition/[0-9]+
              type: string
          readOnly: true
          required:
            - self
          type: object
        relationships:
          type: object
        type:
          type: string
      required:
        - type
        - id
      type: object
    Identifier:
      properties:
        label:
          type: string
        system:
          type: string
        value:
          type: string
      required:
        - system
        - value
      type: object
    OrganizationResource:
      properties:
        attributes:
          properties:
            name:
              example: Health Activation Partners
              type: string
          required:
            - name
        id:
          example: 57b36e3c04ad8c2224f2af38
          type: string
        links:
          properties:
            self:
              example: /organization/57b36e3c04ad8c2224f2af38
              pattern: /organization/[0-9a-z]+
              type: string
          readOnly: true
          required:
            - self
        type:
          enum:
            - organization
          example: organization
          type: string
      required:
        - id
        - type
        - attributes
      type: object
    PatientCreateResource:
      allOf:
        - $ref: "#/components/schemas/PatientResource"
        - description: |
            Note that `data` can either be a single object or an array of objects matching the schema specified here
            (bulk create).
        - properties:
            relationships:
              properties:
                coaches:
                  properties:
                    data:
                      items:
                        properties:
                          id:
                            example: 57fee2a66b49113551658505
                            type: string
                          meta:
                            properties:
                              primary:
                                type: boolean
                            type: object
                          type:
                            enum:
                              - coach
                            example: coach
                            type: string
                        required:
                          - type
                          - id
                        type: object
                      type: array
                    links:
                      properties:
                        related:
                          example: /patient/57b36ef304ad8c2224f2af3a/coaches
                          pattern: /patient/[0-9a-z]+/coaches
                          type: string
                      readOnly: true
                  required:
                    - data
                  type: object
                groups:
                  properties:
                    data:
                      items:
                        properties:
                          id:
                            description: Required if the `meta.query` is not defined.
                            example: 57b3708b04ad8c2224f2af3b
                            type: string
                          meta:
                            description: Allows the specification of a query for a group rather than providing a group id directly
                            properties:
                              query:
                                description: |
                                  1. If the query does not return any groups, a group with the specified name will be created and related to the patient.
                                  2. If the query returns one group, that group will be related to the patient.
                                  3. If the query returns more than one group, the creation of the patient will fail.
                                properties:
                                  name:
                                    type: string
                                  organization:
                                    type: string
                                required:
                                  - organization
                                  - name
                                type: object
                            required:
                              - query
                            type: object
                          type:
                            enum:
                              - group
                            example: group
                            type: string
                        required:
                          - type
                        type: object
                      type: array
                  required:
                    - data
                  type: object
              required:
                - groups
              type: object
      type: object
    PatientHealthMetricCreateResource:
      allOf:
        - $ref: "#/components/schemas/PatientHealthMetricResource"
        - description: |
            Note that `data` can either be a single object or an array of objects matching the schema specified here
            (bulk create).
      type: object
    PatientHealthMetricResource:
      example:
        data:
          attributes:
            code:
              system: LOINC
              value: 13457-7
            occurred_at: 2017-03-14T11:00:57.000Z
            type: ldl_cholesterol
            unit: mg/dl
            value: 121
          relationships:
            patient:
              data:
                id: ""
                type: patient
          type: patient_health_metric
      properties:
        attributes:
          properties:
            code:
              properties:
                system:
                  type: string
                value:
                  type: string
              required:
                - system
                - value
              type: object
            diastolic:
              type: number
            occurred_at:
              format: dateTime
              type: string
            systolic:
              type: number
            type:
              enum:
                - blood_pressure_systolic
                - blood_pressure_diastolic
                - hemoglobin_a1c
                - hdl_cholesterol
                - ldl_cholesterol
                - total_cholesterol
                - triglycerides
                - blood_urea_nitrogen
                - creatinine
                - hemoglobin
                - hematocrit
                - total_serum_iron
                - thyroid_stimulating_hormone
                - free_thyroxine
                - free_triiodothyronine
                - total_triiodothyronine
                - cd4_cell_count
                - hiv_viral_load
                - inr
                - free_testosterone
                - total_testosterone
                - c_reactive_protein
                - prostate_specific_antigen
                - cotinine
                - c_peptide
                - blood_pressure
                - blood_glucose
                - weight
                - heart_rate
                - body_fat_percentage
                - body_mass_index
                - body_temperature
                - forced_expiratory_volume1
                - forced_vital_capacity
                - lean_body_mass
                - nausea_level
                - oxygen_saturation
                - pain_level
                - peak_expiratory_flow_rate
                - peripheral_perfusion_index
                - respiratory_rate
                - inhaler_usage
              type: string
            unit:
              type: string
            value:
              description: Can be any value (number, boolean, string, object) depending on the metric type. Most values are of type number.
          type: object
        id:
          type: string
        relationships:
          properties:
            patient:
              properties:
                data:
                  properties:
                    id:
                      description: Required if the `meta.query` is not defined.
                      example: 5817ead56f5316c0d05ba8bf
                      type: string
                    meta:
                      description: Allows the specification of a query for a patient rather than providing a patient id directly
                      properties:
                        query:
                          description: The query must return one and only one patient.
                          properties:
                            groups:
                              items:
                                type: string
                              type: array
                            identifier:
                              properties:
                                system:
                                  type: string
                                value:
                                  type: string
                              required:
                                - system
                                - value
                              type: object
                            organization:
                              type: string
                          required:
                            - identifier
                          type: object
                      required:
                        - query
                      type: object
                    type:
                      type: string
                  type: object
                links:
                  type: object
              type: object
          type: object
        type:
          type: string
      required:
        - type
        - id
      type: object
    PatientHealthResultResource:
      example:
        data:
          attributes:
            _thread: 569c631f4b378f51306324f2d69fd29aa0c034ac
            annotations: []
            created_at: 2018-09-18T12:24:37.000Z
            created_by: 5c0fc0d02d02421ed70ca1d1
            data:
              value: 1
            occurred_at: 2018-09-18T12:24:37.000Z
            occurred_at_time_zone: America/New_York
            source: {}
            type: medication
            updated_at: 2018-09-18T12:24:37.000Z
            updated_by: 5c0fc0d02d02421ed70ca1d1
            window: 5c0fc0d42d02421ed70cae01
          id: 5c0fc0d42d02421ed70cae16
          relationships:
            action:
              data:
                id: 5ada648779672451a6c1b095
                type: action
            metric:
              data:
                id: 5c0fc0d42d02421ed70cae16
                type: patient_health_metric
            patient:
              data:
                id: 5c0fc0d02d02421ed70ca1d1
                type: patient
          type: result
      properties:
        attributes:
          properties:
            _thread:
              description: Links together results. This should be the same as the thread of _action, if it is defined
              type: string
            aggregation:
              type: string
            annotations:
              items:
                properties:
                  text:
                    type: string
                  title:
                    type: string
                type: object
              type: array
            channel:
              type: string
            data:
              properties:
                value:
                  description: Can be any value (number, boolean, string, object) depending on the metric type. Most values are of type number
              type: object
            external_id:
              type: string
            metric_type:
              enum:
                - blood_pressure_systolic
                - blood_pressure_diastolic
                - hemoglobin_a1c
                - hdl_cholesterol
                - ldl_cholesterol
                - total_cholesterol
                - triglycerides
                - blood_urea_nitrogen
                - creatinine
                - hemoglobin
                - hematocrit
                - total_serum_iron
                - thyroid_stimulating_hormone
                - free_thyroxine
                - free_triiodothyronine
                - total_triiodothyronine
                - cd4_cell_count
                - hiv_viral_load
                - inr
                - free_testosterone
                - total_testosterone
                - c_reactive_protein
                - prostate_specific_antigen
                - cotinine
                - c_peptide
                - blood_pressure
                - blood_glucose
                - weight
                - heart_rate
                - body_fat_percentage
                - body_mass_index
                - body_temperature
                - forced_expiratory_volume1
                - forced_vital_capacity
                - lean_body_mass
                - nausea_level
                - oxygen_saturation
                - pain_level
                - peak_expiratory_flow_rate
                - peripheral_perfusion_index
                - respiratory_rate
                - inhaler_usage
              type: string
            occurred_at:
              example: 2018-09-18T12:24:37.000Z
              format: dateTime
              type: string
            occurred_at_time_zone:
              example: America/New_York
              type: string
            skipped:
              type: boolean
            source:
              properties:
                metadata:
                  description: Can be any value
                name:
                  type: string
                source_id:
                  type: string
              type: object
            type:
              description: Type of result. Usually the same as metric_type except for lifestyle actions
              type: string
            window:
              type: string
          type: object
        id:
          type: string
        relationships:
          properties:
            action:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  type: object
              type: object
            metric:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  type: object
              type: object
            patient:
              properties:
                data:
                  properties:
                    id:
                      description: Required if the `meta.query` is not defined.
                      example: 5c0fc0d02d02421ed70ca1d1
                      type: string
                    meta:
                      description: Allows the specification of a query for a patient rather than providing a patient id directly
                      properties:
                        query:
                          description: The query must return one and only one patient.
                          properties:
                            groups:
                              items:
                                type: string
                              type: array
                            identifier:
                              properties:
                                system:
                                  type: string
                                value:
                                  type: string
                              required:
                                - system
                                - value
                              type: object
                            organization:
                              type: string
                          required:
                            - identifier
                          type: object
                      required:
                        - query
                      type: object
                    type:
                      type: string
                  type: object
                links:
                  type: object
              type: object
          type: object
        type:
          type: string
      required:
        - type
        - id
      type: object
    PatientIdentifier:
      properties:
        label:
          type: string
        system:
          type: string
        unique:
          default: true
          description: If `true`, the combination of system and value must be global unique among all patients and coaches in Fitbit Plus.
          type: boolean
        value:
          type: string
      required:
        - system
        - value
      type: object
    PatientPlanSummaryResource:
      properties:
        attributes:
          properties:
            adherence:
              readOnly: true
              type: object
            critical:
              additionalProperties: true
              type: object
            effective_from:
              format: dateTime
              readOnly: true
              type: string
            time_zone:
              type: string
            window_notification_times:
              properties:
                afternoon:
                  type: integer
                evening:
                  type: integer
                morning:
                  type: integer
                night:
                  type: integer
              readOnly: true
              type: object
            window_order:
              items:
                properties:
                  _actions:
                    items:
                      type: string
                    type: array
                  type:
                    type: string
                type: object
              type: array
          type: object
        id:
          example: 57b36e3c04ad8c2224f2af38
          type: string
        links:
          properties:
            self:
              example: /patient_plan_summary/57b36e3c04ad8c2224f2af38
              pattern: /patient_plan_summary/[0-9a-z]+
              type: string
          readOnly: true
          required:
            - self
          type: object
        relationships:
          properties:
            actions:
              properties:
                data:
                  items:
                    properties:
                      id:
                        type: string
                      type:
                        type: string
                    required:
                      - type
                      - id
                    type: object
                  type: array
                links:
                  properties:
                    related:
                      type: string
                  type: object
              type: object
            bundles:
              properties:
                data:
                  items:
                    properties:
                      id:
                        type: string
                      type:
                        type: string
                    required:
                      - type
                      - id
                    type: object
                  type: array
                links:
                  properties:
                    related:
                      type: string
                  type: object
              type: object
            current_results:
              properties:
                data:
                  items:
                    properties:
                      id:
                        type: string
                      type:
                        type: string
                    required:
                      - type
                      - id
                    type: object
                  type: array
                links:
                  properties:
                    related:
                      type: string
                  type: object
              type: object
            patient:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
                links:
                  properties:
                    related:
                      type: string
                  type: object
              type: object
          required:
            - actions
            - bundles
            - patient
          type: object
        type:
          enum:
            - patient_plan_summary
          example: patient_plan_summary
          type: string
      required:
        - id
        - type
      type: object
    PatientResource:
      properties:
        attributes:
          properties:
            addresses:
              items:
                $ref: "#/components/schemas/Address"
              type: array
            archive_history:
              items:
                $ref: "#/components/schemas/ArchiveHistory"
              type: array
            archived:
              example: true
              readOnly: true
              type: boolean
            birth_date:
              example: 1944-03-06
              format: date
              type: string
            email_address:
              example: fiona@example.com
              type: string
            enrolled_at:
              example: 2016-05-26T15:25:54.000Z
              format: dateTime
              readOnly: true
              type: string
            first_access_at:
              example: 2016-06-03T13:15:22.000Z
              format: dateTime
              readOnly: true
              type: string
            first_name:
              example: Fiona
              type: string
            gender:
              enum:
                - male
                - female
                - other
              example: female
              type: string
            identifiers:
              items:
                $ref: "#/components/schemas/PatientIdentifier"
              type: array
            invited_at:
              example: 2016-06-01T16:20:16.000Z
              format: dateTime
              readOnly: true
              type: string
            last_access_at:
              example: 2016-07-11T17:50:49.400Z
              format: dateTime
              readOnly: true
              type: string
            last_name:
              example: Reeves
              type: string
            note:
              description: Coach's note about the patient. Not visible to the patient.
              example: Relies on daughter to get around
              type: string
            phone_numbers:
              items:
                $ref: "#/components/schemas/PhoneNumber"
              type: array
            statement:
              description: A patient's motivation statement.
              properties:
                updated_at:
                  example: 2016-06-03T13:15:22.000Z
                  format: dateTime
                  type: string
                updated_by:
                  example: 5c509cc2f60e34018180b57c
                  type: string
                value:
                  example: Enjoying nature.
                  type: string
              readOnly: true
              type: object
            updated_at:
              example: 2016-07-11T17:13:57.027Z
              format: dateTime
              readOnly: true
              type: string
          type: object
        id:
          example: 57b36ef304ad8c2224f2af3a
          type: string
        links:
          properties:
            self:
              example: /patient/57b36ef304ad8c2224f2af3a
              pattern: /patient/[0-9a-z]+
              type: string
            twine_web_app:
              description: A link to the patient record in the Fitbit Plus web application.
              example: https://app.plus.fitbit.com/#/coach/patient/5367c6300b7bb6e94188c02c/overview
              type: string
          readOnly: true
          type: object
        relationships:
          properties:
            coaches:
              properties:
                data:
                  items:
                    properties:
                      id:
                        example: 57fee2a66b49113551658505
                        type: string
                      meta:
                        properties:
                          primary:
                            type: boolean
                        type: object
                      type:
                        enum:
                          - coach
                        example: coach
                        type: string
                    required:
                      - type
                      - id
                    type: object
                  type: array
                links:
                  properties:
                    related:
                      example: /patient/57b36ef304ad8c2224f2af3a/groups
                      pattern: /patient/[0-9a-z]+/groups
                      type: string
                  readOnly: true
              required:
                - data
            groups:
              properties:
                data:
                  items:
                    properties:
                      id:
                        example: 57b3708b04ad8c2224f2af3b
                        type: string
                      type:
                        enum:
                          - group
                        example: group
                        type: string
                    required:
                      - type
                    type: object
                  type: array
              required:
                - data
          required:
            - groups
          type: object
        type:
          enum:
            - patient
          example: patient
          type: string
      required:
        - type
        - attributes
      type: object
    PhoneNumber:
      properties:
        primary:
          example: true
          type: boolean
        type:
          enum:
            - home
            - work
            - mobile
            - home-fax
            - work-fax
            - other
          example: mobile
          type: string
        value:
          example: 555-555-1234
          type: string
      required:
        - type
        - value
        - primary
      type: object
    Resource:
      properties:
        attributes:
          type: object
        id:
          type: string
        type:
          type: string
      type: object
    RewardEarningFulfillmentResource:
      properties:
        attributes:
          properties:
            fulfilled_at:
              description: Date at which the reward earning was fulfilled. (Must be at the same time or after the reward was earned)
              format: dateTime
              type: string
            fulfilled_unit:
              description: Unit of the earned reward that has been fulfilled. (Read-only property)
              readOnly: true
              type: string
            fulfilled_value:
              description: Value of the earned reward that has been fulfilled. (Must be greater than or equal to 0)
              type: number
          required:
            - fulfilled_value
            - fulfilled_at
          type: object
        id:
          type: string
        relationships:
          properties:
            patient:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              readOnly: true
              type: object
            reward_earning:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
          required:
            - reward_earning
          type: object
        type:
          type: string
      required:
        - type
      type: object
    RewardEarningResource:
      properties:
        attributes:
          properties:
            earned_at:
              description: Date at which the reward was earned. (Must be after the reward was allocated and before the reward program activation was deactivated or expired)
              format: dateTime
              type: string
            earned_unit:
              description: Unit of the reward that has been earned. (Read-only property)
              readOnly: true
              type: string
            earned_value:
              description: Value of the reward that has been earned. (Must not exceed the allocated value for the reward)
              type: number
            fulfilled_at:
              description: Date at which the reward earning was fulfilled. (Read-only property)
              format: dateTime
              readOnly: true
              type: string
            fulfilled_value:
              description: Value of the earned reward that has been fulfilled. (Read-only property)
              readOnly: true
              type: number
            ready_for_fulfillment:
              description: If true, the reward earning is ready to be fulfilled, either because the reward program activation was fulfill_as_earned or because the reward program activation has been deactivated. (Read-only property)
              readOnly: true
              type: boolean
          required:
            - earned_value
            - earned_at
          type: object
        id:
          type: string
        relationships:
          properties:
            group:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              readOnly: true
              type: object
            patient:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              readOnly: true
              type: object
            reward:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
            reward_program_activation:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              readOnly: true
              type: object
          required:
            - reward
          type: object
        type:
          type: string
      required:
        - type
      type: object
    RewardProgramActivationResource:
      properties:
        attributes:
          properties:
            activated_at:
              description: Date at which the reward program was activated for the patient. (Must be between the start_at and end_at dates for the reward program)
              format: dateTime
              type: string
            active:
              default: true
              description: If true, the reward program is currently active.
              type: boolean
            allocated_count:
              description: Number of rewards allocated. (Read-only property)
              readOnly: true
              type: number
            budget_unit:
              description: Unit of the reward program budget. (Read-only property)
              readOnly: true
              type: string
            deactivated_at:
              description: Date at which the reward program was deactivated. (Must be after the activated_at date)
              format: dateTime
              type: string
            earned_count:
              description: Number of reward earnings. (Read-only property)
              readOnly: true
              type: number
            expires_at:
              description: Date at which the reward program activation expires. (Read-only property set by adding the days_active from the reward program to the activated_at date)
              format: dateTime
              readOnly: true
              type: string
            fulfill_as_earned:
              description: If true, the rewards created for a patient for the program can be fulfulled as they are earned. If false, the rewards should only be fulfilled when the program is deactivated. (Read-only property denormalized from the reward program)
              readOnly: true
              type: boolean
            total_allocated_value:
              description: Total value of reward allocated. (Read-only property)
              readOnly: true
              type: number
            total_earned_value:
              description: Total value of reward earnings. (Read-only property)
              readOnly: true
              type: number
          required:
            - activated_at
          type: object
        id:
          type: string
        relationships:
          properties:
            patient:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
            reward_program:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
          required:
            - patient
            - reward_program
          type: object
        type:
          type: string
      required:
        - type
      type: object
    RewardProgramResource:
      properties:
        attributes:
          properties:
            budget_unit:
              default: dollar
              description: Unit of the budget for the reard program.
              enum:
                - dollar
                - point
                - credit
              type: string
            budget_value:
              description: Value of the budget for the reward program. (Must be greater than 0)
              type: number
            description:
              description: Description of the reward program - designed to be a comprehensive text description
              type: string
            duration_active:
              default: 540
              description: Number of days that a program can be active after it has been activated for a patient. (Must be greater than 0)
              type: number
            end_at:
              description: Date at which the reward program ends. (Must be after the start_at)
              format: dateTime
              type: string
            frozen:
              default: false
              description: If true, the reward program cannot be activated for a patient and new rewards cannot be created for the program.
              type: boolean
            fulfill_as_earned:
              default: false
              description: If true, the rewards created for a patient for the program can be fulfulled as they are earned. If false, the rewards should only be fulfilled when the program is deactivated.
              type: boolean
            name:
              description: Name of the reward program
              type: string
            start_at:
              description: Date at which the reward program starts.
              format: dateTime
              type: string
            tagline:
              description: Tagline of the reward program - designed to be one line
              type: string
          required:
            - name
            - start_at
            - end_at
            - budget_value
          type: object
        id:
          type: string
        relationships:
          properties:
            group:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  required:
                    - type
                    - id
                  type: object
              required:
                - data
              type: object
          required:
            - group
          type: object
        type:
          type: string
      required:
        - type
      type: object
    RewardResource:
      properties:
        attributes:
          properties:
            _thread:
              description: Unique string identifying the health action with which the reward is associated.
              type: string
            allocated_at:
              description: Date at which the reward was allocated. (Must be after the reward program is activated and before it is deactivated or expires)
              format: dateTime
              type: string
            allocated_unit:
              description: Unit of the reward program. (Read-only property)
              readOnly: true
              type: string
            allocated_value:
              description: Value of the reward program budget allocated for the reward. (Must not exceed the remaining budget for the reward program activation)
              type: number
            description:
              description: Description of the reward.
              type: string
            earned_at:
              description: Date at which the reward was earned. (Read-only property)
              format: dateTime
              readOnly: true
              type: string
            earned_value:
              description: Value of the reward that has been earned. (Read-only property)
              readOnly: true
              type: number
            fulfilled_at:
              description: Date at which the reward earning was fulfilled. (Read-only property)
              format: dateTime
              readOnly: true
              type: string
            fulfilled_value:
              description: Value of the earned reward that has been fulfilled. (Read-only property)
              readOnly: true
              type: number
            target_at:
              description: Date at which the patient aspires to achieve the reward. (Must be the same or after the allocated_at date)
              format: dateTime
              type: string
          required:
            - description
            - allocated_value
            - allocated_at
          type: object
        id:
          type: string
        relationships:
          properties:
            patient:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              readOnly: true
              type: object
            reward_program_activation:
              properties:
                data:
                  properties:
                    id:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
          required:
            - reward_program_activation
          type: object
        type:
          type: string
      required:
        - type
      type: object
    TokenResource:
      properties:
        attributes:
          properties:
            access_token:
              example: a01fe2bb-1977-48d9-b722-ac7f9135143f
              type: string
            expires_in:
              example: 3600
              type: integer
            refresh_token:
              example: b452cb17-72e2-4e90-b9c6-d77a0b66cf7c
              type: string
            token_type:
              enum:
                - bearer
              example: bearer
              type: string
          required:
            - access_token
            - refresh_token
            - token_type
            - expires_in
        id:
          example: 57b36c9a04ad8c2224f2af35
          type: string
        relationships:
          properties:
            groups:
              properties:
                data:
                  items:
                    properties:
                      id:
                        example: 57b36d6f04ad8c2224f2af36
                        type: string
                      type:
                        enum:
                          - group
                        example: group
                        type: string
                    required:
                      - type
                      - id
                    type: object
                  type: array
                links:
                  properties:
                    related:
                      example: /oauth/token/57b36d8804ad8c2224f2af37/groups
                      pattern: /oauth/token/[0-9a-z]+/groups
                      type: string
                  required:
                    - related
              required:
                - links
                - data
            organization:
              properties:
                data:
                  properties:
                    id:
                      example: 57b36d6f04ad8c2224f2af36
                      type: string
                    type:
                      enum:
                        - organization
                      example: organization
                      type: string
                  required:
                    - type
                    - id
                links:
                  properties:
                    related:
                      example: /oauth/token/57b36d8804ad8c2224f2af37/organization
                      pattern: /oauth/token/[0-9a-z]+/organization
                      type: string
                  required:
                    - related
              required:
                - links
                - data
          type: object
        type:
          enum:
            - token
          example: token
          type: string
      required:
        - type
        - id
      type: object
    UpdateActionRequest:
      properties:
        data:
          $ref: "#/components/schemas/ActionResource"
      required:
        - data
      type: object
    UpdateActionResponse:
      properties:
        data:
          $ref: "#/components/schemas/ActionResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    UpdateBundleRequest:
      properties:
        data:
          $ref: "#/components/schemas/BundleResource"
      required:
        - data
      type: object
    UpdateBundleResponse:
      properties:
        data:
          $ref: "#/components/schemas/BundleResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    UpdateCalendarEventRequest:
      example:
        data:
          attributes:
            all_day: false
            attendees:
              - user: 5a0c8e27a9d454cc150997c9
              - user: 5a0c8e27a9d454cc150997f7
            completed_at: 2017-11-03T06:17:34.652Z
            completed_by: 5a0c8e27a9d454cc150997c9
            end_at: 2018-02-20T18:00:00Z
            start_at: 2018-02-20T14:00:00Z
            time_zone: America/New_York
            title: Telephone Call
            type: telephone-call
          id: 42ba7c2da9d45415234345b3
          relationships:
            owner:
              data:
                id: 5a0c8e27a9d454cc150997f7
                type: patient
          type: calendar_event
      properties:
        data:
          properties:
            attributes:
              allOf:
                - $ref: "#/components/schemas/CalendarEventResource/properties/attributes"
            id:
              $ref: "#/components/schemas/CalendarEventResource/properties/id"
            relationships:
              properties:
                owner:
                  properties:
                    data:
                      $ref: "#/components/schemas/CalendarEventResource/properties/relationships/properties/owner/properties/data"
                  type: object
              type: object
            type:
              $ref: "#/components/schemas/CalendarEventResource/properties/type"
          required:
            - type
            - id
          type: object
      type: object
    UpdateCalendarEventResponse:
      properties:
        data:
          $ref: "#/components/schemas/CalendarEventResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      type: object
    UpdatePatientPlanSummaryRequest:
      properties:
        data:
          $ref: "#/components/schemas/PatientPlanSummaryResource"
      required:
        - data
      type: object
    UpdatePatientPlanSummaryResponse:
      properties:
        data:
          $ref: "#/components/schemas/PatientPlanSummaryResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    UpdatePatientRequest:
      example:
        data:
          attributes:
            first_name: Jonathon
          id: 5817ead56f5316c0d05ba8bf
          type: patient
      properties:
        data:
          $ref: "#/components/schemas/PatientResource"
      required:
        - data
      type: object
    UpdatePatientResponse:
      example:
        data:
          attributes:
            addresses: []
            archive_history: []
            archived: false
            first_name: Jack
            identifiers: []
            last_name: Frost
            phone_numbers: []
            updated_at: 2016-11-01T01:07:33.121Z
          id: 5817ead56f5316c0d05ba8bf
          links:
            self: /pub/patient/5817ead56f5316c0d05ba8bf
            twine_web_app: http://10.0.1.55:9000/#/coach/patient/5817ead56f5316c0d05ba8bf
          relationships:
            coaches:
              data: []
              links:
                related: /pub/patient/5817ead56f5316c0d05ba8bf/coaches
            groups:
              data:
                - id: 5755db2a3db4179179999acf
                  type: group
              links:
                related: /pub/patient/5817ead56f5316c0d05ba8bf/groups
          type: patient
        included: []
        meta:
          req_id: 5b813ad3-cabc-418f-add4-1e53bc69f7cb
      properties:
        data:
          $ref: "#/components/schemas/PatientResource"
        meta:
          $ref: "#/components/schemas/CreateOrUpdateMetaResponse"
      required:
        - data
      type: object
    UpsertPatientRequest:
      example:
        data:
          attributes:
            first_name: Jack
            last_name: Frost
          relationships:
            groups:
              data:
                - id: 5755db2a3db4179179999acf
                  type: group
          type: patient
        meta:
          query:
            groups:
              - 5755db2a3db4179179999acf
            identifier:
              system: OtherPlace
              value: "123456"
      properties:
        data:
          $ref: "#/components/schemas/PatientResource"
        meta:
          properties:
            query:
              properties:
                groups:
                  description: Group to create/update patient in.
                  items:
                    description: ID of group
                    type: string
                  type: array
                identifier:
                  description: Identifier to match patient
                  properties:
                    system:
                      description: Name of system
                      type: string
                    value:
                      description: Value in system
                      type: string
                  type: object
              required:
                - identifier
                - groups
              type: object
          required:
            - query
          type: object
      required:
        - meta
        - data
      type: object
  securitySchemes:
    OAuth2:
      description: |
        Fitbit Plus allows customers to access data for their organization using client credentials.
        OAuth2 is a safe and secure way to give you access.
      flows:
        clientCredentials:
          scopes:
            group: access patients and data within a group
            organization: access patients and data within an organization
          tokenUrl: /oauth/token
      type: oauth2
x-tagGroups:
  - name: Authentication (oauth)
    tags:
      - oauth
  - name: Admin
    tags:
      - organization
      - group
      - coach
      - reward program
  - name: Patient Data
    tags:
      - action
      - bundle
      - calendar event
      - calendar event response
      - email history
      - health profile
      - health profile answer
      - health profile question
      - health question definition
      - metric
      - patient
      - plan
      - result
      - reward
      - reward earning
      - reward earning fulfillment
      - reward program activation
