Loyalty API

Read Call

EstimateAccrual1

Estimates how many loyalty points a customer would earn for a given order, with support for tier preview based on customer data.

Kind Read API call
Method GET or POST
URL https://app.bubblehouse.com/api/v20230601/<shop>/EstimateAccrual1
Authentication AnonymousCustomer TokenShop Token
You have a choice of making this call from your server using a shop token and specifying a customer ID, or making this call from a web browser/app using a customer token you have generated on the server.

This function allows you to predict how many points would be awarded for a specific order before it's actually placed or processed. This is useful for showing customers their potential point earnings during the checkout process.

The function uses the same Order2 format as the UpdateOrders4 call, making it easy to estimate points for an order before submitting it.

If customer identity is not provided or the customer doesn't exist, the function behaves as if invoked on an empty customer record.

EstimateAccrual1 can preview tier changes based on customer data provided in the order. If the order includes customer tags that would result in a different tier, the API calculates what tier the customer would be in based on the provided tags, and returns an accurate estimate based on the previewed tier, but does not persist the tier change beyond the scope of the call.

Input

  • customer CustomerIdentity1 optional

    Identity of the customer placing the order (optional if included in the order object).

  • order Order2 required

    The order to estimate points for, using the same format as UpdateOrders4.

    The order object can include customer data with tags, which will be used to preview tier changes for tag-based tier systems. The customer data in the order (including tags) affects the tier calculation but is not saved to the database.

    For tag-based tiers, include the customer's tags in order.customer.tags to get accurate point estimates based on the tier those tags would grant.

Output

  • pts integer required

    The estimated number of points the customer would earn for this order.

  • lines array of OrderLineDetails1 required

    Detailed breakdown of point calculations for each order line item.

    Each line item includes information about the subtotal, accrual amount, points, and any applicable multipliers or discounts.

  • accrual_debug_info string required

    Debug information about how the points were calculated.

    This is intended for development and troubleshooting, not for displaying to end users.

Usage Examples

Basic Point Estimation

For a simple point estimation without tier changes:

Request

{
  "order": {
    "amount_spent": "110.00",
    "amount_subtotal": "100.00",
    "id": "ORDER-123"
  }
}

Response

{
  "accrual_debug_info": "Base earning: 100 points (1:1 ratio)",
  "lines": [
    {
      "accrual_amount": "100.00",
      "id": "ORDER-123",
      "multiplier": 1,
      "pts": 100,
      "subtotal": "100.00"
    }
  ],
  "pts": 100
}

The customer earns 100 points based on the order amount. No tier changes occur in this basic scenario.

Estimation with Tier Preview

When using tag-based tiers, include customer tags to preview tier-specific multipliers:

Request

{
  "order": {
    "amount_spent": "110.00",
    "amount_subtotal": "100.00",
    "customer": {
      "id": "CUST-789",
      "tags": [
        "VIP",
        "Premium"
      ]
    },
    "id": "ORDER-456"
  }
}

Response

{
  "accrual_debug_info": "VIP tier multiplier applied: 2x points",
  "lines": [
    {
      "accrual_amount": "100.00",
      "id": "ORDER-456",
      "multiplier": 2,
      "pts": 200,
      "subtotal": "100.00",
      "tier_id": "TIER-VIP",
      "tier_name": "VIP Member"
    }
  ],
  "pts": 200
}

With the VIP tag, the customer receives a 2x multiplier on their points, earning 200 points instead of 100.

API-wide Errors

Status Error Reason & Examples
400 missing_customer_identity

The customer identity ('customer' input parameter) has not been specified when using a shop token. You need to either specify a non-empty value for one of the customer identity fields, or use a customer token.

404 empty_customer_identity

All fields of the customer identity ('customer' input parameter) have been empty when using a shop token. You need to either specify a non-empty value for one of the customer identity fields, or use a customer token.

403 customer_identity_does_not_match_token

API call is using a customer token, but the customer identity in API params does not match the customer from the token.

404 no_customers_match_customer_identity

The customer identity ('customer' input parameter) does not match a known customer.

404 customer_identity_partially_mismatches_matched_customer

A customer has been matched by one of the fields of the customer identity ('customer' input parameter), but some non-empty fields do not match Bubblehouse data on that customer.

Global Errors

Status Error Reason & Examples
400 obsolete_global_api_version

The global API version you are trying to use is no longer supported.

400 inaccessible_global_api_version

The global API version you are trying to use is not enabled on your account.

401 invalid_token

The provided authentication token is invalid or has expired.

429 rate_limit_exceeded

Your usage is over the rate limit. Ensure that you're not making duplicate calls, and contact our team for a rate limit increase.

400 invalid_global_api_version

The global API version you are trying to use has never existed.

Previous
CustomerReferrals2