---
title: Creating Sync Groups
slug: v4-7/sync/transports-overview
docTags: 
createdAt: 2024-03-13T15:23:38.465Z
---

A sync group is a collection of devices organized into a distinct group, allowing you to limit connections to specific subsets of devices rather than the default behavior of connecting all devices sharing the same app ID.&#x20;

# Introduction

By default, devices with the same app ID automatically form a mesh network to connect. However, you can streamline sync processes, minimize unnecessary data transfer, and optimize resource usage by configuring sync groups within your app.

For example, the following graphic illustrates two distinct restaurants identified by their location IDs: `7890` and `1234`. When a peer establishes its identity with the Big Peer, it includes its location ID as part of the authentication callback.&#x20;

Now, the two groups maintain isolated mesh networks:

::Image[]{src="https://api.archbee.com/api/optimize/qoRkNxW5fJ81r_NqVpc8C/K0lx1Dc3BcPZkOYysO3tB_syncgroups.png" size="92" width="872" height="391" position="flex-start" showCaption="false"}

# Access Controls by Group

Sync groups are an optimization, not a security control — if a connection is created manually, such as by specifying a specific peer to connect to, then devices from different sync groups will still connect and sync as normal.&#x20;

To enforce access controls by group, for instance, two groups of devices, each accessing different datasets, use Ditto's permissions system. (See [End-User Access](docId\:kwgh8Ab8HufAo8j60mgdH))

A device can only be in one sync group, which by default is group 0. Up to 2^32 distinct group numbers can be used in an app.

# Setting Up Sync Groups

To create a sync group:

:::CodeblockTabs
```swift
var config = DittoTransportConfig()
config.global.syncGroup = 1234

ditto.transportConfig = config

do {
  try ditto.startSync()
} catch (let error) {
  print(error.localizedDescription)
}
```

```kotlin
val config = DittoTransportConfig()
config.global.syncGroup = 1234U

ditto.transportConfig = config

ditto.startSync()
```

```javascript
const config = new TransportConfig()
config.global.syncGroup = 1234

ditto.setTransportConfig(config)

ditto.startSync()
```

```java
// Not supported
```

```csharp
DittoTransportConfig transportConfig = new DittoTransportConfig();
transportConfig.Global.SyncGroup = 1234;

ditto.TransportConfig = transportConfig;

ditto.StartSync();
```

```cpp
auto config = ditto::TransportConfig();
config.global.sync_group = 1234;

ditto.set_transport_config(config);

ditto.start_sync();
```

```rust
let mut config = TransportConfig::new();
config.global.sync_group = 1234;

ditto.set_transport_config(config);
ditto.start_sync()?;
```

Dart (beta)

```dart
// Coming Soon
```
:::









