---
description: /loyalty-program/v1/customers
---

# Customers

The admin customers API allows you to search for customers, view a specific customers data (status, sources and history) and adjust their unclaimed points (increase or decrease).‌

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

Search customers based on id, first name, last name, email, meta values, etc.

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

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method | Endpoint                              |
| ------ | ------------------------------------- |
| GET    | /wp-json/loyalty-program/v1/customers |

| Query Parameters | Required | Type    | Description     |
| ---------------- | -------- | ------- | --------------- |
| ​search          | ​true    | ​string | ​search keyword |
{% endtab %}

{% tab title="Request Example" %}
Get all customers

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

Searching for customers

```
GET: http://example.com/wp-json/loyalty-program/v1/customers?search=dummy
```
{% endtab %}

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

Get all customers / Searching for customers

```
[
    ...
    {
        "id": 17,
        "name": "John Smith",
        "email": "johnsmith@example.com",
    },
    ...
}
```

**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/customers/status/{user\_id} <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Get customer's points status and sources data.

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

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method | Endpoint                                                |
| ------ | ------------------------------------------------------- |
| GET    | /wp-json-loyalty-program/v1/customers/status/{user\_id} |
{% endtab %}

{% tab title="Request Example" %}
Get customer points status data

```
GET: http://example.com/wp-json/loyalty-program/v1/customers/status/17
```
{% endtab %}

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

```
{
    "status": [
        {
            "label": "Total Points (All Time)",
            "points": 61,
            "value": "$6.10"
        },
        {
            "label": "Unclaimed Points",
            "points": 61,
            "value": "$6.10"
        },
        {
            "label": "Claimed Points",
            "points": 0,
            "value": "$0.00"
        },
        {
            "label": "Expired Points",
            "points": 0,
            "value": "$0.00"
        }
    ],
    "sources": [
        {
            "label": "Purchasing products",
            "points": 61
        },
        {
            "label": "Leaving a product review",
            "points": 0
        },
        {
            "label": "Commenting on a blog post",
            "points": 0
        },
        {
            "label": "Registering as a user/customer",
            "points": 0
        },
        {
            "label": "After completing first order",
            "points": 0
        },
        {
            "label": "Spending over a certain amount",
            "points": 0
        },
        {
            "label": "Extra points during a period",
            "points": 0
        }
    ]
}
```

**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/customers/history/{user\_id}

Get customer's points history data.

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

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method | Endpoint                                                 |
| ------ | -------------------------------------------------------- |
| GET    | /wp-json/loyalty-program/v1/customers/history/{user\_id} |

| 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 points history (10 entries)

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

Get next page of history entries

```
GET: http://example.com/wp-json/loyalty-program/v1/customers/history/17?page=2
```
{% endtab %}

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

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


JSON Body:
[
    ...
    {
        "id": 101,
        "object_id": 258,
        "action": "buy_product",
        "date": "01/27/2021 08:55:54",
        "activity": "Purchasing products",
        "points": 61,
        "rel_link": "http://acfw.test/wp-admin/post.php?post=258&action=edit",
        "rel_label": "View Order"
    }
    ...
]
```

**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/customers/points/{user\_id}

Adjust customer's unclaimed points.

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

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method | Endpoint                                                |
| ------ | ------------------------------------------------------- |
| POST   | /wp-json/loyalty-program/v1/customers/points/{user\_id} |

| Query Parameters | Required | Type    | Description                           |
| ---------------- | -------- | ------- | ------------------------------------- |
| ​type            | ​true    | ​string | `​increase` or `decrease`             |
| points           | true     | integer | Number of points to increase/decrease |
{% endtab %}

{% tab title="Request Example" %}
Increase customer's points

```
POST: http://example.com/wp-json/loyalty-program/v1/customers/points/17

JSON Body:
{
    "type": "increase",
    "points": 50
}
```

Decrease customer's points

```
POST: http://example.com/wp-json/loyalty-program/v1/customers/points/17

JSON Body:
{
    "type": "decrease",
    "points": 50
}
```
{% endtab %}

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

Increase customer's points

```
{
    "message": "Successfully adjusted points for customer.",
    "status": [
        {
            "label": "Total Points (All Time)",
            "points": 111,
            "value": "$11.10"
        },
        {
            "label": "Unclaimed Points",
            "points": 111,
            "value": "$11.10"
        },
        {
            "label": "Claimed Points",
            "points": 0,
            "value": "$0.00"
        },
        {
            "label": "Expired Points",
            "points": 0,
            "value": "$0.00"
        }
    ],
    "sources": [
        {
            "label": "Purchasing products",
            "points": 61
        },
        {
            "label": "Leaving a product review",
            "points": 0
        },
        {
            "label": "Commenting on a blog post",
            "points": 0
        },
        {
            "label": "Registering as a user/customer",
            "points": 0
        },
        {
            "label": "After completing first order",
            "points": 0
        },
        {
            "label": "Spending over a certain amount",
            "points": 0
        },
        {
            "label": "Extra points during a period",
            "points": 0
        }
    ]
}
```

**Status: 200 OK**

Decrease customer's points

```
{
    "message": "Successfully adjusted points for customer.",
    "status": [
        {
            "label": "Total Points (All Time)",
            "points": 1,
            "value": "$0.10"
        },
        {
            "label": "Unclaimed Points",
            "points": 1,
            "value": "$0.10"
        },
        {
            "label": "Claimed Points",
            "points": 0,
            "value": "$0.00"
        },
        {
            "label": "Expired Points",
            "points": 0,
            "value": "$0.00"
        }
    ],
    "sources": [
        {
            "label": "Purchasing products",
            "points": 61
        },
        {
            "label": "Leaving a product review",
            "points": 0
        },
        {
            "label": "Commenting on a blog post",
            "points": 0
        },
        {
            "label": "Registering as a user/customer",
            "points": 0
        },
        {
            "label": "After completing first order",
            "points": 0
        },
        {
            "label": "Spending over a certain amount",
            "points": 0
        },
        {
            "label": "Extra points during a period",
            "points": 0
        }
    ]
}
```

**Status: 403 Forbidden**

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

