Webhooks
The Webhooks are used to give real-time status updates, for example when someone has completed the challenge. You need to use a URL to push these statuses. After implementation of the push endpoints, you will get a ping every time a status has changed. You can use these pings to send a notification to a user about his/her status.
Set-up:
-
You log into the dashboard- https://api.wefitter.com/dashboard/login/ and access your App.
-
Inside the App, you can select the option of 'push endpoints'
-
Select data type, you can select V1. Save them individually (see screenshot) with a callback URL.
-
Tick the box for ‘Active’ status.
-
Notifications are sent with an interval of 5 minutes.
Types of Webhooks @WeFitter
-
When new 'activity' data is available
-
When status of the profile has changed in the challenge
New activity for a profile
When new activity data is available, you will receive a status. Directly pushing incoming data (workouts, daily summaries etc.)
a) Activity
b) Biometric
c) Daily summaries
d) Heartrate data
e) myzone workout
f) Sleep summary
g) Stress sample
h) Stress summary
Example body:
{"profile": "aaaaaav-afb0-gggggggff", "data": {"timestamp": "2021-02-09T13:32:59Z", "duration": "00:33:30.914000", "source": "POLAR", "is_manual": null, "type": "WALKING", "distance": 449.0, "steps": null, "calories": null, "points": 33.51}
Status change of profile in challenge
Besides to directly pushing incoming data (workouts, daily summaries etc.) we currently provide the following webhook notifications:
CHALLENGE_START
CHALLENGE_END
PERIOD_GOAL_REACHED
PERIOD_GOAL_PARTIALLY_REACHED
Note that the last two are currently only supported for Individual challenges and not Team or Group (global). We are working on the implementation for these types.
You can register an endpoint to receive webhook notifications in the WeFitter dashboard, by creating push endpoints on the corresponding tab on the app-edit page, e.g.
https://api.wefitter.com/dashboard/account/{account_id}/app/{app_id}/
Notifications are sent with an interval of 5 minutes.
Challenge start and end
Challenge start example body (similarly for challenge end, but event is 'challenge_end'):
{
"event":"challenge_start",
"event_timestamp":"2021-02-17 15:39:00+01:00",
"challenge_id":aaaaaa-0000-bbbb-cccc-dddddd4d",
"challenge_title":"foo"
}
Period goal reached example body
This notification is sent each time a profile completes the goal for the current challenge period (e.g. a given day, week, month or total challenge duration, depending on challenge type).
{
"event":"challenge_period_goal_reached",
"challenge_id":"aaaaaa-0000-bbbb-cccc-dddddd4d",
"challenge_title":"foo",
"period_start":"2021-02-17 14:39:00+00:00",
"period_end":"2021-02-18 14:39:00+00:00",
"model":"profile",
"model_id":"aaaaaa-0000-bbbb-cccc-dddddd4d"
}
Period goal partially reached
{
"event":"partial_period_goal_reached",
"challenge_id":"aaaaaa-0000-bbbb-cccc-dddddd4d",
"challenge_title":"foo",
"period_start":"2021-02-17 14:39:00+00:00",
"period_end":"2021-02-18 14:39:00+00:00",
"model":"profile",
"model_id":"aaaaa- vvvv-eeee-aaaaaaaaa",
"goal_reached_proportion":0.80321,
"current_score":481.926
}
This notification is sent each time a profile partially completes the goal for the current challenge period (e.g. a given day, week, month or total challenge duration, depending on challenge type).
Triggers for this notification are reaching 25%, 50% and 75% of the goal value in the current period. If a profile receives a new score (through daily summaries, workouts, or events) and the new score crosses multiple thresholds (e.g. 25% and 50% at the same time), we only send one notification.