• Example searches: “transaction”, “CreateOrder”, “/v2/locations”, “inventory”, “delete customer”

You are viewing an old version of the API
Calculate loyalty points

POST /v2/loyalty/programs/{program_id}/calculate

Calculates the points a purchase earns.

  • If you are using the Orders API to manage orders, you provide order_id in the request. The endpoint calculates the points by reading the order.
  • If you are not using the Orders API to manage orders, you provide the purchase amount in the request for the endpoint to calculate the points.

An application might call this endpoint to show the points that a buyer can earn with the specific purchase.


Permissions
LOYALTY_READ
Try in API Explorer
Name Description
program_id
string

Required

The loyalty program ID, which defines the rules for accruing points.

Name Description
order_id
string

The order ID for which to calculate the points. Specify this field if your application uses the Orders API to process orders. Otherwise, specify the transaction_amount.

transaction_amount_money
Money

The purchase amount for which to calculate the points. Specify this field if your application does not use the Orders API to process orders. Otherwise, specify the order_id.

Response Fields

Name Description
errors
Error [ ]

Any errors that occurred during the request.

points
integer (32-bit)

The points that the buyer can earn from a specified purchase.

Examples

You are viewing an old version of the API
POST /v2/loyalty/programs/{program_id}/calculate
cURL
  • cURL
  • Ruby
  • Python
  • C#
  • Java
  • PHP
  • Node.js
curl https://connect.squareup.com/v2/loyalty/programs/d619f755-2d17-41f3-990d-c04ecedd64dd/calculate \
  -X POST \
  -H 'Square-Version: 2021-05-13' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "order_id": "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY"
  }'
Response JSON
{
  "points": 6
}

Share Feedback

Thanks for visiting the Square API documentation. What's on your mind?