API Library
This section includes the four (4) AIR MILES Cash API endpoints listed below. Each page offers a brief summary of the API endpoint in question, common use-case scenarios, and sample request/response messages with response codes.
API endpoints
ECHO
Used to test and confirm that the real-time checkout platform is up and ready to process requests.
INQUIRE
Used to retrieve account balances and AIR MILES Cash offer information.
REDEEM
Used to redeem AIR MILES Cash Miles from a Collector’s account to be used towards their purchase.
REVERSE
Used to refund (aka reverse) an AM Cash Miles redemption.
Idempotent requests
All the API calls shown above (excluding ECHO
& INQUIRY
) support idempotency for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. For example, if a request to redeem miles from a Collector does not receive a response due to a network connection error, you can retry the request with the same idempotency key to guarantee that additional miles aren’t accidentally redeemed from the Collector’s account.
Note
To perform an idempotent request, you need to provide an additionalIdempotency-Key: <key>
header to the request.
What is an “Idempotency Key”
An “Idempotency Key” is a unique value generated by the client which the server uses to recognize subsequent retries of the same request. How you create unique keys is up to you, but we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions.
WARNING
If you omit the header in the request, then the content of the transaction itself will be used to detect if it’s a duplicate. This requires that you send the exact same request as before, including an identical timestamp. This process however does not guarantee idempotency and should only be used as a last resort.Sample header with Idempotency
curl -X POST https://cert.airmilesapis.ca/checkout/amcash/echo \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJ...' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: 123e4567-e89b-12d3-a456-426655440000' \
-d '{
Handling request/response messages
As described above, the RESTful specification defines a transaction as a pair of request and response messages that are used for information interchange.
Note
Mandatory parameters will be marked with an asterisk (*) in the subsequent pages.Message Type | Description |
---|---|
Request | |
Response | Content-Type is specified in the Header (e.g., application/json .responseCode .null or ‘empty’ values are automatically excluded from the response body. |
Handling request timeouts
A request timeout has likely occurred if either of the following are true.
- You received a Response Code of
0008
- You didn’t receive any response at all
Upon experiencing a request timeout, your POS terminal should immediately attempt to retry the same request. The reattempted request MUST be identical to the initial request.
Important
If the new request does not match exactly with the initial request, the system will not recognize it as a “retry” request, but will register it as a brand new transaction. If the request continues to timeout and/or fail, an error message should be displayed to the cashier, as suggested in the section Displaying the reversal result.If at any time, AIR MILES real-time encounters an internal problem or network error while trying to return a “redemption response” to the partner, the redemption request will be automatically cancelled. Thereby ensuring the customer is not charged for a redemption that could not be redeemed.
Note
- If the retry succeeds, then the transaction must be included in the reconciliation report sent to AIR MILES.
- If the retry fails, the transaction must NOT be included in the reconciliation report, as no Miles were processed for the transaction.
For all other Response codes; when a particular code is received (e.g., 0002
, 0096
, etc.), the appropriate message should be displayed to the cashier, as shown in POS Workflows > Redemption.
Status/response codes
Status Code | Response Code | Display Message | Description |
---|---|---|---|
200 |
0000 |
Approved | The transaction was successful. The POS terminal AND receipt should display the appropriate information. |
202 |
0001 |
Approved - balance suppressed | The transaction was successful, however the Collector opted to not view their rewards balances. The printed receipt MUST NOT show the Collector’s ‘Cash’/‘Dream’ balances, or the available “AM Cash” that can be redeemed. |
401 |
0002 |
Collector account inactive | The Collector account is not active. Please ask the Collector to visit the airmiles.ca self-serve page, online chat support, or contact our call-center. |
408 |
0008 |
Transaction timeout | The transaction timed out when a request was sent to the “Instant POS” Switch. The Partner’s Switch/POS Terminal should retry the request one (1) time. If a cashier receives this error, they should escalate the issue as indicated in the “AM Cash - Sponsor Escalation Guide”. |
403 |
0009 |
Card not swiped or scanned | Redemption offers will not be sent if the Collector Card is not presented. The Collector Card is physically required to perform instant cash redemptions. Please ask the Collector to visit the airmiles.ca self-serve page, online chat support, or contact our call-center to request a replacement card. |
401 |
0025 |
Invalid Collector number | The Collector number is invalid. Please ask the Collector to visit the airmiles.ca self-serve page, online chat support, or contact our call-center to request a replacement card. |
400 |
0035 |
Invalid request parameter | A mistake was made when submitting the request. Please correct the error and try again. |
202 |
0051 |
Insufficient reward miles | The Collector has not earned enough in their “AIR MILES Cash” balance for the requested redemption amount. Please ask the Collector to go to airmiles.ca and check their redemption/earning history. |
400 |
0057 |
Invalid redemption confirmation number | The redemptionConfirmationNumber submitted is invalid. Please resubmit the request with the correct Redemption Confirmation Number. |
202 |
0065 |
Exceeded daily redemption limit | The Collector has exceeded the daily redemption limit. The Collector’s account has exceeded the maximum daily redemption amount. Please ask the Collector to wait until the following day to redeem more Cash miles. |
202 |
0066 |
Insufficient basket size | The Collector’s basket size is too small to make a redemption. The purchase amount is not enough to make a redemption. Ask the customer if they wish to add more items to their basket in order to make an AM Cash redemption. |
408 |
0067 |
Offer is temporarily unavailable | The offer being requested is temporarily unavailable. Please advise the Collector to try redeeming this offer at a later time. |
409 |
0080 |
Reversal window expired | The reversal window for the redemption has expired; meaning a reversal can no longer be submitted for this transaction. This usually happens when a reversal is attempted after 3:00 AM the day after the original transaction. Any reversals that are attempted past the 3:00 AM time-frame should be refunded to the customer via in-store credit or gift card. Please DO NOT RETURN CASH to the customer. |
503 |
0092 |
Scheduled outage | The system is unavailable due to scheduled maintenance. No requests can be sent. |
500 |
0096 |
Server error or no response | An unknown error occurred while calling the “Instant POS” Switch". The Sponsor Switch/POS Terminal should retry one time and if the error persists, they should escalate the issue as indicated in the “AM Cash - Sponsor Escalation Guide”. |
null |
null |
Missing or invalid “bearer” token | No valid “Bearer Token” present. Please generate a valid “Bearer” Token and submit to continue." |