> For the complete documentation index, see [llms.txt](https://rymera.gitbook.io/advanced-coupons-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rymera.gitbook.io/advanced-coupons-api/coupons-v1-acfwp/virtual-coupons/query-a-list-of-virtual-coupons.md).

# Query a list of virtual coupons

## GET: /wp-json/coupons/v1/virtualcoupons

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

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

| Method | Endpoint                           |
| ------ | ---------------------------------- |
| GET    | /wp-json/coupons/v1/virtualcoupons |

| Query Parameters | Required | Type                   | Default       | Description                                                                                              |
| ---------------- | -------- | ---------------------- | ------------- | -------------------------------------------------------------------------------------------------------- |
| search           | no       | string                 |               | Search for virtual codes by name                                                                         |
| status           | no       | string                 |               | Valid virtual coupon status (used\|pending)                                                              |
| coupon\_id       | ​no      | ​integer \| integer\[] | 0             | ​Coupon ID(s)                                                                                            |
| user\_id         | no       | ​integer \| integer\[] | 0             | Customer ID(s)                                                                                           |
| date\_created    | no       | string                 |               | <p>A valid date text in mysql format. <br><em>Y-m-d H:i:s</em></p><p></p>                                |
| page             | no       | integer                | 1             | Current page to load in query.                                                                           |
| per\_page        | no       | integer                | 10            | Number of virtual coupons to list in a single page.                                                      |
| sort\_by         | no       | string                 | date\_created | Value to be based for sorting. (code\|date\_created\|id\|user\_id\|status\|date\_expire)                 |
| sort\_order      | no       | string                 | desc          | Order of sorting: `desc` or `asc`                                                                        |
| codes\_only      | no       | boolean                | false         | Return list of codes only when set to true.                                                              |
| date\_format     | no       | string                 | F j, Y g:i a  | Date format of virtual coupon date values. See here: <https://www.php.net/manual/en/datetime.format.php> |

{% endtab %}

{% tab title="Request Example" %}
Get virtual coupons for coupon with id of **207**

```
GET: http://example.com/wp-json/coupons1/v1/virtualcoupons?coupon_id=207
```

Get all virtual coupon, but coupon code's only for the main coupon with id of **207**

```
GET: http://example.com/wp-json/coupons1/v1/virtualcoupons?coupon_id=207&codes_only=1&page=-1
```

{% endtab %}

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

Get virtual coupons

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

[
    ...
    {
        "key": "116",
        "id": 116,
        "code": "67FQRYUYCT",
        "main_code": "bogo1",
        "coupon_code": "bogo1-67fqryuyct",
        "status": "pending",
        "coupon_id": 207,
        "user_id": 0,
        "user_fullname": "",
        "user_email": "",
        "date_created": "June 25, 2021 8:45 am",
        "date_expire": ""
    },
    ...
]
```

Get virtual coupon codes only

```
[
  "bogo1-67fqryuyct",
  "bogo1-wuujfbsk44",
  "bogo1-cje5svg862",
  "bogo1-pmd8ukcuep",
  "bogo1-m7w4zwbanp",
  "bogo1-n8ywtbjywy",
  "bogo1-2xagjdntw3",
  "bogo1-75hp7usjc5",
  ...
]
```

**Status: 403 Forbidden**

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

{% endtab %}
{% endtabs %}
