# Group Attributes

## **List attributes group**

<mark style="color:blue;">`GET`</mark> `‎‎ https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/`

This API endpoint will give you the list of attributes group.

#### Query Parameters

| Name        | Type   | Description                                                                                                             |
| ----------- | ------ | ----------------------------------------------------------------------------------------------------------------------- |
| offset      | string | numeric - The offset indicates the starting position of the query in relation to the complete set of unpaginated items. |
| limit       | string | The limit indicates the maximum number of items to return, default maximum number is 50, and maximum limit is 100.      |
| group\_name | string | Attribute group name.                                                                                                   |
| attr\_name  | string | Attribute name.                                                                                                         |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <attribute_group_id>,
                "name": "<attribute_group_name>",
                "attribute_id": [
                    {
                        "id": <attribute_id>,
                        "machine_code": "<attribute_machine_code>",
                        "name": "<attribute_name>",
                        "description": "<attribute_description>",
                        "widget": "<attribute_widget_type>",
                        "attribute_for": "<attribute_for>",
                        "is_unique": <is_unique_boolean>,
                        "is_required": <is_required_boolean>,
                        "is_display": <is_display_boolean>,
                        "options": [
                            {
                                "label": "<option_label>",
                                "value": "<option_value>",
                                "status": <option_status_boolean>,
                                "weight": <option_weight>
                            },
                            ...
                        ],
                        "data_type": "<attribute_data_type>",
                        "status": <attribute_status>,
                        "created": "<created_date_time>"
                    },
                    ...
                ],
                "status": <attribute_group_status>,
                "created": "<created_date_time>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <link_for_previous_page_list>,
        "next": <link_for_next_page_list>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': '‎https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "‎https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

## Create attributes group

<mark style="color:green;">`POST`</mark> `‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/create/attribute-groups/`

This API endpoint will create an attributes group.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                            | Type   | Description                                                                                                                                                                                                            |
| ----------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>          | string | Name of attribute                                                                                                                                                                                                      |
| attribute\_id<mark style="color:red;">\*</mark> | array  | <p>Attribute id - require an array of attribute ids containing at least one attribute id.</p><p><a data-mention href="/pages/-MMGTZ7ncCPxGvDbrBEn#list-attributes">/pages/-MMGTZ7ncCPxGvDbrBEn#list-attributes</a></p> |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/create/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  body: JSON.stringify({"name":"<name>","attribute_id":["<attribute_id>","<attribute_id>",...]})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/create/attribute-groups/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "name":"<name>",
    "attribute_id": ["<attribute_id>","<attribute_id>"]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field         | Description                                                                                                                         |
| ----------- | ---------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | name          | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 20 characters.</p>           |
| 400         | Validation Error | attribute\_id | <p>Attribute id is required.</p><p>attribute\_id is not valid or This field may not be blank.</p><p>attribute\_id is not exist.</p> |

## Update attributes group

<mark style="color:green;">`POST`</mark> `‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute-groups/`

This API endpoint will update an attributes groups.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                            | Type   | Description                                                                            |
| ----------------------------------------------- | ------ | -------------------------------------------------------------------------------------- |
| attrgroup\_id<mark style="color:red;">\*</mark> | string | Id of an attributes group that wants to update.                                        |
| name<mark style="color:red;">\*</mark>          | string | Give a new name if u want to update the name of the group else give the existing name. |
| remove\_attr                                    | array  | An array of attribute ids that wants to remove from the attributes group.              |
| add\_attr                                       | array  | An array of attribute ids that wants to add to the attributes group.                   |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': '‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  body: JSON.stringify({"attrgroup_id":"<attrgroup_id>","name":"<name>","add_attr":["<attr_id>","<attr_id>",...],"remove_attr":["<attr_id>","<attr_id>",...]})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute-groups/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "attrgroup_id":"<attrgroup_id>",
    "name":"<name>",
    "add_attr": ["<attr_id>","<attr_id>",...],
    "remove_attr": ["<attr_id>","<attr_id>",...]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field         | Description                                                                                                                                                   |
| ----------- | ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Invalid Input    | attrgroup\_id | <p>This field is required.</p><p>attrgroup\_id is not valid or This field may not be blank</p>                                                                |
| 400         | Validation Error | name          | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 20 characters.</p>                                     |
| 400         | Validation Error | attribute\_id | <p>\<attribute\_id>  is not valid or This field may not be blank.</p><p>\<attribute\_id>  is not exist.</p><p>\<attribute\_id> is already exist in group.</p> |


---

# 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://api.epixelsoftware.help/group-attributes.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.
