> 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/create-a-virtual-coupon.md).

# Create a virtual coupon

### POS&#x54;**:** /wp-json/coupons/v1/virtualcoupons/‌ <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>

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

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

| Method | Endpoint                             |
| ------ | ------------------------------------ |
| POST   | /wp-json/coupons/v1/virtualcoupons/‌ |

| Query Parameters | Required | Type     | Description                                                                                                                                                                                         |
| ---------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ​coupon\_id      | ​yes     | ​integer | Coupon ID                                                                                                                                                                                           |
| status           | no       | string   | Valid virtual coupon status: `pending` or `used`                                                                                                                                                    |
| date\_created    | no       | string   | Date and time of virtual coupon was created                                                                                                                                                         |
| date\_expire     | no       | string   | Date and time for virtual coupon to be marked as expired.                                                                                                                                           |
| user\_id         | no       | integer  | Customer ID                                                                                                                                                                                         |
| date\_format     | no       | string   | <p>Date format of the provided date values. Default: Y-m-d H:i:s</p><p>See: <a href="https://www.php.net/manual/en/datetime.format.php"><https://www.php.net/manual/en/datetime.format.php></a></p> |

{% endtab %}

{% tab title="Request Example" %}
Create virtual coupon

```
POST: http://example.com/wp-json/coupons/v1/virtualcoupons/‌

JSON Body:
{
    "coupon_id": 207
}
```

Create virtual coupon with date expire

```
POST: http://example.com/wp-json/coupons/v1/virtualcoupons/‌

JSON Body:
{
    "coupon_id": 207,
    "date_expire": "January 1, 2022 10:00 am",
    "date_format": "F j, Y g:i a"
}
```

{% endtab %}

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

Create Virtual Coupon

```
{
  "message": "Successfully created virtual coupon.",
  "data": {
    "key": "467",
    "id": 467,
    "code": "S4WXTUG8DT",
    "main_code": "bogo1",
    "coupon_code": "bogo1-s4wxtug8dt",
    "status": "pending",
    "coupon_id": 207,
    "user_id": 0,
    "user_fullname": "",
    "user_email": "",
    "date_created": "2021-06-28 13:48:20",
    "date_expire": ""
  }
}
```

Create virtual coupon with date expire

```
{
  "message": "Successfully created virtual coupon.",
  "data": {
    "key": "468",
    "id": 468,
    "code": "QVJS2UYQFQ",
    "main_code": "bogo1",
    "coupon_code": "bogo1-qvjs2uyqfq",
    "status": "pending",
    "coupon_id": 207,
    "user_id": 0,
    "user_fullname": "",
    "user_email": "",
    "date_created": "June 28, 2021 1:50 pm",
    "date_expire": "January 1, 2022 10:00 am"
  }
}
```

**Status: 403 Forbidden**

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

{% endtab %}
{% endtabs %}
