> For the complete documentation index, see [llms.txt](https://rymera.gitbook.io/wholesale-suite-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/wholesale-suite-api/wholesale-v1-wwpp/category-discounts/create-category-discount.md).

# Create Category Discount

This API allows you to set wholesale discount of a wholesale roles on a specific category.

{% tabs %}
{% tab title="Request" %}

| Method       | Endpoint                                               |
| ------------ | ------------------------------------------------------ |
| POST         | /wp-json/wholesale/v1/category-discount/{category\_id} |
| {% endtab %} |                                                        |

{% tab title="Request Example" %}

#### Postman

Create a wholesale discount for a wholesale customer:

```javascript
POST: /wp-json/wholesale/v1/category-discount/{category_id}

JSON Body:
{
    "wholesale_customers" : 22,
    "wholesale_bronze": 11
}
```

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

List all wholesale role discounts from a specific category.

```
POST: /wp-json/wholesale/v1/category-discount/{category_id}

JSON Body:
{
    "wholesale_customer" : 22,
    "wholesale_bronze": 11
}

Response:
{
    "message": "Successfully created category discount.",
    "data": {
        "wholesale_customer_wholesale_discount": 22,
        "wholesale_bronze_wholesale_discount": 11
    }
}
```

#### Status: 400 Bad Request

The category id does not exist.

```
GET: /wp-json/wholesale/v1/category-discount/{category_id}

Response:
{
    "code": "wholesale_rest_category_discount_cannot_view",
    "message": "Category ID is invalid.",
    "data": {
        "status": 400
    }
}
```

#### Status: 400 Bad Request

The wholesale role is invalid.

```
GET: /wp-json/wholesale/v1/category-discount/{category_id}

JSON Body:
[
    "wholesale_customer_invalid_key" : 10
]

Response:
{
    "code": "wholesale_rest_category_discount_cannot_delete",
    "message": "Make sure wholesale role are valid. Please indicate the wholesale roles you want to remove the discount.",
    "data": {
        "status": 400,
        "invalid_roles": [
            "wholesale_customer_invalid_key"
        ]
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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:

```
GET https://rymera.gitbook.io/wholesale-suite-api/wholesale-v1-wwpp/category-discounts/create-category-discount.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.
