Skip to main content

CreateUser

Creates a new user within the authenticated group context.

The user will be created with the provided email and group ownership, with system-generated unique identifier and ownership hierarchy. Additional roles can be assigned after creation.

Method Options​

Authorisation specification of the CreateUser method.

TypeMETHOD_TYPE_WRITE
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_IAM_ADMIN
  • ROLE_IAM_USER_ADMIN

Parameters​

Request and response parameter message overview:

Input: CreateUserRequest Message​

FieldTypeRequiredDescription
User

meshtrade.iam.user.v1.User

True

The user resource to create. The name field will be ignored and assigned by the server.

Returns: User Message​

Code Examples​

Select supported SDK in the language of your choice for a full example of how to invoke the this method:

package main

import (
"context"
"log"

rolev1 "github.com/meshtrade/api/go/iam/role/v1"
userv1 "github.com/meshtrade/api/go/iam/user/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 := userv1.NewUserService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Create request with user configuration
request := &userv1.CreateUserRequest{
User: &userv1.User{
Owner: service.Group(), // Current authenticated group becomes the owner
Email: "sarah.thompson@company.com", // Unique email address
Roles: []string{
rolev1.Role_ROLE_WALLET_VIEWER.FullResourceNameFromGroupName(service.Group()),
rolev1.Role_ROLE_TRADING_VIEWER.FullResourceNameFromGroupName(service.Group()),
},
},
}

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

// Use the newly created user
log.Printf("User created successfully:")
log.Printf(" Name: %s", user.Name)
log.Printf(" Email: %s", user.Email)
log.Printf(" Owner: %s", user.Owner)
log.Printf(" Roles: %v", user.Roles)

// The user is ready for authentication and resource access
log.Printf("User is ready for authentication with %d assigned roles", len(user.Roles))
}

Advanced Configuration​

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

Other Methods​