# Group

## Get content restriction status for group

`GET /wiki/rest/api/content/{id}/restriction/byOperation/{operation}/group/{group}`

Returns whether the specified content restriction applies to a group.&#x20;

* This endpoint combines the get content restriction status by group name and group id.
* If you provide the group id (UUID), the method will create the endpoint with the verb /**byGroupId**/{groupNameOrID}
* If you provide the group name, the endpoint uses the verb **/group/**{groupNameOrID}.

```go
var endpoint strings.Builder
endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/", contentID, operationKey))

// check if the group id is an uuid type
// if so, it's the group id
groupID, err := uuid.Parse(groupNameOrID)

if err == nil {
	endpoint.WriteString(fmt.Sprintf("byGroupId/%v", groupID.String()))
} else {
	endpoint.WriteString(fmt.Sprintf("group/%v", groupNameOrID))
}
```

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"github.com/ctreminiom/go-atlassian/confluence"
	"log"
	"os"
)

func main()  {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	instance, err := confluence.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	instance.Auth.SetBasicAuth(mail, token)
	instance.Auth.SetUserAgent("curl/7.54.0")

	contentID := "80412692"
	ctx := context.Background()
	operationKey := "update"
	groupNameOrID := "confluence-users"

	response, err := instance.Content.Restriction.Operation.Group.Get(ctx, contentID, operationKey, groupNameOrID)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	log.Println("Endpoint:", response.Endpoint)
	log.Println("Status Code:", response.Code)
}
```

{% endcode %}

## Add group to content restriction

`PUT /wiki/rest/api/content/{id}/restriction/byOperation/{operation}/group/{grou[}`

Adds a group to a content restriction. That is, grant read or update permission to the group for a piece of content.

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"github.com/ctreminiom/go-atlassian/confluence"
	"log"
	"os"
)

func main()  {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	instance, err := confluence.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	instance.Auth.SetBasicAuth(mail, token)
	instance.Auth.SetUserAgent("curl/7.54.0")

	contentID := "80412692"
	ctx := context.Background()
	operationKey := "read"
	groupNameOrID := "jira-users-22"

	response, err := instance.Content.Restriction.Operation.Group.Add(ctx, contentID, operationKey, groupNameOrID)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	log.Println("Endpoint:", response.Endpoint)
	log.Println("Status Code:", response.Code)
}
```

{% endcode %}

## Remove group from content restriction

`DELETE /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/group/{groupName}`

Removes a group from a content restriction. That is, remove read or update permission for the group for a piece of content.

{% code fullWidth="true" %}

```go
package main

import (
	"context"
	"github.com/ctreminiom/go-atlassian/confluence"
	"log"
	"os"
)

func main()  {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	instance, err := confluence.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	instance.Auth.SetBasicAuth(mail, token)
	instance.Auth.SetUserAgent("curl/7.54.0")

	contentID := "80412692"
	ctx := context.Background()
	operationKey := "read"
	groupNameOrID := "jira-users-22"

	response, err := instance.Content.Restriction.Operation.Group.Remove(ctx, contentID, operationKey, groupNameOrID)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	log.Println("Endpoint:", response.Endpoint)
	log.Println("Status Code:", response.Code)

}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations/group.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
