> For the complete documentation index, see [llms.txt](https://devdocs.joy.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devdocs.joy.so/joy-javascript-api/joy-loyalty-sdk/public-api-action-methods.md).

# Public API action methods

This will cover all the posting data Javascript methods of the `joyInstance` object. These methods will take action on behalf of the current user such as: redeeming points, and getting referral links.

### Redeem a program

This method will call an API request to redeem the customer's balance for a coupon.\
It normally takes **2 parameters**: `programId` and `points` (optional).

* For fixed-point programs like **"Get 10% off for 100 points"**, the `points` parameter is not required.
* For dynamic redeem programs, customers must provide the number of points they want to redeem.

Additional parameter for Free Gift programs:

If the program type is **Free gift** and uses the option **"Free one product from selection"**, the method supports an additional **optional** parameter:

* `variantIdSelected` *(optional)* — the variant ID of the selected free gift product.

```javascript
joyInstance.redeem(programId, points, variantIdSelected).then(function(resp){
    console.log(resp)
});
```

Sample response:

```json
{
    "customer": {
        "id": "avsu0TQoHYd4Zq5TZnJg",
        "shopifyCustomerId": 6858989109535,
        "earnSignUp": true,
        "name": "admin super",
        "hasPoint": true,
        "state": "enabled",
        "shopId": "7vqeDbhZtyofeuH7l1ky",
        "type": "member",
        "acceptsMarketing": false,
        "urlReferral": "https://inviteee.to/i/5Nuw",
        "email": "anhth@avada.email",
        "createdAt": "2023-04-04T07:03:32.119Z",
        "totalSpent": 22,
        "latestActivity": "2023-06-14T04:45:55.465Z",
        "point": 9999800,
        "updatedAt": "2023-08-08T06:48:42.938Z",
        "appliedCollectionIds": []
    },
    "discount": {
        "id": "gid://shopify/DiscountCodeNode/1396689076511",
        "code": "JOY-1YOCADBV6JMW"
    }
}
```

### Generate referral link

This method will generate the referral link for the customer by their email. This will only create a new link if the customer matching the email has not created one. If not, it will return the existing referral link.

```javascript
joyInstance.generateLinkReferral(email).then(function(resp){
    console.log(resp)
});
```

Sample response:

```json
{
    "url":"https://inviteee.to/i/a8h3"
}
```

### Update date of birth

Our app stores customer birthdays in the format: DD/MM. You can update that on behalf of the logged-in user.

```javascript
joyInstance.updateDOB(month, day).then(function(resp){
    console.log(resp)
});
```

Sample response:

```json
{status: true}
```

### Revoke coupon

This API will enable a coupon revocation action for coupons at your customer's end.

```javascript
joyInstance.revokeCoupon(rewardId).then(function(resp){
    console.log(resp)
});
```

Sample response

```json
{status: true}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://devdocs.joy.so/joy-javascript-api/joy-loyalty-sdk/public-api-action-methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
