# Public APIs for Customer Groups

### How to get the access key

After you install **B2Bridge - B2B All in one**, go to **API and integration**, fill out the form and submit your access request. We’ll review it and send the access key to your email.

<figure><img src="/files/fB1bqkQCJjqqCKtbRvti" alt=""><figcaption></figcaption></figure>

## Rule endpoints

There are fields of Customer Group rule, you need to understand:

* `id`: If provided and matches an existing customer group, the group will be updated. If omitted or does not match any existing group, a new customer group will be created.
* `name`<mark style="color:red;">\*</mark>: Customer group name.
* `customer_tags`<mark style="color:red;">\*</mark>: A tag is necessary to differentiate B2B and B2C customers. Must start with the prefix `"b2b-"`.
* `payment_options`<mark style="color:red;">\*</mark>
  * ONLINE: Pay online
  * NETTERM: Net payment term
* `pricing_rule_ids`: IDs of the price list rules to assign to the customer group.
* `collect_tax`
  * 0: Don't collect tax
  * 1: Collect tax

If the **`payment_options`** array includes **`NETTERM`**

* `nt_eligible`
  * ON\_RECEIPT: pay on receipt
  * CUSTOM: custom date net term
  * 7: pay after 7 days
  * 15: pay after 15 days
  * 30: pay after 30 days
  * 60: pay after 60 days
  * 90: pay after 90 days
* `nt_to_final_order`
  * 0: Net Terms orders as draft orders
  * 1: Net Terms orders as final orders
* `nt_tag_order_enable`
  * 0: disable
  * 1: enable
* `nt_tag_order_list`
* `nt_time_custom`: Defaults to `{"time": "DAY", "value": 1}` if not provided.\
  If specified, it must follow the structure
  * time: Must be one of `"DAY"`, `"WEEK"`, or `"MONTH"`.
  * value : If `time` is `"DAY"` must be between `1` and `365`. If `time` is `"WEEK"` or `"MONTH"` must be between `1` and `99`.

### Get all customer group by domain

<mark style="color:green;">**`GET`**</mark> `https://b2bridge-public-api.b2bridge.io/api/v1/customer-groups/get-by-domain`

#### Headers

| KEY                | VALUE |
| ------------------ | ----- |
| x-b2bridge-api-key | xxx   |

#### Params

| KEY    | VALUE             |
| ------ | ----------------- |
| domain | abc.myshopify.com |

#### Response <mark style="color:green;">`200`</mark>

```json
{
    "success": true,
    "message": "Get Customer Groups Successfully",
    "groups": [
        {
            "id": 1,
            "shop_id": 1,
            "name": "cg1",
            "customer_tags": "b2b-cus1",
            "pricing_rule_ids": "[1]",
            "payment_options": "[\"ONLINE\",\"NETTERM\"]",
            "nt_eligible": "ON_RECEIPT",
            "nt_limit_option": 0,
            "nt_limit_type": "QUANTITY",
            "nt_limit_value": "0",
            "nt_tag_order_enable": 0,
            "nt_tag_order_list": "[]",
            "nt_time_custom": "null",
            "nt_to_final_order": 0,
            "customer_ids": "[\"7875968794841\",\"7881979887833\"]",
            "collect_tax": 0,
            "nt_form_id": null,
            "created_at": "2025-05-23T04:46:48.149Z",
            "updated_at": null,
            "customerGroupPricing": [
                {
                    "pricing_rule_id": 1,
                    "customer_group_id": 1,
                    "shop_id": 1,
                    "created_at": "2025-05-23T04:46:48.154Z",
                    "updated_at": null,
                    "pricingListRules": {
                        "id": 1,
                        "name": "pl1"
                    }
                }
            ]
        }
    ]
}
```

### Get customer group by id

<mark style="color:green;">**`GET`**</mark> `https://b2bridge-public-api.b2bridge.io/api/v1/customer-groups/get-by-id`

#### Headers

| KEY                | VALUE |
| ------------------ | ----- |
| x-b2bridge-api-key | xxx   |

#### Params

| KEY    | VALUE             |
| ------ | ----------------- |
| domain | abc.myshopify.com |
| id     | 1                 |

#### Response <mark style="color:green;">`200`</mark>

```json
{
    "success": true,
    "message": "Get Customer Group By Id Successfully",
    "group": {
        "id": 1,
        "shop_id": 1,
        "name": "cg1",
        "customer_tags": "b2b-cus1",
        "pricing_rule_ids": "[1]",
        "payment_options": "[\"ONLINE\",\"NETTERM\"]",
        "nt_eligible": "ON_RECEIPT",
        "nt_limit_option": 0,
        "nt_limit_type": "QUANTITY",
        "nt_limit_value": "0",
        "nt_tag_order_enable": 0,
        "nt_tag_order_list": "[]",
        "nt_time_custom": "null",
        "nt_to_final_order": 0,
        "customer_ids": "[\"7875968794841\",\"7881979887833\"]",
        "collect_tax": 0,
        "nt_form_id": null,
        "created_at": "2025-05-23T04:46:48.149Z",
        "updated_at": null,
        "customerGroupPricing": [
            {
                "pricing_rule_id": 1,
                "customer_group_id": 1,
                "shop_id": 1,
                "created_at": "2025-05-23T04:46:48.154Z",
                "updated_at": null,
                "pricingListRules": {
                    "id": 1,
                    "name": "pl1"
                }
            }
        ]
    }
}
```

### Save or update customer group

* If the `id` field is **not provided** in the customer group, it will be treated as a **new customer group**.
* If the `id` field **is provided** and matches an existing, it will be treated as an **update to that existing customer group**.

<mark style="color:yellow;">**`POST`**</mark> `https://b2bridge-public-api.b2bridge.io/api/v1/customer-groups/save`

#### Headers

| KEY                | VALUE            |
| ------------------ | ---------------- |
| Content-Type       | application/json |
| x-b2bridge-api-key | xxx              |

#### Body

```json
{
    "domain": "abc.myshopify.com",
    "data": {
        "name": "cg6",
        "collect_tax": 1,
        "customer_ids": [
            "7875968794841"
        ],
        "customer_tags": "b2b-cus4",
        "payment_options": [
            "ONLINE",
            "NETTERM"
        ],
        "pricing_rule_ids": [],
        "nt_to_final_order":0,
        "nt_tag_order_enable": 0,
        "nt_eligible": "CUSTOM",
        "nt_time_custom": {
            "time": "DAY",
            "value": 1
        }
    }
}
```

#### Response <mark style="color:green;">`200`</mark>

```json
{
    "success": true,
    "message": "Created customer group successfully",
    "payload": {
        "id": 3
    }
}
```

### Save multiple customer group

<mark style="color:yellow;">**`POST`**</mark> `https://b2bridge-public-api.b2bridge.io/api/v1/customer-groups/bulk-save`

#### Headers

| KEY                | VALUE            |
| ------------------ | ---------------- |
| Content-Type       | application/json |
| x-b2bridge-api-key | xxx              |

#### Body

```json
{
    "domain": "abc.myshopify.com",
    "groups": [
        {
            "name": "cg7",
            "collect_tax": 1,
            "customer_ids": [
                "7875968794841"
            ],
            "customer_tags": "b2b-cus4",
            "payment_options": [
                "ONLINE"
            ],
            "pricing_rule_ids": []
        },
        {
            "id": 14,
            "name": "cg4",
            "collect_tax": 0,
            "customer_ids": [
                "7875968794841"
            ],
            "customer_tags": "b2b-cus3",
            "payment_options": [
                "ONLINE"
            ],
            "pricing_rule_ids": []
        }
    ]
}
```

#### Response <mark style="color:green;">`200`</mark>

```json
{
    "success": true,
    "message": [
        "Create new rule 'cg7' with ID 4 successfully",
        "Update rule ID 14 successfully"
    ]
}
```

### Delete customer group

<mark style="color:red;">**`DELETE`**</mark> `https://b2bridge-public-api.b2bridge.io/api/v1/customer-groups/delete-by-id`

#### Headers

| KEY                | VALUE |
| ------------------ | ----- |
| x-b2bridge-api-key | xxx   |

#### Params

| KEY    | VALUE             |
| ------ | ----------------- |
| domain | abc.myshopify.com |
| id     | 1                 |

#### Response <mark style="color:green;">`200`</mark>

```json
{
    "success": true,
    "message": "Delete Customer Group Successfully"
}
```

### Mass delete customer group

<mark style="color:yellow;">**`POST`**</mark> `https://b2bridge-public-api.b2bridge.io/api/v1/customer-groups/mass-delete`

#### Headers

| KEY                | VALUE            |
| ------------------ | ---------------- |
| Content-Type       | application/json |
| x-b2bridge-api-key | xxx              |

#### Body

```json
{
    "domain": "abc.myshopify.com",
    "ids": [
        9,
        10
    ]
}
```

#### Response <mark style="color:green;">`200`</mark>

```json
{
    "success": true,
    "message": "Deleted customer groups successfully",
    "deleted": [
        9,
        10
    ],
    "failed": []
}
```

{% hint style="success" %}

### Need Help?

If you have questions or run into issues while using any feature, we’re here to help.

* 💬 **Start a** [**Live Chat** with our support team](https://go.crisp.chat/chat/embed/?website_id=a59f354c-f51f-4f84-ae9a-c0e8dd69d2e5) directly from your B2Bridge dashboard.
* 📧 **Email us at** [**support@b2bridge.io**](mailto:support@b2bridge.io) and we’ll get back to you as soon as possible.
  {% endhint %}


---

# 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://docs.b2bridge.io/integration/api-integration/public-apis-for-customer-groups.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.
