Skip to main content

CreateGroup

Method Details​

Description: Creates a new child group within the authenticated group's hierarchy.

The new group inherits access from its parent and becomes part of the organizational structure. Group ownership must match the executing context.

Required Roles: Check proto file for roles

Parameters:

  • Group (message) (required): The group configuration for creation. The name field will be ignored and assigned by the system.

Returns: Group

Method Type: METHOD_TYPE_WRITE

Code Examples​

package main

import (
"context"
"log"

groupv1 "github.com/meshtrade/api/go/iam/group/v1"
)

func main() {
ctx := context.Background()

// Default configuration is used and credentials come from MESH_API_CREDENTIALS
// environment variable or default discovery methods. Zero config required
// unless you want custom configuration.
service, err := groupv1.NewGroupService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Get current executing group to use as owner for the new child group
// Note: Owner format is "groups/{ULIDv2}" (e.g. "groups/01HZ2XWFQ4QV2J5K8MN0PQRSTU")
// but you can only create groups owned by your authenticated context

// Create request with group configuration
request := &groupv1.CreateGroupRequest{
Group: &groupv1.Group{
Owner: service.Group(), // Current executing group becomes the parent
DisplayName: "Trading Team Alpha",
Description: "Primary trading team for equity markets and derivatives",
},
}

// Call the CreateGroup method
group, err := service.CreateGroup(ctx, request)
if err != nil {
log.Fatalf("CreateGroup failed: %v", err)
}

// Use the newly created group
log.Printf("Group created successfully:")
log.Printf(" Name: %s", group.Name)
log.Printf(" Display Name: %s", group.DisplayName)
log.Printf(" Owner: %s", group.Owner)
log.Printf(" Description: %s", group.Description)

// The group can now be used to own resources and manage users
log.Printf("Group is ready to own API users, accounts, and trading resources")
}

Advanced Configuration​

For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.

Other Methods​