> This page is for API Reference.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fiftytwo-demo.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fiftytwo-demo.ferndocs.com/_mcp/server.

# Insert/update a list of store groups on all stores

POST https://api.fiftytwo.com/masterdata/storegroups/v1/chain/{chain}
Content-Type: application/json

Only supported when master data is distributed by the 52ViKING enterprise service.

Reference: https://fiftytwo-demo.ferndocs.com/api/master-data/reference/store-groups/ecstg

## Request

### Path parameters

- `chain` (integer, required) — The ID of the chain

### Body (application/json)

This endpoint expects a storeGroups.

- `storeGroups` (list of StoreGroupsStoreGroupsItems, required)

## Response

### 202

Accepted

## Errors

### 400 Bad Request Error

Bad Request

- `string`

## Types

### StoreGroupsStoreGroupsItems

- `storeGroupId` (string, required) — The ID of the store group. Reference this ID to scope, for example, a campaign or prices to stores in the store group. Must match the regular expression ^\[B-Z]\[A-Z,0-9]\$
- `description` (string, optional) — A short description of the store group.
- `storeIds` (list of string, optional) — The store IDs of stores in this store group. To include ranges of store IDs, use the format 1 3..5 7 10, where '3..5' means 'from and including 3 to and including 5'.

## Examples

**Request**

```json
{
  "storeGroups": [
    {
      "storeGroupId": "BBBB",
      "description": "My storegroup.",
      "storeIds": [
        "1",
        "3..5",
        "7",
        "10"
      ]
    }
  ]
}
```

**Response**

```json
{}
```

**SDK Code**

```python StoreGroups_ECSTG_example
import requests

url = "https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1"

payload = { "storeGroups": [
        {
            "storeGroupId": "BBBB",
            "description": "My storegroup.",
            "storeIds": ["1", "3..5", "7", "10"]
        }
    ] }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript StoreGroups_ECSTG_example
const url = 'https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"storeGroups":[{"storeGroupId":"BBBB","description":"My storegroup.","storeIds":["1","3..5","7","10"]}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go StoreGroups_ECSTG_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1"

	payload := strings.NewReader("{\n  \"storeGroups\": [\n    {\n      \"storeGroupId\": \"BBBB\",\n      \"description\": \"My storegroup.\",\n      \"storeIds\": [\n        \"1\",\n        \"3..5\",\n        \"7\",\n        \"10\"\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby StoreGroups_ECSTG_example
require 'uri'
require 'net/http'

url = URI("https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"storeGroups\": [\n    {\n      \"storeGroupId\": \"BBBB\",\n      \"description\": \"My storegroup.\",\n      \"storeIds\": [\n        \"1\",\n        \"3..5\",\n        \"7\",\n        \"10\"\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java StoreGroups_ECSTG_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1")
  .header("Content-Type", "application/json")
  .body("{\n  \"storeGroups\": [\n    {\n      \"storeGroupId\": \"BBBB\",\n      \"description\": \"My storegroup.\",\n      \"storeIds\": [\n        \"1\",\n        \"3..5\",\n        \"7\",\n        \"10\"\n      ]\n    }\n  ]\n}")
  .asString();
```

```php StoreGroups_ECSTG_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1', [
  'body' => '{
  "storeGroups": [
    {
      "storeGroupId": "BBBB",
      "description": "My storegroup.",
      "storeIds": [
        "1",
        "3..5",
        "7",
        "10"
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp StoreGroups_ECSTG_example
using RestSharp;

var client = new RestClient("https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"storeGroups\": [\n    {\n      \"storeGroupId\": \"BBBB\",\n      \"description\": \"My storegroup.\",\n      \"storeIds\": [\n        \"1\",\n        \"3..5\",\n        \"7\",\n        \"10\"\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift StoreGroups_ECSTG_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["storeGroups": [
    [
      "storeGroupId": "BBBB",
      "description": "My storegroup.",
      "storeIds": ["1", "3..5", "7", "10"]
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fiftytwo.com/masterdata/storegroups/v1/chain/1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```