# My Points

the my points API is intended solely for frontend use on a customer's session. This allows you to process the following data:

* fetch user's points balance and worth
* fetch user's redeemed coupons
* fetch user's points history
* redeem coupons using user's earned points

### GE&#x54;**:** /wp-json/loyalty-program/v1/mypoints <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Fetch all sections of LPFW settings.

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* role is allowed to earn points

| Method       | Endpoint                             |
| ------------ | ------------------------------------ |
| GET          | /wp-json/loyalty-program/v1/mypoints |
| {% endtab %} |                                      |

{% tab title="Request Example" %}
Get current logged in user's points balance

```
GET: http://example.com/wp-json/loyalty-program/v1/mypoints
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Get current logged in user's points balance

```
{
    "points": 361,
    "worth": "$36.10",
    "expiry": "April 7, 2022 11:59 am"
}
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

### GE&#x54;**:** /wp-json/loyalty-program/v1/mypoints/coupons <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Fetch all sections of LPFW settings.

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* role is allowed to earn points

| Method | Endpoint                                     |
| ------ | -------------------------------------------- |
| GET    | /wp-json/loyalty-program/v1/mypoints/coupons |

| Query Parameters | Required | Type    | Description  |
| ---------------- | -------- | ------- | ------------ |
| ​page            | ​false   | ​number | ​Page number |

| Custom Response Headers | Type   | Description                     |
| ----------------------- | ------ | ------------------------------- |
| X-TOTAL                 | number | Total number of history entries |
| {% endtab %}            |        |                                 |

{% tab title="Request Example" %}
Get customer's most recent redeemed coupons (10 entries)

```
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/coupons
```

Get next page of redeemed coupon entries

```
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/coupons?page=2
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Get customer's most recent redeemed coupons (10 entries) / Get next page of redeemed coupon entries

```
Headers:
{
...
X-TOTAL: 15
}


JSON Body:
[
    ...
    {
        "id": 314,
        "code": "1mpwzrp",
        "amount": "$10.00",
        "date_created": "April 7, 2021 11:59 am",
        "date_expire": "April 2, 2022 12:00 am",
        "points": 100
    }
    ...
]
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

### GE&#x54;**:** /wp-json/loyalty-program/v1/mypoints/history

Get customer's points history data.

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* role is allowed to earn points

| Method | Endpoint                                     |
| ------ | -------------------------------------------- |
| GET    | /wp-json/loyalty-program/v1/mypoints/history |

| Query Parameters | Required | Type    | Description  |
| ---------------- | -------- | ------- | ------------ |
| ​page            | ​false   | ​number | ​Page number |

| Custom Response Headers | Type   | Description                     |
| ----------------------- | ------ | ------------------------------- |
| X-TOTAL                 | number | Total number of history entries |
| {% endtab %}            |        |                                 |

{% tab title="Request Example" %}
Get logged in user's most recent points history (10 entries)

```
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/history
```

Get next page of history entries

```
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/history?page=2
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

```
Headers:
{
...
X-TOTAL: 25
}


JSON Body:
[
    ...
    {
        "id": 116,
        "action": "coupon",
        "date": "04/07/2021 11:59:22",
        "activity": "Redeem Coupon",
        "points": 100,
        "rel_link": "http://acfw.test/coupon/1mpwzrp/",
        "rel_label": "Coupon: 1mpwzrp"
    }
    ...
]
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

### POS&#x54;**:** /wp-json/loyalty-program/v1/mypoints/redeem <a href="#post-wp-json-loyalty-program-v-1-customers-points-user_id" id="post-wp-json-loyalty-program-v-1-customers-points-user_id"></a>

Redeem points and create a coupon.

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* role is allowed to earn points

| Method | Endpoint                                    |
| ------ | ------------------------------------------- |
| POST   | /wp-json/loyalty-program/v1/mypoints/redeem |

| Query Parameters | Required | Type    | Description                |
| ---------------- | -------- | ------- | -------------------------- |
| points           | true     | integer | Number of points to redeem |
| {% endtab %}     |          |         |                            |

{% tab title="Response Example" %}
Redeem 50 points

```
POST: http://example.com/wp-json/loyalty-program/v1/mypoints/redeem

JSON Body:
{
    "points": 50
}
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Redeem 50 points

```
{
    "user_coupon": {
        "id": 315,
        "code": "1l6ywrm",
        "amount": "$5.00",
        "date_created": "April 7, 2021 1:57 pm",
        "date_expire": "April 7, 2022 1:57 pm",
        "link": "http://acfw.test/coupon/1l6ywrm/",
        "points": 50
    },
    "balance": {
        "points": 311,
        "worth": "$31.10",
        "expiry": "April 7, 2022 1:57 pm"
    },
    "message": "Points redeemed successfully!"
}
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rymera.gitbook.io/advanced-coupons-api/loyalty-program-v1-lpfw/my-points.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
