The Balance Rewards API enables qualified partners to connect into Walgreens to share individual member health and wellness information to be eligible to receive Balance Rewards points for completing 4-week physical activity and healthy lifestyle challenges. The API is designed to enable partners to seamlessly share individual health and lifestyle activity (Data Sharing), and create or validate user memberships (Authentication).
In order for Balance Rewards members to receive points for data recorded using pre-qualified partners applications, devices, or platform, partners must share full activity information with Walgreens. In no way is Walgreens able to reward activity without supporting aggregate or transaction level information. Currently, Balance Rewards members are eligible to receive the following rewards:
In order for individuals to receive points for completing healthy challenges, they must be a Balance Rewards member and have successfully completed a Walgreens OAuth login or registration. Further instructions on prerequisites and how to obtain required authentication credentials are contained with the API Documentation.
Below are the technical steps you will need to go through in order to get your integration configured and branded correctly:
The following API endpoints can be used to programmatically integrate all functions of the Digital Offers experience:
Your application will navigate to the authorization code URL, while passing parameters outlined below in order to complete the required Walgreens.com login or registration process.
Sandbox: https://m-qa2.walgreens.com/oauth/authorize.jsp
Production: https://www.walgreens.com/oauth/authorize.jsp
Open a Webview/Browser:
AuthURL
? client_id=YOUR_AFFILIATE_ID
& response_type=code
& scope=steps
& redirect_uri=YOUR_REDIRECT_URI
& channel=1,5, or 6
& transaction_id=1234567890123456
& state=abcd1234xyz
Upon successfully logging into Walgreens.com or registering with Walgreens.com, the authorization server validates the incoming parameters, verifies the client registration, and then the authorization server issues an authorization code. The authorization code will be embedded within the redirect URI as a URL parameter.
Sample URL redirect response:
YOUR_REDIRECT_URI
? code=AUTHORIZATION_CODE
& scope=steps
& transaction_id=ONE_PASSED_IN_REQUEST_AUTH
& state=ONE_PASSED_IN_REQUEST_AUTH
Sample Error Response:
YOUR_REDIRECT_URI
? error_code=ERROR_CODES_BELOW
& error=ERROR_NAMES_BELOW
& error_description=ERROR_DESCRIPTIONS_BELOW
& transaction_id=ONE_PASSED_IN_REQUEST_AUTH
& state=ONE_PASSED_IN_REQUEST_AUTH
Your application requests the authorization server for access to the token by sending the authorization code, along with other parameters detailed below, which is shared by authorization server using the application/x-www-form-urlencoded format.
Sandbox: https://services-qa.walgreens.com/api/oauthtoken/v1
Production: https://services.walgreens.com/api/oauthtoken/v1
TOKEN_URL
Content-Type: application/x-www-form-urlencoded
? grant_type=authorization_code
& act=getOAuthToken
& client_id=YOUR_AFFILIATE_ID
& client_secret=YOUR_API_KEY
& code=AUTHORIZATION_CODE
& redirect_uri=YOUR_REDIRECT_URI
& channel=1,5, or 6
& transaction_id=ONE_PASSED_IN_REQUEST_AUTH
& state=ONE_PASSED_IN_REQUEST_AUTH
If the authorization token request is valid and authorized, the authorization server issues an access token and refresh token.
Sample Success response:
Content-Type: application/json
{
"scope":"steps",
"token_type":"BEARER",
"access_token_expires_in": "2020-09-17T18:19:18.000Z",
"refresh_token_expires_in": "2020-12-15T18:19:18.000Z"
"access_token":"USER_ACCESS_TOKEN",
"refresh_token":"USER_REFRESH_TOKEN",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
Sample Error Response:
Content-Type: application/json
{
"error_code":"ERROR_CODES_BELOW",
"error":"ERROR_NAMES_BELOW",
"error_description":"ERROR_DESCRIPTIONS_BELOW",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
If the authorization token request is valid and authorized, the authorization server issues a new access token and refresh token.
Sandbox: https://services-qa.walgreens.com/api/oauthtoken/v1
Production: https://services.walgreens.com/api/oauthtoken/v1
curl --request POST \
TOKEN_URL
Content-Type: application/x-www-form-urlencoded
? grant_type=refresh_token
& act=getOAuthToken
& client_id=YOUR_AFFILIATE_ID
& client_secret=YOUR_API_KEY
& refresh_token=USER_REFRESH_TOKEN
& redirect_uri=YOUR_REDIRECT_URI
& channel=1,5, or 6
& transaction_id=ONE_PASSED_IN_REQUEST_AUTH
& state=ONE_PASSED_IN_REQUEST_AUTH
If the authorization token request is valid and authorized, the authorization server issues a new access token and refresh token.
Sample Success Response:
Content-Type: application/json
{
"scope":"steps",
"token_type":"BEARER",
"access_token_expires_in": "2020-09-17T18:19:18.000Z",
"refresh_token_expires_in": "2020-12-15T18:19:18.000Z"
"access_token":"USER_ACCESS_TOKEN",
"refresh_token":"USER_REFRESH_TOKEN",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
Sample Error Response:
Content-Type: application/json
{
"error_code":"ERROR_CODES_BELOW",
"error":"ERROR_NAMES_BELOW",
"error_description":"ERROR_DESCRIPTIONS_BELOW",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
If the deactivate token request is valid and authorized, the authorization server deactivates the access token and refresh token
Sandbox: https://services-qa.walgreens.com/api/oauthtoken/delete/v1
Production: https://services.walgreens.com/api/oauthtoken/delete/v1
DEACTIVATE_TOKEN_URL
Content-Type: application/x-www-form-urlencoded
? act=deactivateToken
& client_id=YOUR_AFFILIATE_ID
& client_secret=YOUR_API_KEY
& token=USER_ACCESS_TOKEN
& channel=1,5, or 6
If the deactivate token request is valid and authorized, the authorization server deactivates the access token and refresh token.
Sample Success Response:
Content-Type: application/json
{
"status":"success",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
Sample Error Response:
Content-Type: application/json
{
"error_code":"ERROR_CODES_BELOW",
"error":"ERROR_NAMES_BELOW",
"error_description":"ERROR_DESCRIPTIONS_BELOW",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
Once the oAuth process has been completed, your app is ready to send activity data whenever new data has been received by the user from a device or when the user has entered a manual entry of data. You have the option to post the activity immediately upon receiving the data from the user, or in can be posted in batches on a scheduled basis.
Sandbox: https://services-qa.walgreens.com/api/steps/activity/v1?apiKey=[YOUR_API_KEY]
Production: https://services.walgreens.com/api/steps/activity/v1?apiKey=[YOUR_API_KEY]
POST_ACTIVITY_URL
Content-Type: application/json
{
"creates": [ {
"access_token":"USER_ACCESS_TOKEN",
"affiliate_id":"YOUR_AFFILIATE_ID",
"transaction_id":"RANDOM_NUMBER_16_LENGTH",
"date":"YYYY_MM_DD *(THE DATE OF THIS POST REQUEST)",
"user_device_id":"Either user_id from their account in your app, or the UUID",
"manufacturer_name":"YOUR_COMPANY_NAME" (20 MAX LENGTH),
"device_name":"YOUR_DEVICE_NAME" (20 MAX LENGTH,This is displayed on the Walgreens Health Dashboard),
"data": [
{
"id":"UNIQUE_ID (This must be 100% unique for every user/activity/entry)",
"device_tracked":"true or false",
"timestamp":"YYYY-MM-DD HH:MM:SS *(THE TIME THE HEALTHY ACTIVITY IS COMPLETED)",
"type":"ACTIVITY_TYPE" (Listed below),
"value": {"EXPLAINED BELOW" }
} ]
} ]
}
Sample Success Response:
Content-Type: application/json
{
"success_code":"2000",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
Sample Error Response:
Content-Type: application/json
{
"error_code":"ERROR_CODES_BELOW",
"error":"ERROR_NAMES_BELOW",
"error_description":"ERROR_DESCRIPTIONS_BELOW",
"transaction_id":"ONE_PASSED_IN_REQUEST_AUTH"
}
The below table defines what "value" parameters are currently available to pass. We are always updating with new activity types!
Type | Example | Description | Units | Range |
---|---|---|---|---|
total_steps |
|
Number of Steps taken the entire day. | Steps | 0-100000 |
walking |
|
Duration of Exercise
Distance Traveled Number of Steps |
Seconds
Miles Steps |
0-86400
0-1400 0-100000 |
running |
|
Duration of Exercise
Distance Traveled Number of Steps |
Seconds
Miles Steps |
0-86400
0-1400 0-100000 |
biking |
|
Duration of Exercise
Distance Traveled |
Seconds
Miles |
0-86400
0-1400 |
general_exercise |
|
Duration of Exercise
Name of Activity |
Seconds
String |
0-86400
Ex. "Yoga" |
weight |
|
Total Weight Measured | Pounds | 0-1500 |
blood_pressure |
|
Systolic Blood Pressure
Diastolic Blood Pressure |
MmHg
MmHg |
0-300
0-300 |
blood_oxygen_ratio |
|
Blood Oxygen Saturation | Precent Oxigenated | 0-100 |
blood_glucose |
|
Blood Glucose Value
Medicine Relation Relation To Meal Meal Type |
Mg/dL
String
String
String |
0-1000
"Pre-Medicine", "Post-Medicine" "Pre" || "Post" Ex. "Lunch" |
sleep |
|
Duration of Sleep
Quality of Sleep |
Seconds
String
|
0-86400
Examples: "Good", "Normal", "Bad" |
With this endpoint we have introduced the ability for your integration to retrieve the points total for a connected Walgreens Balance Rewards user by leveraging the access token that is gained in the oAuth process.
Sandbox: https://services-qa.walgreens.com/api/steps/brpoints/v1?apiKey=[YOUR_API_KEY]
Production: https://services.walgreens.com/api/steps/brpoints/v1?apiKey=[YOUR_API_KEY]
GET_POINTS_URL
Content-Type: application/json
{
"access_token":"USER_ACCESS_TOKEN",
"affiliate_id":"YOUR_AFFILIATE_ID",
"act":"getBRPoints",
"transaction_id":"RANDOM_NUMBER_16_LENGTH"
}
If the authorization token is valid, the server issues the points total for that user. The points comes back with the Total Balance Rewards points, and the points earned from doing healthy choices.
Sample Success response:
Content-Type: application/json
{
"total_rewards_points":"Total Balance Rewards points",
"healthy_choice_points":"Balance Rewards points earned by healthy choices.",
"transaction_id":"ONE_PASSED_IN_REQUEST"
}
Sample Error Response:
Content-Type: application/json
{
"error_code":"ERROR_CODES_BELOW",
"error":"ERROR_NAMES_BELOW",
"error_description":"ERROR_DESCRIPTIONS_BELOW",
"transaction_id":"ONE_PASSED_IN_REQUEST"
}
Obviously we don't want any errors to happen, but sometimes they do and as a result we respond the following error codes. The table below helps explain why each of the error codes could occur:
Code | Type | Message |
---|---|---|
1001 | invalid_request | Any missing parameters in the request. Invalid response_type. Invalid grant_type. Invalid value in the request params. |
1011 | unauthorized_client | The client_id is invalid or not registered. The redirect_uri is invalid. |
1021 | access_denied | When the Authorization Code already exists for the user. |
1031 | invalid_scope | The requested scope is invalid or not authorized to that client. |
1041 | invalid_authcode | The authorization code which is in the request is invalid or expired. |
1051 | invalid_token | The access token or refresh token which is in the request is invalid or expired. |
1061 | temporarily_unavailable | The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server. |
1071 | application_error | Unable register user in Walgreens.com (Balance Rewards registration) due to some internal issues. |
1081 | process_activity_error | Token validation success but unable process one or more activities. Only failed activity ids will be sent in the response object. |