{
  "openapi": "3.1.0",
  "info": {
    "title": "JavaScript SDK Object Schemas",
    "version": "1.0.0",
    "description": "Object schemas for the Smile.io JavaScript SDK"
  },
  "components": {
    "schemas": {
      "ApiError": {
        "type": "object",
        "properties": {
          "status": {
            "type": "number",
            "description": "The HTTP status code from the API response, or `0` for network-level errors (e.g. the user is offline).",
            "example": 400
          },
          "message": {
            "type": "string",
            "description": "A human-readable error message describing what went wrong.",
            "example": "An invalid `token` value was provided."
          },
          "requestId": {
            "type": "string",
            "description": "A unique identifier for the request, useful when contacting Smile's support team.",
            "example": "5b36eda6-1460-44c2-95cb-bd38755e5451"
          }
        },
        "required": []
      },
      "Activity": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Unique identifier for the activity.",
            "example": 503256787
          },
          "customerId": {
            "type": "integer",
            "description": "The ID of the customer who performed the activity.",
            "example": 304169228
          },
          "token": {
            "type": "string",
            "description": "A token identifying the activity that was performed.",
            "example": "activity_f57a9b5a8d0ac5"
          },
          "distinctId": {
            "type": "string",
            "description": "A unique identifier for the activity in the external system (e.g. the order number). When provided, it must be unique among activities with the same token. Creating a second activity with the same token and distinctId will fail, preventing duplicates.",
            "example": "212993"
          },
          "createdOnOriginAt": {
            "type": "string",
            "description": "The date and time the activity was performed by the customer in the external system (e.g. when the action actually occurred, which is often earlier than when the activity is created in Smile).",
            "example": "2024-04-04T15:10:42.030Z",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time when the activity was created.",
            "example": "2024-05-15T08:35:08.920Z",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "The date and time when the activity was last updated.",
            "example": "2024-05-15T08:35:08.920Z",
            "format": "date-time"
          }
        },
        "required": []
      },
      "CustomerPointsWallet": {
        "type": "object",
        "properties": {
          "balance": {
            "type": "integer",
            "description": "The customer's current points balance.",
            "example": 100
          }
        },
        "required": []
      },
      "CustomerVipStatus": {
        "type": "object",
        "properties": {
          "progressValue": {
            "type": "number",
            "format": "float",
            "description": "The amount the customer has already spent or earned within the current VIP period.",
            "example": 300.0
          },
          "vipTier": {
            "type": ["object", "null"],
            "description": "A partial representation of the customer's current VIP tier. A `null` value indicates that the customer is not in a VIP tier.",
            "properties": {
              "id": {
                "type": "integer",
                "description": "The unique identifier of the VIP tier.",
                "example": 426715794
              },
              "name": {
                "type": "string",
                "description": "The name of the VIP tier.",
                "example": "Silver"
              }
            }
          },
          "vipTierExpiresAt": {
            "type": ["string", "null"],
            "description": "The date the customer's current VIP tier expires. For all-time VIP programs, this will be `null` because tiers do not expire.",
            "format": "date-time",
            "example": "2026-12-31T23:59:59.999Z"
          },
          "deltaToRetainVipTier": {
            "type": ["number", "null"],
            "format": "float",
            "description": "The additional amount the customer must spend or earn before the end of the current VIP period to retain their VIP tier until the end of the next VIP period. For all-time VIP programs or if the customer has already spent or earned enough this period to retain their current VIP tier, this will be `null`.",
            "example": 123.0
          },
          "currentVipPeriodEnd": {
            "type": ["string", "null"],
            "description": "The end date for the current VIP period. For calendar-year VIP programs, this will be the end of the current calendar year. For all-time VIP programs, this will be `null`.",
            "format": "date-time",
            "example": "2025-12-31T23:59:59.999Z"
          },
          "nextVipTier": {
            "type": ["object", "null"],
            "description": "A partial representation of the next VIP tier that the customer will move into if they meet the minimum spending or earning requirement. If the customer is already in the highest tier, this will be `null`.",
            "properties": {
              "id": {
                "type": "integer",
                "description": "The unique identifier of the VIP tier.",
                "example": 426715799
              },
              "name": {
                "type": "string",
                "description": "The name of the VIP tier.",
                "example": "Gold"
              }
            }
          },
          "deltaToNextVipTier": {
            "type": ["number", "null"],
            "description": "The amount the customer must spend or earn within the current VIP period to reach the next VIP tier. If the customer is already in the highest tier, this will be `null`.",
            "example": 200.0
          }
        },
        "required": []
      },
      "EarningRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 739246764,
            "description": "Unique identifier for the earning rule."
          },
          "name": {
            "type": "string",
            "example": "Place an order",
            "description": "The display name of the earning rule."
          },
          "imageUrl": {
            "type": "string",
            "example": "https://platform.smile.io/images/earning/order-online.svg",
            "description": "The image of the earning rule."
          },
          "actionText": {
            "type": ["string", "null"],
            "example": null,
            "description": "The label for a clickable element (e.g. a call to action) that allows the customer to complete the rewardable action. When `null`, no clickable element should be displayed."
          },
          "actionUrl": {
            "type": ["string", "null"],
            "example": null,
            "description": "The destination URL for a clickable element (e.g. a call to action) that allows the customer to complete the rewardable action. When `null`, no clickable element should be displayed."
          },
          "restrictedToVipTierIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "example": 426715799
            },
            "description": "A list of VIP tier IDs. When present, the earning rule only applies to customers who currently belong to at least one of the specified VIP tiers. If the array is empty, the earning rule applies to all VIP tiers."
          },
          "reward": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": ["points"],
                "example": "points",
                "description": "The type of reward that will be issued."
              }
            },
            "description": "The reward that will be issued to the customer when the rewardable action is completed."
          },
          "rewardValue": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": ["variable", "fixed"],
                "example": "variable",
                "description": "The way that the reward's value will be computed."
              },
              "variable": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "number",
                    "format": "float",
                    "example": 5.0,
                    "description": "The amount of reward value issued per unit (e.g. if the reward is 5 Points per $1 spent, this field would be `5.0`)."
                  },
                  "perAmount": {
                    "type": "number",
                    "format": "float",
                    "example": 1.0,
                    "description": "The amount of action needed to earn the specified value (e.g. if the reward is 5 Points per $1 spent, this field would be `1.0`)."
                  }
                },
                "description": "The configuration for a variable reward value (e.g. points per dollar spent). Only present when type is `variable`, otherwise this key will be omitted from response."
              },
              "fixed": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "number",
                    "format": "float",
                    "example": 100.0,
                    "description": "The value of the reward that will be issued."
                  }
                },
                "description": "The configuration for a fixed reward value (e.g. 5 points). Only present when type is `fixed`, otherwise this key will be omitted from response."
              }
            },
            "description": "The value of the reward that will be issued to the customer when the rewardable action is completed."
          },
          "earningLimit": {
            "type": ["object", "null"],
            "properties": {
              "max": {
                "type": "integer",
                "example": 5,
                "description": "Maximum number of times a customer can complete the rule within the specified timeframe."
              },
              "type": {
                "type": "string",
                "enum": ["rolling", "lifetime"],
                "example": "rolling",
                "description": "The type of timeframe the limit applies to."
              },
              "rolling": {
                "type": "object",
                "properties": {
                  "unit": {
                    "type": "string",
                    "enum": ["day"],
                    "example": "day",
                    "description": "The rolling window's unit (e.g. if the window is 30 days, this field will have a value of `day`)."
                  },
                  "unitCount": {
                    "type": "integer",
                    "example": 30,
                    "description": "The number of units in the rolling window (e.g. if the window is 30 days, this field will have a value of `30`)."
                  }
                },
                "description": "The configuration for a rolling window of time. Only present when type is `rolling`, otherwise this key will be omitted from response."
              }
            },
            "description": "A restriction on the number of times the rewardable action can be completed. If no limit exists, will be `null`."
          }
        },
        "required": []
      },
      "PointsPurchase": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The unique identifier for the points purchase.",
            "example": 665523890
          },
          "pointsProductId": {
            "type": "integer",
            "description": "The unique identifier of the points product that was purchased.",
            "example": 132456921
          },
          "pointsSpent": {
            "type": "integer",
            "description": "The total points spent by the customer.",
            "example": 500
          },
          "rewardFulfillment": {
            "$ref": "#/components/schemas/RewardFulfillment",
            "description": "The nested Reward Fulfillment object representing the reward issued to the customer when they purchased the points product."
          },
          "createdAt": {
            "type": "string",
            "description": "Date and time at which the points purchase was created.",
            "format": "date-time",
            "example": "2024-12-07T20:15:27.893Z"
          },
          "updatedAt": {
            "type": "string",
            "description": "Date and time at which the points purchase was updated.",
            "format": "date-time",
            "example": "2024-12-07T20:15:27.893Z"
          }
        },
        "required": []
      },
      "RewardFulfillment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The unique identifier of the reward fulfillment.",
            "example": 625478984
          },
          "name": {
            "type": "string",
            "description": "The reward fulfillment's name.",
            "example": "$5 off coupon"
          },
          "code": {
            "type": "string",
            "description": "A unique code for the customer to use. This is commonly a discount code the customer applies at checkout on their next order, but it can be a unique code they use for other purposes like accessing an exclusive page on the merchant's website.",
            "example": "5off-e26d02e39149"
          },
          "fulfillmentStatus": {
            "type": "string",
            "enum": ["pending", "issued", "cancelled", "failed"],
            "description": "The fulfillment status of the reward fulfillment, indicating whether the reward is available to the customer. Possible values: \n- `pending` - The reward fulfillment is pending issuance. \n- `issued` - The reward fulfillment has been issued to the customer. \n- `cancelled` - The reward fulfillment has been cancelled. \n- `failed` - The reward fulfillment has failed to be issued.",
            "example": "issued"
          },
          "expiresAt": {
            "type": ["string", "null"],
            "description": "Date and time at which the code associated with the reward fulfillment expires and is no longer valid. If empty, the code does not expire.",
            "format": "date-time",
            "example": "2025-06-07T23:59:59.999Z"
          },
          "imageUrl": {
            "type": "string",
            "description": "The reward fulfillment's image.",
            "example": "https://platform-images.smilecdn.co/9283449.png"
          },
          "usedAt": {
            "type": ["string", "null"],
            "description": "Date and time at which the reward fulfillment was used by the customer. This field will be blank if the reward fulfillment has not yet been used, or if it does not support usage tracking.",
            "format": "date-time",
            "example": null
          },
          "createdAt": {
            "type": "string",
            "description": "Date and time at which the reward fulfillment was created.",
            "format": "date-time",
            "example": "2024-12-07T20:15:27.893Z"
          },
          "updatedAt": {
            "type": "string",
            "description": "Date and time at which the reward fulfillment was updated.",
            "format": "date-time",
            "example": "2024-12-07T20:15:27.893Z"
          }
        },
        "required": []
      },
      "Reward": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Unique identifier for the reward.",
            "example": 924565472
          },
          "name": {
            "type": "string",
            "description": "The name of the reward.",
            "example": "Order discount"
          },
          "description": {
            "type": ["string", "null"],
            "description": "A description of the reward.",
            "example": "Applies to one-time purchases."
          },
          "imageUrl": {
            "type": "string",
            "description": "An image for the reward.",
            "example": "https://platform-images.smilecdn.co/3755938.png"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time when the reward was created.",
            "example": "2024-04-04T15:10:42.030Z",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "The date and time when the reward was last updated.",
            "example": "2024-04-04T15:10:42.030Z",
            "format": "date-time"
          }
        },
        "required": []
      },
      "CustomerPointsProduct": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the reward that the customer will receive when their points are redeemed.",
            "example": "$5 off coupon"
          },
          "pointsPrice": {
            "type": "integer",
            "description": "Number of points needed to purchase this reward.",
            "example": "500"
          },
          "pointsProduct": {
            "$ref": "#/components/schemas/PointsProduct",
            "description": "A nested Points Product object representing the points product that this reward is based on."
          }
        },
        "required": []
      },
      "PointsSetting": {
        "type": "object",
        "properties": {
          "pointsLabel": {
            "type": "object",
            "description": "The branding of the account's points currency.",
            "properties": {
              "one": {
                "type": "string",
                "description": "The singular unit for a point.",
                "example": "Coin"
              },
              "other": {
                "type": "string",
                "description": "The unit for zero or many points.",
                "example": "Coins"
              }
            }
          }
        },
        "required": []
      },
      "ReferralSetting": {
        "type": "object",
        "properties": {
          "senderReward": {
            "type": "object",
            "description": "The reward that will be issued to a customer who successfully refers another individual to the loyalty program.",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name of the reward.",
                "example": "$5 off discount"
              },
              "image": {
                "type": "object",
                "description": "An image for the reward.",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "The URL of the image.",
                    "example": "https://platform-images.smilecdn.co/3755938.png"
                  },
                  "contentType": {
                    "type": ["string", "null"],
                    "description": "The MIME type of the image.",
                    "example": "image/png"
                  }
                }
              }
            }
          },
          "receiverReward": {
            "type": "object",
            "description": "The reward that will be issued to an individual who is referred to and joins the loyalty program.",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name of the reward.",
                "example": "5% off coupon"
              },
              "image": {
                "type": "object",
                "description": "An image for the reward.",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "The URL of the image.",
                    "example": "https://platform-images.smilecdn.co/3755938.png"
                  },
                  "contentType": {
                    "type": ["string", "null"],
                    "description": "The MIME type of the image.",
                    "example": "image/png"
                  }
                }
              }
            }
          }
        },
        "required": []
      },
      "PointsProduct": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Unique identifier for the points product."
          },
          "exchangeType": {
            "type": "string",
            "enum": ["fixed", "variable"],
            "description": "How points are exchanged for the reward. Possible values: \n- `fixed` - Customer must spend a fixed amount of points for a predetermined reward value. \n- `variable` - Customer can spend a variable amount of points for a dynamic reward value.",
            "example": "variable"
          },
          "exchangeDescription": {
            "type": "string",
            "description": "A human readable description of how a customer spends points on this reward. It includes the points branding for the program.",
            "example": "100 Points = $1 off"
          },
          "pointsPrice": {
            "type": ["integer", "null"],
            "description": "Number of points needed to purchase this reward. Only present when `exchangeType` is `fixed`.",
            "example": null
          },
          "variablePointsStep": {
            "type": ["integer", "null"],
            "description": "Imagine there's a points slider your customers can drag to spend more or less points on a reward. The `variablePointsStep` represents the number of points between each notch on the slider. E.g. If this value is set to 100, it means customers can spend their points in increments of 100. They will drag the slider from 100, 200, 300, etc. Only present when `exchangeType` is `variable`.",
            "example": 100
          },
          "variablePointsStepRewardValue": {
            "type": ["integer", "null"],
            "description": "Imagine there's a points slider your customers can drag to spend more or less points on a reward. The `variablePointsStepRewardValue` represents the corresponding reward value for each step increment on the slider. E.g. if this value is set to 1, and the `variablePointsStep` is set to 100, the customer will get $1 off for every 100 points they spend. Only present when `exchangeType` is `variable`.",
            "example": 1
          },
          "variablePointsMin": {
            "type": ["integer", "null"],
            "description": "The minimum amount of points the customer must spend to get this reward. Only present when `exchangeType` is `variable`.",
            "example": 100
          },
          "variablePointsMax": {
            "type": ["integer", "null"],
            "description": "The maximum amount of points the customer can spend on this reward. Only present when `exchangeType` is `variable`.",
            "example": 5000
          },
          "reward": {
            "$ref": "#/components/schemas/Reward",
            "description": "A nested Reward object representing the reward issued to the customer when they purchase the points product."
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time when the points product was created.",
            "format": "date-time",
            "example": "2024-04-04T15:10:42.030Z"
          },
          "updatedAt": {
            "type": "string",
            "description": "The date and time when the points product was last updated.",
            "format": "date-time",
            "example": "2024-04-04T15:10:42.030Z"
          }
        },
        "required": []
      },
      "VipTier": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The unique identifier of the VIP tier.",
            "example": 426715799
          },
          "name": {
            "type": "string",
            "description": "The display name of the VIP tier.",
            "example": "Gold"
          },
          "imageUrl": {
            "type": "string",
            "description": "The image of the VIP tier.",
            "example": "https://platform.smile.io/v1/images/vip_tiers/vip-tier-3.svg"
          },
          "milestone": {
            "type": "number",
            "format": "float",
            "description": "The threshold a customer must reach to be eligible for the VIP tier. Represents either points or a dollar amount depending on program configuration.",
            "example": 500.0
          },
          "perks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "A description of the benefit.",
                  "example": "Early access to new product releases"
                }
              }
            },
            "description": "Ongoing benefits a customer is entitled to when in the tier."
          },
          "entryRewards": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Reward"
            },
            "description": "Rewards issued to a customer when they enter the VIP tier."
          }
        },
        "required": []
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Unique identifier for the customer in Smile.",
            "example": 304169228
          },
          "firstName": {
            "type": "string",
            "description": "The customer's first name.",
            "example": "Jane"
          },
          "lastName": {
            "type": "string",
            "description": "The customer's last name.",
            "example": "Doe"
          },
          "email": {
            "type": "string",
            "description": "The customer's email address.",
            "example": "jane@doe.com"
          },
          "state": {
            "type": "string",
            "description": "The customer's state in the loyalty program. Possible values: \n- `candidate` - An individual that has not yet joined the loyalty program. Depending on program settings, they may or may not earn points. \n- `member` - An active loyalty program participant. \n- `disabled` - An individual that has been excluded from the program and cannot earn or redeem rewards.",
            "example": "member"
          },
          "dateOfBirth": {
            "type": "string",
            "description": "The customer's birthday. A year value of `1004` means only the customer's birth day and month is available.",
            "example": "1004-05-27"
          },
          "referralUrl": {
            "type": "string",
            "description": "The customer's unique referral URL. Used to share with friends as part of the referral program.",
            "example": "http://i.refs.cc/9qr5Pw"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time when the customer was created.",
            "example": "2024-04-04T15:10:42.030Z",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "The date and time when the customer was last updated.",
            "example": "2024-04-04T15:10:42.030Z",
            "format": "date-time"
          }
        },
        "required": []
      }
    }
  }
}
