# Create a Wholesale Role

This API allows you to create custom wholesale role.

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

| Method | Endpoint                     |
| ------ | ---------------------------- |
| POST   | /wp-json/wholesale/v1/roles/ |

| Body Parameters                   | Type   | Required | Description                                                                           |
| --------------------------------- | ------ | -------- | ------------------------------------------------------------------------------------- |
| role\_key                         | string | yes      | Wholesale Role key to be created.                                                     |
| role\_name                        | string | yes      | Wholesale Role name.                                                                  |
| description                       | string | no       | Wholesale Role description.                                                           |
| shipping\_class\_name             | string | no       | Shipping class name.                                                                  |
| shipping\_class\_term\_id         | int    | no       | Shipping term ID.                                                                     |
| only\_allow\_wholesale\_purchases | string | no       | Only allow wholesale purchases for this specific role. Value should be "yes" or "no". |
| {% endtab %}                      |        |          |                                                                                       |

{% tab title="Request Example" %}

#### Postman

```javascript
POST: /wp-json/wholesale/v1/roles/

JSON Body:
{
    "role_key" : "sample_role",
    "role_name" : "Sample Role",
    "description" : "The sample wholesale role",
    "shipping_class_name" : "",
    "shipping_class_term_id" : "",
    "only_allow_wholesale_purchases" : "no"
}
```

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

Successfully created

```
{
    "message": "Successfully created role \"sample_role\"",
    "data": {
        "sample_role": {
            "roleName": "Sample Role",
            "desc": "The sample wholesale role",
            "onlyAllowWholesalePurchases": "no"
        }
    }
}
```

#### Status: 403 Forbidden

Duplicate or missing required fields

```
{
    "code": "wholesale_rest_cannot_create",
    "message": "Can't create item. Please make sure \"role_key\" is unique. Both \"role_key\" and \"role_name\" property are required.",
    "data": {
        "status": 403
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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/wholesale-role/create-a-wholesale-role.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.
