Add item to cart

Description

This service adds a specified quantity of an item to the cart for a given mileage activity.


Request

Restrictions

This service requires an authenticated user and can only be called after a successful consumer login.

Endpoint

POST https://<server-url>/api/v4/mileage/{activity_code}/cart/items

Path Parameters

Parameter
Type
Description

activity_code

String

The unique code for the mileage activity (e.g., "MPOINTS").

Parameters

Parameter
Location
Description

touchpoint

Query / Header

The identifier for the touchpoint. Use Thalamus-Touchpoint for the header.

token

Query / Header

The authentication token for the API session. Use Thalamus-Token for the header.

Full URL Example

https://<server-url>/api/v4/mileage/MPOINTS/cart/items?touchpoint=test&token=...

Request Body

The body of the request must specify the item's code and the quantity to add.

Field
Type
Description

itemCode

String

The unique code of the item to add to the cart.

quantity

Integer

The number of units of the item to add.

JSON

{
  "itemCode": "CD",
  "quantity": 5
}

Response

✅ Successful Response: 201 Created

The item was successfully added to the cart. The response returns the updated session context, including the new cartTotal and accountBalance in the personStatus object.

JSON

{
  "context": {
    "links": [
      {
        "ref": "home",
        "href": "/api/v4/people/home"
      }
    ],
    "activities": [
      {
        "code": "MPOINTS",
        "name": "ML Points",
        "message": "This is a message",
        "type": "MILEAGE",
        "personStatus": {
          "accountBalance": 100,
          "accountLeft": 50,
          "cartTotal": 50,
          "quantityItemsInCart": 5,
          "state": "Active"
        }
      }
    ],
    "simpleProfile": {
      "firstname": "test",
      "lastname": "test",
      "email": "[email protected]"
    }
  }
}

❌ Unsuccessful Response: 400 Bad Request

Returned if the item is invalid (e.g., out of stock) or the consumer has insufficient points.

JSON

{
  "errors": {
    "item": "InvalidID",
    "account": "NotEnoughPoints"
  }
}

❌ Unsuccessful Response: 404 Not Found

Returned if the specified activity_code or itemCode does not exist.

JSON

{
  "errors": {
    "error.message": "NOT_FOUND"
  }
}

Last updated

Was this helpful?