Skip to content
Start here

Create User Group

client.IAM.UserGroups.New(ctx, params) (*UserGroupNewResponse, error)
POST/accounts/{account_id}/iam/user_groups

Create a new user group under the specified account.

Security

API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
SCIM ProvisioningAccount Settings Write
ParametersExpand Collapse
params UserGroupNewParams
AccountID param.Field[string]

Path param: Account identifier tag.

maxLength32
minLength32
Name param.Field[string]

Body param: Name of the User group.

Policies param.Field[[]UserGroupNewParamsPolicy]

Body param: Policies attached to the User group

Access UserGroupNewParamsPoliciesAccess

Allow or deny operations against the resources.

One of the following:
const UserGroupNewParamsPoliciesAccessAllow UserGroupNewParamsPoliciesAccess = "allow"
const UserGroupNewParamsPoliciesAccessDeny UserGroupNewParamsPoliciesAccess = "deny"
PermissionGroups []UserGroupNewParamsPoliciesPermissionGroup

A set of permission groups that are specified to the policy.

ID string

Permission Group identifier tag.

maxLength32
minLength32
ResourceGroups []UserGroupNewParamsPoliciesResourceGroup

A set of resource groups that are specified to the policy.

ID string

Resource Group identifier tag.

maxLength32
minLength32
ReturnsExpand Collapse
type UserGroupNewResponse struct{…}

A group of policies resources.

ID string

User Group identifier tag.

maxLength32
minLength32
CreatedOn Time

Timestamp for the creation of the user group

formatdate-time
ModifiedOn Time

Last time the user group was modified.

formatdate-time
Name string

Name of the user group.

Policies []UserGroupNewResponsePolicyoptional

Policies attached to the User group

ID stringoptional

Policy identifier.

Access UserGroupNewResponsePoliciesAccessoptional

Allow or deny operations against the resources.

One of the following:
const UserGroupNewResponsePoliciesAccessAllow UserGroupNewResponsePoliciesAccess = "allow"
const UserGroupNewResponsePoliciesAccessDeny UserGroupNewResponsePoliciesAccess = "deny"
PermissionGroups []UserGroupNewResponsePoliciesPermissionGroupoptional

A set of permission groups that are specified to the policy.

ID string

Identifier of the permission group.

Meta UserGroupNewResponsePoliciesPermissionGroupsMetaoptional

Attributes associated to the permission group.

Key stringoptional
Value stringoptional
Name stringoptional

Name of the permission group.

ResourceGroups []UserGroupNewResponsePoliciesResourceGroupoptional

A list of resource groups that the policy applies to.

ID string

Identifier of the resource group.

Scope []UserGroupNewResponsePoliciesResourceGroupsScope

The scope associated to the resource group

Key string

This is a combination of pre-defined resource name and identifier (like Account ID etc.)

Objects []UserGroupNewResponsePoliciesResourceGroupsScopeObject

A list of scope objects for additional context.

Key string

This is a combination of pre-defined resource name and identifier (like Zone ID etc.)

Meta UserGroupNewResponsePoliciesResourceGroupsMetaoptional

Attributes associated to the resource group.

Key stringoptional
Value stringoptional
Name stringoptional

Name of the resource group.

Create User Group

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/iam"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  userGroup, err := client.IAM.UserGroups.New(context.TODO(), iam.UserGroupNewParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Name: cloudflare.F("My New User Group"),
    Policies: cloudflare.F([]iam.UserGroupNewParamsPolicy{iam.UserGroupNewParamsPolicy{
      Access: cloudflare.F(iam.UserGroupNewParamsPoliciesAccessAllow),
      PermissionGroups: cloudflare.F([]iam.UserGroupNewParamsPoliciesPermissionGroup{iam.UserGroupNewParamsPoliciesPermissionGroup{
        ID: cloudflare.F("c8fed203ed3043cba015a93ad1616f1f"),
      }, iam.UserGroupNewParamsPoliciesPermissionGroup{
        ID: cloudflare.F("82e64a83756745bbbb1c9c2701bf816b"),
      }}),
      ResourceGroups: cloudflare.F([]iam.UserGroupNewParamsPoliciesResourceGroup{iam.UserGroupNewParamsPoliciesResourceGroup{
        ID: cloudflare.F("6d7f2f5f5b1d4a0e9081fdc98d432fd1"),
      }}),
    }}),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", userGroup.ID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "023e105f4ecef8ad9ca31a8372d0c353",
    "created_on": "2024-03-01T12:21:02.0000Z",
    "modified_on": "2024-03-01T12:21:02.0000Z",
    "name": "My New User Group",
    "policies": [
      {
        "id": "f267e341f3dd4697bd3b9f71dd96247f",
        "access": "allow",
        "permission_groups": [
          {
            "id": "c8fed203ed3043cba015a93ad1616f1f",
            "meta": {
              "key": "key",
              "value": "value"
            },
            "name": "Zone Read"
          },
          {
            "id": "82e64a83756745bbbb1c9c2701bf816b",
            "meta": {
              "key": "key",
              "value": "value"
            },
            "name": "Magic Network Monitoring"
          }
        ],
        "resource_groups": [
          {
            "id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1",
            "scope": [
              {
                "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4",
                "objects": [
                  {
                    "key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"
                  }
                ]
              }
            ],
            "meta": {
              "key": "key",
              "value": "value"
            },
            "name": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4"
          }
        ]
      }
    ]
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "023e105f4ecef8ad9ca31a8372d0c353",
    "created_on": "2024-03-01T12:21:02.0000Z",
    "modified_on": "2024-03-01T12:21:02.0000Z",
    "name": "My New User Group",
    "policies": [
      {
        "id": "f267e341f3dd4697bd3b9f71dd96247f",
        "access": "allow",
        "permission_groups": [
          {
            "id": "c8fed203ed3043cba015a93ad1616f1f",
            "meta": {
              "key": "key",
              "value": "value"
            },
            "name": "Zone Read"
          },
          {
            "id": "82e64a83756745bbbb1c9c2701bf816b",
            "meta": {
              "key": "key",
              "value": "value"
            },
            "name": "Magic Network Monitoring"
          }
        ],
        "resource_groups": [
          {
            "id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1",
            "scope": [
              {
                "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4",
                "objects": [
                  {
                    "key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"
                  }
                ]
              }
            ],
            "meta": {
              "key": "key",
              "value": "value"
            },
            "name": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4"
          }
        ]
      }
    ]
  }
}