API Version: 
Version 1.5 - March 30, 2017 - Available for iOS & Android (Phone/Tablet) Native App Integrations Only

Introduction:

The Walgreens Pharmacy Prescription API allows users of third-party mobile & tablet applications to quickly order refills of prescriptions originally filled at one of the 8,200+ Walgreens pharmacies. Mobile & tablet app users can order refills in seconds, as well as select the option to opt-in to receive a text alert when their prescription order is ready for pick up.

The health care focused Pharmacy Prescription API is designed to increase prescription compliance and aid in personal health management through automated refill alerts and a streamlining of the refill process. By offering easy prescription refills through this health management API, Walgreens hopes to further increase health care adherence by reaching a wider audience through third party health care apps.

Documentation/Services Highlights:

  • Added detailed description tables for all the request json body parameters!

Technical Information:


Rx Refill Flow:

The external services listed below make up the complete list of services that are available to submit refills via the Rx Refill API.

Rx Transfer Flow:

The external services listed below make up the complete list of services that are available to submit transfers via the Rx Transfer API.

In order to ensure your integration is both future and backwards compatible, please make sure that the integration is only reading the parameters which will display in the app UI and do not impose strict parsing or typecasting logic for any of the API response parameters. We may add new request and response parameters to our APIs in order to offer enhanced functionality and to support multiple products in a contiguous way.

Obtain Refill Landing URL:

Description: This service is used to fetch the "landingUrl" used for the Rx Refill API. Request Content-type is application/json. The request should be a HTTPS POST.

Attribute Required/Optional Description
apiKey required The API Key that you have been approved for. Can be found here.
affId required The AffiliateID that you was given in your application email.
transaction required The Transaction is a value that invokes the refill service. The value must be "refillByScan".
act required The Action is a value that invokes our internal service. The value must be "mweb5Url".
view required The View is a value that invokes our internal service. The value must be "mweb5UrlJSON".
devinf optional value See below section Explaining Device Info
appver optional value See below section Explaining App version

Open Refill Landing URL:

Description: This service is used to open the "landingUrl" used for the Rx Refill API. Request Content-type is application/json. The request should be a HTTPS POST.

Attribute Required/Optional Description
affId required The AffiliateID that you was given in your application email.
token required The Token is a value that associates the checkout to the landingURL request made above. The value must be re-obtained for every checkout.
lat required The lat is the latitude of the customer as a string. Example: "42.138199"
lng required The lng is the longitude of the customer as a string. Example: "-87.945799"
rxNo required The rxNo is the number either scanned/manually entered by the customer. Sample Prescription Numbers
appCallBackScheme required The appCallBackScheme is the URI scheme that is associated in either your info.plist or AndroidManifest.xml file.
appCallBackAction required The appCallBackAction is the URI action that is associated in either your info.plist or AndroidManifest.xml file.
trackingId optional value The trackingId is a value that can be used for tracking orders on your system.
appId required The appId is a value that invokes our internal service. The value must be "refillByScan".
act required The Action is a value that invokes our internal service. The value must be "chkExpRx".
devinf optional value See below section Explaining Device Info
appver optional value See below section Explaining App version

Handling Refill Callbacks:

Once the user has loaded the checkout page there are some button interactions that must be handled by the callback URL passed in generating the checkout:

Possible Refill Callback Scenarios:

  • When the user taps the "Cancel" button on the landing page
  • When the user taps the "Back" button on the landing page
  • When the user taps the "Close" button on the prescription confirmation page
  • When the user taps the "Refill Another" button on the prescription confirmation page
  • After an invalid prescription number alert
Value of appCallBackScheme passed in the request + ? + value of appCallBackAction passed in the request + = + the callback value
Example of a call from the "Refill Another" button being pressed:
"appCallbackScheme://appCallbackScheme?appCallbackAction=fillAnother"
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
{
	let arrURL:Array = url.absoluteString.components(separatedBy: "?")
	let arrQuery:Array = arrURL[1].components(separatedBy: "=")
	if(url.scheme == "refiller" && arrQuery[0] == "action")
	{
		switch (arrQuery[1])
		{
			case "refillTryAgain":
				//Open the Error View Controller, they entered an invalid Rx Number
			case "cancel":
				//Open the Error View Controller, customer chose to cancel their refill
			case "back":
				//Open the Error View Controller, customer chose to back out of the refill
			case "close":
				//Open the Success View Controller, their Rx is on its way
			case "fillAnother":
				//Open the Refill View Controller, they want to refill another Rx
			default:
				//Open the Error View Controller, something bad happened during checkout
		}
		return true
	}
	else {return false}
}
						
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
	Uri appCallbackURI = Uri.parse(url);
	if (appCallbackURI != null && appCallbackURI.getScheme().equalsIgnoreCase("refiller"))
	{
		String action = appCallbackURI.getQueryParameter("action");
		switch(action)
		{
			case action.equalsIgnoreCase("refillTryAgain"):
				//Open the Error Activity, they entered an invalid Rx Number
			case action.equalsIgnoreCase("cancel"):
				//Open the Error Activity, customer chose to cancel their refill
			case action.equalsIgnoreCase("back"):
				//Open the Error Activity, customer chose to back out of the refill
			case action.equalsIgnoreCase("close"):
				//Open the Success Activity, their Rx is on its way
			case action.equalsIgnoreCase("fillAnother"):
				//Open the Refill Activity, they want to refill another Rx
			default:
				//Open the Error Activity, something bad happened during checkout
		}
	}
}

@Override
public void onBackPressed()
{
	if (webview.getVisibility() == View.VISIBLE)
	{
		if (webview.canGoBack())
		{
			//Java script call to dismiss the Native calendar Control
			webview.loadUrl("javascript:dismissCalendar();");
			//Java script call to handle page navigations
			webview.loadUrl("javascript:nativeBackBtnClicked();");
		}
		else 
		{
			Intent intent = new Intent(CustomWebView.this, MainActivity.class);
			CustomWebView.this.startActivity(intent);
			finish();
		}
	}
}
					    
Button Pressed Callback Value
Cancel "cancel"
Back "back"
Close "close"
Refill Another "fillAnother"
Ok (in an invalid prescription number alert) "refillTryAgain"

Obtain Transfer Landing URL:

Description: This service is used to fetch the "landingUrl" used for the Rx Transfer API. Request Content-type is application/json. The request should be a HTTPS POST.

Attribute Required/Optional Description
apiKey required The API Key that you have been approved for. Can be found here.
affId required The AffiliateID that you was given in your application email.
transaction required The Transaction is a value that invokes the refill service. The value must be "refillByScan".
act required The Action is a value that invokes our internal service. The value must be "mweb5Url".
view required The View is a value that invokes our internal service. The value must be "mweb5UrlJSON".
devinf optional value See below section Explaining Device Info
appver optional value See below section Explaining App version

Open Transfer Landing URL:

Description: This service is used to open the "landingUrl" used for the Rx Transfer API. Request Content-type is application/json. The request should be a HTTPS POST.

Note:

Though some of the parameters are listed as "optional", passing these values would pre-populate the details in the checkout so the users don't have to key-in all these details again thereby avoiding duplication of efforts and providing better user experience.

Note:

We suggest compressing the image of the Rx Bottle before converting it to the Base64 encoded image data string. This way the POST of the file data is smaller and a faster checkout experience can happen!

Attribute Required/Optional Description
affId required The AffiliateID that you was given in your application email.
token required The Token is a value that associates the checkout to the landingURL request made above. The value must be re-obtained for every checkout.
lat required The lat is the latitude of the customer as a string. Example: "42.138199"
lng required The lng is the longitude of the customer as a string. Example: "-87.945799"
rxImg required The rxImg is the Base64 encoded image data as a string pulled from a picture of the customers pill bottle.
fname optional value The fname is the first name of the customer as a string.
lname optional value The lname is the last name of the customer as a string.
dob optional value The dob is the date of birth of the customer as a string. Format: "MM-DD-YYYY"
phoneNbr optional value The phoneNbr is the customers phone number. Format: "##########"
pharmacyNbr optional value The pharmacyNbr is the customers previous pharmacy phone number, usually placed on the Rx Label. Format: "##########"
appCallBackScheme required The appCallBackScheme is the URI scheme that is associated in either your info.plist or AndroidManifest.xml file.
appCallBackAction required The appCallBackAction is the URI action that is associated in either your info.plist or AndroidManifest.xml file.
trackingId optional value The trackingId is a value that can be used for tracking orders on your system.
appId required The appId is a value that invokes our internal service. The value must be "transferByScan".
act required The Action is a value that invokes our internal service. The value must be "transferRxHome".
devinf optional value See below section Explaining Device Info
appver optional value See below section Explaining App version

Handling Transfer Callbacks:

Once the user has loaded the checkout page there are some button interactions that must be handled by the callback URL passed in generating the checkout:

Possible Transfer Callback Scenarios:

  • When the user taps the "Cancel" button on the landing page or on the transfer review page
  • When the user taps the "Back" button on the landing page
  • When the user taps the "Home" button on the transfer confirmation page
  • When the user taps the "Transfer Another" button on the transfer confirmation page
  • When the user taps the "Done" button on the transfer confirmation page
Value of appCallBackScheme passed in the request + ? + value of appCallBackAction passed in the request + = + the callback value
Example of a call from the "Transfer Another" button being pressed:
"appCallbackScheme://appCallbackScheme?appCallbackAction=txAnother"
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
{
	let arrURL:Array = url.absoluteString.components(separatedBy: "?")
	let arrQuery:Array = arrURL[1].components(separatedBy: "=")
	if(url.scheme == "transfer" && arrQuery[0] == "action")
	{
		switch (arrQuery[1])
		{
			case "txCancel":
				//Open the Error View Controller, customer chose to cancel their transfer or back out of it
			case "txHome":
				//Open the Error View Controller, customer chose to hit home on the checkout page
			case "txDone":
				//Open the Success View Controller, their transfer is on its way to the store!
			case "txAnother":
				//Open the Transfer View Controller, they want to transfer another Rx
			default:
				//Open the Error View Controller, something bad happened during checkout
		}
		return true
	}
	else {return false}
}
						
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
	Uri appCallbackURI = Uri.parse(url);
	if (appCallbackURI != null && appCallbackURI.getScheme().equalsIgnoreCase("transfer"))
	{
		String action = appCallbackURI.getQueryParameter("action");
		switch(action)
		{
			case action.equalsIgnoreCase("txCancel"):
				//Open the Error View Controller, customer chose to cancel their transfer or back out of it
			case action.equalsIgnoreCase("txHome"):
				//Open the Error View Controller, customer chose to hit home on the checkout page
			case action.equalsIgnoreCase("txDone"):
				//Open the Success View Controller, their transfer is on its way to the store!
			case action.equalsIgnoreCase("txAnother"):
				//Open the Transfer View Controller, they want to transfer another Rx
			default:
				//Open the Error View Controller, something bad happened during checkout
		}
	}
}

@Override
public void onBackPressed()
{
	if (webview.getVisibility() == View.VISIBLE)
	{
		if (webview.canGoBack())
		{
			//Java script call to dismiss the Native calendar Control
			webview.loadUrl("javascript:dismissCalendar();");
			//Java script call to handle page navigations
			webview.loadUrl("javascript:nativeBackBtnClicked();");
		}
		else 
		{
			Intent intent = new Intent(CustomWebView.this, MainActivity.class);
			CustomWebView.this.startActivity(intent);
			finish();
		}
	}
}
					    
Button Pressed Callback Value
Cancel or Back "txCancel"
Home "txHome"
Done "txDone"
Transfer Another "txAnother"

Errors:

Error Codes & Messages for Rx Refill Service:

Error Code Description
111,112,113,114,115,116 Configuration issues found in JSON body.
117 We are unable to complete your request. Please try again later.
118 A required attribute is missing in the request.
120 The Rx Number is invalid.
121 Rx number entered is a Medicare Part B prescription. It can be refilled by calling 888-727-8265.
122 The Rx number entered is a Mail Service prescription. It can be refilled by calling 866-525-1590.
123,124,125,126,127 The Rx number entered cannot be filled at that store. Please select a different store.
128 Network error, please try again.
1001 We are unable to enroll you in Rx Text alerts at this time. Please try again later.
1003,202 We are unable to complete your request. Please try again later.
205 No request parameters found.
209 We are unable to locate any stores based on your current location.
ERR_DEFAULT We are unable to complete your request.
ERR_PRES_CANT_PICKED Unable to refill that prescription now. Please contact the Pharmacist.
VALIDATE_RX_WRN_MSG There are no refills left for that prescription.
ERR_TEXT_SUBSCR Unable to enroll you in Rx Text alerts. Please try again later.
ERR_NET_FAIL We are unable to complete your request. Please try again later.
ERR_APP_ID_INCORRECT Requested application not found in the configuration file.
ALERT_ERR_INVALID_TIME Please select a valid store pickup time.
ALERT_NO_STORES_FOUND We are unable to locate any stores based on your current location.
ALERT_ERR_VALID_PHNO Customer entered a valid phone number.

Error Codes & Messages for Rx Transfer Service:

Error Code Description
632 Please enter all required information.
635 Sorry, failed to subscribe for text messages.
636 Invalid Pick-up Time.
633 Please enter a valid pharmacy phone number.
630 Please enter a valid phone number.
658 Missing device info.
603 We are unable to complete your request. Please try again later.
638 Invalid SMS OPT Service.
111,112,113,114,115,116,117 Configuration issues found in JSON body
118 A required attribute is missing in the request.
202 We are unable to complete your request. Please try again later.
205 No request parameters found.
209 We are unable to locate any stores based on your current location.
1003 We are unable to complete your request. Please try again later.
ERR_GEN_PDF We are unable to complete your request. Please try again later.
ERR_MISSING_MANDATORY_FLDS Please enter all required information.
ERR_INVALID_PH_NO Please enter a valid phone number.
ERR_INVALID_PHARMACY_PH_NO Please enter a valid pharmacy phone number.
ERR_NO_RESPONSE We are unable to complete your request. Please try again later.
ERR_DEFAULT We are unable to complete your request. Please try again later.
ALERT_NO_STORES_FOUND We are unable to locate any stores based on your current location.
ERR_APP_ID_INCORRECT Requested application not found in the configuration file.

App Version Parameter:

Description: Information about the version of your application the customer is using. Useful to us both for debugging product order issues/bugs.

Examples: "1.00" or "1.01" or "1.10" or "10.01"


Device Info Parameter:

Description: Information about the customers device

Examples:

Device OS Version devinf Value
iPhone 10.2 "iPhone,10.2"
iPad 10.2 "iPad,10.2"
iPod 10.2 "iPod,10.2"
Android 7.0 "Android,7.0"
Android Tablet 7.0 "AndroidTablet,7.0"
Chrome 43.0.1410.65 "Chrome,26.0"
Windows 8.1 "Windows,10.2"
Internet Explorer Browser "IE,11"
Safari Browser "Safari,6.0"
Opera Browser "Opera,12.15"

Disclaimer:

Consistent with the Terms of Use, your ability to launch a production integration of an Application is subject to approval by Walgreens.