This is a multi-page printable view. Click here to print.

Or, return to the page.

API Library

Table of contents

This section provides information on the 3 API’s provided by the Offer Service.

Common Use Case

  • Get Offers By Province

    Request Response
    /offers?region=ON Get all offers in Ontario

  • Get Offers By Partner

    Request Response
    /offers?region=ON&partner_id=ID_1,ID_2 Get all offers related to partner with ID_1 OR ID_2, in Ontario

    ID_1 & ID_2 are UUID’s for partners. To get partner id for a specific partner check Mapping -> Partner documentation


Filter Combination

When multiple request parameters are passed, and/or multiple values are passed, the offers that satisfy the following logic are returned in the response.

(param1.valueA OR param1.valueB OR ...) AND (param2.valueX OR param2.valueY OR ...) AND (...)

For example, if request:

  • partner_id = A, B, C
  • category_id = X

/offers?region=ON&partner_id=A,B,C&category_id=X

Then the /offers response will return offers that satisfy: Offers where (partner=A OR partner=B OR partner=C) AND (category=X).

1 - GET /offers

Used to get multiple offers based on parametes.

GET /offers

This is the core API for Offer Service. API to get all details for displaying offers to collectors and the general public. This API has multiple query paramenter and headers that can change the response of the offers returned in varios ways.

Query Parameters

Name Rquired Type Discription
region ✔️ String (single value) Will only show offers from a single region
partner_id UUID (multiple value) Will return offers with only the provided parters
category_id UUID (multiple value) Will return offers with only the provided category
subcategory_id UUID (multiple value) Will return offers with only the provided subcategory
promotion_id UUID (single value) Will return offers with only the provided promotion
type String (multiple value) Specify offer types. ie: buy, spend, amCashEarn, amCashDiscount
program_type String (multiple value) Specify offer program types. allowed values: traditionalcore, cardlinked, airmilesshops, bmopreapp
availability String (multiple value) Specify where offer is avaliable. allowed values: online, in-store
sort String (multiple value) Specify the order of the offers returned, check allowed values list.
offset Number (int) Specify how many offers to skip at the begining and then start showing the offers.
limit Number (int, min = 1, max = 96) Specify the number of offers to return

Authenticated

When calling /offers with a token (as a collector), a few more query paramaters are available to use in addition to all the ones metioned above.

Name Rquired Type Discription
states String (single value) Specify offers that have been interacted in some way by the collector. allowed values: SAVED, OPTED_IN
mass_offer Boolean Specify to show offers that are targeted, when mass_offer = false

Sort Value and Behaviours

Behaviour Sort Value Need Authentication? Discription
Default [promotionId,massOffer,…] Offers are grouped and sorted by promotion id, mass offer, and then ranked by partner priority, and then sorted by offer priority. This is the default sort used on the AirMiles website and mobile.
Ending soon [..] Offers are sorted by End Date first, grouped and sorted by partner priority second, and finally sorted by offer priority.
Collector Relevance [collectorRelevance] ✔️ This is sorting based on Collector prefrences powered by magic.
Region Relevance [regionRelevance] This is sorting based on most popular offers in the region powered by more magic.

Headers

Name Rquired Type Discription
X-Correlation-Id UUID This is used to track the request through the logs, if not provided it will be auto generated by API and returned in the header response
X-Origin-Client ✔️ String This field is to let us know where the request is coming from. ie: internal:amrp:postman, external:web:bmo
Accept-Language String - Locale This is let API know if you want the response back in some supported language. Allowed value: en-US, fr-CA

Authenticated

To make authenticated request you need an additional header. The tokens that are supported are member tokens, these tokens have an associated collecter specification.

Name Rquired Type Discription
Authorization Bearer {token} Specifies a collector when making call to this api. This will give the ability to see the offers tarrgeted for that collector and the states of offers

Response

The response has two main section offers and metadata. The latter is very simple just containing total count of offers that match the given filters in the query parameter.

lets focus on the offers:[] list which is a list of offer objects, lets talk about some key information thats returned to us in these offer objects (for full list of values retuned, check out Sample Response) :

Name Type Discription
id UUID Offer object ID
partnerId UUID Associated partner id
categoryId UUID Associated category id
awardShort String description of the award associated with offer
qualifierShort String Short description of what is needed to qualify for offer award
displayDate LocalDateTime When can this offer show up for collectors
startDate LocalDateTime When can this offer be avalilable for use by collectors. Usually same as displayDate
endDate LocalDateTime When can this offer be marked as expired so that no more collectors are able to see/use it
massOffer Boolean true = Offer is publicly avaliable, false = Offer is targeted to specific collectors.
tiers List<tier> Offers can have multiple qualifers and each can have a different award
mechanisms List How to qualify for the offer
states List<States> Authenticated Request Only Will give a list of states which are object showing the name, value and when it was updated
legalText String Legal copy for offer

Sample

Request

GET /offers?region=ON&limit=1 HTTP/1.1
Host: cdn.airmilesapis.ca
X-Origin-Client: internal:amrp:postman
Authorization: Bearer `TOKEN`

Response Body

{
  "offers": [
    {
      "id": "4a80ad4a-de28-4c77-8180-0a89a71f4a55",
      "partnerId": "3267588b-791d-49bc-a321-d85d5f818480",
      "partnerLabel": "AIR MILES",
      "partnerLogo": {
        "url": "https://dev.cdn.airmilesapis.ca/partner-logo/7m10wxejlkq7/69ZErUapt6c8WQioe6iYSS/5107f862d6a2b238ff6f7739c5a90992/AIRMILES_PLANE_ELECTRIC_BLUE_RGB_E.png"
      },
      "partnerProfileURL": "https://www.airmiles.ca/en/offers/partners/air-miles-reward-program-bonus-offers.html",
      "categoryId": "121fa2dd-1fab-4492-8c5d-fb34624f4dda",
      "categoryLabel": "Travel",
      "awardShort": "You could win a Walt Disney World vacation from AIR MILES®",
      "qualifierShort": "Enter with your Collector info. Plus, earn 4 extra entries when you book any trip with AIR MILES® Travel.*",
      "image": {
        "url": "https://s3.amazonaws.com/prod-l1-amrpwl-post-images/processed-images/4008e08c-cd46-4429-bdc6-ce763cf4731a"
      },
      "displayDate": "2024-05-07T00:00:00",
      "startDate": "2024-05-07T00:00:00",
      "endDate": "2024-05-26T23:59:59",
      "description": "Contest ends May 26, 2024. Must be 18 years or older to enter. No purchase necessary. Contest Rules apply. ",
      "programType": "traditionalcore",
      "massOffer": true,
      "displayPriority": 1000,
      "tiers": [
        {
          "awardLong": "You could win a Walt Disney World vacation from AIR MILES®",
          "qualifierLong": "Enter with your Collector info. Plus, earn 4 extra entries when you book any trip with AIR MILES® Travel.*"
        }
      ],
      "mechanisms": [
        {
          "mechanismType": "button",
          "mechanismLabel": "Enter now",
          "mechanismValue": "https://www.airmiles.ca/arrow/Splash?splashId=26100080&changeLocale=en_CA"
        }
      ],
      "states": [
        {
          "name": "OPT_IN",
          "value": "OPTED_IN",
          "updatedAt": "2024-04-29T13:56:09.083363Z"
        },
        {
          "name": "SAVE",
          "value": "SAVED",
          "updatedAt": "2024-04-29T13:56:09.082147Z"
        }
      ],
      "legalText": "The Contest runs from May 6, 2024 to May 26, 2024 and is open to Canadian resident AIR MILES® collectors who have reached the age of 18. *NO PURCHASE NECESSARY Collectors can visit https://airmiles.ca/magicalmemories\nto complete and submit the form and get 1x entry. To get 4 additional entries collectors must book any trip on AIR MILES Travel during the contest period and complete their trip by July 31, 2024 (or complete the alternative bonus entry method outlined in the full contest rules). Limit one (1) base entry and four (4) bonus entries per collector number. One (1) prize is available to be won consisting of a vacation for four (4) to the Walt Disney World Resort in Florida. Approximate Prize value is $10,219.00 USD ($13,285.00 CDN). Correctly answered math skill-testing question required upon selection as a potential winner. Odds of winning depend on the number of eligible entries received. For full contest rules and details, visit https://airmiles.ca/magicalmemories\n\n®™ Trademarks of AM Royalties Limited Partnership used under license by AIR MILES Loyalty Inc.\n"
    }
  ],
  "metadata": {
    "total": 265
  }
}

Response Header

X-Correlation-Id a0ccb3a7-2b19-4916-8b7e-d3059ccc17bb

For support its best to keep track of the X-Correlation-Id value, as that can be used to track down logs for this request.

2 - GET /offers/{id}

Used to get single offer detail.

GET /offers/{id}

API to get all details for displaying a specific offer to collectors and the general public. This API has limited query paramenter as this is accessing a specific offer resource.

Path Parameter

Name Rquired Type Discription
id ✔️ UUID (single value) Returns the offer detail associated with this id

Query Parameter

Name Rquired Type Discription
region ✔️ String (single value) Will only show offers from a single region

Headers

Name Rquired Type Discription
X-Correlation-Id UUID This is used to track the request through the logs, if not provided it will be auto generated by API and returned in the header response
X-Origin-Client ✔️ String This field is to let us know where the request is coming from. ie: internal:amrp:postman, external:web:bmo
Accept-Language String - Locale This is let API know if you want the response back in some supported language. Allowed value: en-US, fr-CA

Authenticated

To make authenticated request you need an additional header. The tokens that are supported are member tokens, these tokens have an associated collecter specification.

Name Rquired Type Discription
Authorization Bearer {token} Specifies a collector when making call to this api. This will give the ability to see the offers states for the collector

Response

The response has two main section offers and warning.

The warning object has two states depending on region query parameter, authentication header and offer id passed:

  "warning":null

OR

  "warning": {
        "errorCode": "String - errCodes",
        "message": "String"
    }

Error Code

name Offer Returned description
err-login-required YES When viewing a targetted offer without any authorization header
err-region YES When viewing an offer that does not match the region query parameter in the request
err-not-found NO Offer Id does not exist, Offer Id not valid
err-expired NO Offer is expired
err-not-live NO Future offer, Not live yet (current date < display start date)
err-exclusive NO Targeted Offer - Collector is not eligible for the Offer

lets talk about some key information thats returned to us in the offer objects (for full list of values retuned, check out Sample Response) :

Name Type Discription
id UUID Offer object ID
partnerId UUID Associated partner id
categoryId UUID Associated category id
awardShort String description of the award associated with offer
qualifierShort String Short description of what is needed to qualify for offer award
displayDate LocalDateTime When can this offer show up for collectors
startDate LocalDateTime When can this offer be avalilable for use by collectors. Usually same as displayDate
endDate LocalDateTime When can this offer be marked as expired so that no more collectors are able to see/use it
massOffer Boolean true = Offer is publicly avaliable, false = Offer is targeted to specific collectors.
tiers List<tier> Offers can have multiple qualifers and each can have a different award
mechanisms List How to qualify for the offer
states List<States> Authenticated Request Only, Will give a list of states which are object showing the name, value and when it was updated
legalText String Legal copy for offer

Sample

Request

GET /offers/4a80ad4a-de28-4c77-8180-0a89a71f4a55?region=ON HTTP/1.1
Host: cdn.airmilesapis.ca
X-Origin-Client: internal:amrp:postman
Authorization: Bearer `TOKEN`

Response Body

{
  "offer": {
    "id": "4a80ad4a-de28-4c77-8180-0a89a71f4a55",
    "partnerId": "3267588b-791d-49bc-a321-d85d5f818480",
    "partnerLabel": "AIR MILES",
    "partnerLogo": {
      "url": "https://dev.cdn.airmilesapis.ca/partner-logo/7m10wxejlkq7/69ZErUapt6c8WQioe6iYSS/5107f862d6a2b238ff6f7739c5a90992/AIRMILES_PLANE_ELECTRIC_BLUE_RGB_E.png"
    },
    "partnerProfileURL": "https://www.airmiles.ca/en/offers/partners/air-miles-reward-program-bonus-offers.html",
    "categoryId": "121fa2dd-1fab-4492-8c5d-fb34624f4dda",
    "categoryLabel": "Travel",
    "awardShort": "You could win a Walt Disney World vacation from AIR MILES®",
    "qualifierShort": "Enter with your Collector info. Plus, earn 4 extra entries when you book any trip with AIR MILES® Travel.*",
    "image": {
      "url": "https://s3.amazonaws.com/prod-l1-amrpwl-post-images/processed-images/4008e08c-cd46-4429-bdc6-ce763cf4731a"
    },
    "displayDate": "2024-05-07T00:00:00",
    "startDate": "2024-05-07T00:00:00",
    "endDate": "2024-05-26T23:59:59",
    "description": "Contest ends May 26, 2024. Must be 18 years or older to enter. No purchase necessary. Contest Rules apply. ",
    "programType": "traditionalcore",
    "massOffer": true,
    "eventBasedOffer": false,
    "displayPriority": 1000,
    "tiers": [
      {
        "awardLong": "You could win a Walt Disney World vacation from AIR MILES®",
        "qualifierLong": "Enter with your Collector info. Plus, earn 4 extra entries when you book any trip with AIR MILES® Travel.*"
      }
    ],
    "mechanisms": [
      {
        "mechanismType": "button",
        "mechanismLabel": "Enter now",
        "mechanismValue": "https://www.airmiles.ca/arrow/Splash?splashId=26100080&changeLocale=en_CA"
      }
    ],
    "states": [
      {
        "name": "OPT_IN",
        "value": "OPTED_IN",
        "updatedAt": "2024-04-29T13:56:09.083363Z"
      },
      {
        "name": "SAVE",
        "value": "SAVED",
        "updatedAt": "2024-04-29T13:56:09.082147Z"
      }
    ],
    "legalText": "The Contest runs from May 6, 2024 to May 26, 2024 and is open to Canadian resident AIR MILES® collectors who have reached the age of 18. *NO PURCHASE NECESSARY Collectors can visit https://airmiles.ca/magicalmemories\nto complete and submit the form and get 1x entry. To get 4 additional entries collectors must book any trip on AIR MILES Travel during the contest period and complete their trip by July 31, 2024 (or complete the alternative bonus entry method outlined in the full contest rules). Limit one (1) base entry and four (4) bonus entries per collector number. One (1) prize is available to be won consisting of a vacation for four (4) to the Walt Disney World Resort in Florida. Approximate Prize value is $10,219.00 USD ($13,285.00 CDN). Correctly answered math skill-testing question required upon selection as a potential winner. Odds of winning depend on the number of eligible entries received. For full contest rules and details, visit https://airmiles.ca/magicalmemories\n\n®™ Trademarks of AM Royalties Limited Partnership used under license by AIR MILES Loyalty Inc.\n"
  },
  "warning": null
}

Response Header

X-Correlation-Id a7b3b6a8-f033-4e78-804e-f1990f317515

For support its best to keep track of the X-Correlation-Id value, as that can be used to track down logs for this request.

3 - PUT /offers/{id}/states

Used to update single offer state for a collector.

PUT /offers/{id}/states

API to update the state of an offer for a given collector. This API can only be used with a Authorization token, as thats how the API knows which collector should be associated with the action.

Path Parameter

Name Rquired Type Discription
id ✔️ UUID (single value) Identify the offer to updated its state

Request Body

required

{
  "states": [
    {
      "name": "name1",
      "value": "value1"
    }
  ]
}

The request body contains a states: [] list which can contain multiple state objects.

Name Rquired Type Discription
name ✔️ String This specifies the type of state to update, as of now we support SAVE and OPT_IN
value ✔️ String The values associated with the state to update. For name equals SAVE valid value is SAVED OR UNSAVED, for name equals OPT_IN valid value is OPTED_IN

Headers

Name Rquired Type Discription
X-Correlation-Id UUID This is used to track the request through the logs, if not provided it will be auto generated by API and returned in the header response
X-Origin-Client ✔️ String This field is to let us know where the request is coming from. ie: internal:amrp:postman, external:web:bmo
Authorization ✔️ Bearer {token} Specifies a collector when making call to this api.

Response

As this is a PUT request there is no response body. Check for status code 204 No Content for successful request.

Sample

Request

PUT /offers/e6528c38-6642-497d-85ca-f71cc5a74583/states HTTP/1.1
Host: cdn.airmilesapis.ca
Authorization: Bearer {JWT_TOKEN}
x-origin-client: internal:amrp:postman
Content-Type: application/json
Content-Length: 102

{
    "states": [
        {
            "name": "SAVE",
            "value": "SAVED"
        }
    ]
}

Response

Body

Status Code

Status-Code: 204 No Content
X-Correlation-Id a7b3b6a8-f033-4e78-804e-f1990f317515

For support its best to keep track of the X-Correlation-Id value, as that can be used to track down logs for this request.