> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yuko.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Points estimate

Estimates how many loyalty points a customer will earn for a given set of cart items. Customer is optional — guest checkouts are fully supported.

**POST /public/points/estimate**

#### **Authorizations**

**Authorization**

**string**

**header**

**required**

Bearer authentication header of the form `Bearer <token>`, where `<token>` is your REST API token.

#### **Request Body**

**customer**

**object | null**

The customer placing the order. Optional — omit entirely for guest checkouts.

Show child attributes

**customer.id**

**string | null**

The platform customer ID. Used to look up the customer if `email` is not provided.

Example:

`"cus_847362"`

**customer.email**

**string\<email> | null**

The customer's email address. Takes priority over `id` when both are provided.

Example:

`"rahul.sharma@example.com"`

**items**

**object\[]**

**required**

The line items in the cart. Must contain at least one item.

Show child attributes

**items\[].product\_id**

**string**

**required**

The platform product ID.

Example:

`"prod_1001"`

**items\[].variant\_id**

**string**

**required**

The platform variant/SKU ID.

Example:

`"var_1001_red_m"`

#### **Response**

**200 - application/json**

**data**

**object**

Hide child attributes

**data.points\_earned**

**integer**

The estimated number of loyalty points the customer will earn after completing the purchase.

Example:

`120`

**data.message**

**string**

A human-readable message to display to the customer.

Example:

`"You will earn 120 points after completing this purchase"`

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url "https://api.yukoapp.com/api/v1/public/points/estimate" \
    --header "Authorization: Bearer py_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    --header "Content-Type: application/json" \
    --data '{
      "customer": {
        "id": "cus_847362",
        "email": "rahul.sharma@example.com"
      },
      "items": [
        {
          "product_id": "prod_1001",
          "variant_id": "var_1001_red_m"
        },
        {
          "product_id": "prod_2044",
          "variant_id": "var_2044_black_42"
        }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.yukoapp.com/api/v1/public/points/estimate",
    {
      method: "POST",
      headers: {
        Authorization: "Bearer py_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        customer: {
          id: "cus_847362",
          email: "rahul.sharma@example.com",
        },
        items: [
          {
            product_id: "prod_1001",
            variant_id: "var_1001_red_m",
          },
          {
            product_id: "prod_2044",
            variant_id: "var_2044_black_42",
          },
        ],
      }),
    }
  );

  const data = await response.json();
  ```

  ```php PHP theme={null}
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://api.yukoapp.com/api/v1/public/points/estimate");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
      "customer" => [
          "id"    => "cus_847362",
          "email" => "rahul.sharma@example.com",
      ],
      "items" => [
          [
              "product_id" => "prod_1001",
              "variant_id" => "var_1001_red_m",
          ],
          [
              "product_id" => "prod_2044",
              "variant_id" => "var_2044_black_42",
          ],
      ],
  ]));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer py_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "Content-Type: application/json",
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  $data = json_decode($response, true);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": {
      "points_earned": 120,
      "message": "You will earn 120 points after completing this purchase"
    }
  }
  ```

  ```json 200 (guest checkout or no matching campaign) theme={null}
  {
    "data": {
      "points_earned": 0,
      "message": "You will earn 0 points after completing this purchase"
    }
  }
  ```

  ```json 422 (validation error) theme={null}
  {
    "error": {
      "code": "validation_error",
      "message": "The given data was invalid",
      "details": {
        "items": ["The items field is required."]
      }
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": "invalid_token",
      "message": "Invalid or revoked API token"
    }
  }
  ```
</ResponseExample>
