> For the complete documentation index, see [llms.txt](https://docs.go-atlassian.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.go-atlassian.io/bitbucket-cloud/workspace/permissions.md).

# Permissions

## Get user permissions in a workspace

`GET /2.0/workspaces/{workspace}/permissions`

Returns the list of members in a workspace and their permission levels. Permission can be:

* `owner`
* `collaborator`
* `member`

{% code fullWidth="true" %}

```go
package main

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

func main() {

	token := os.Getenv("BITBUCKET_TOKEN")

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

	instance.Auth.SetBearerToken(token)
	instance.Auth.SetUserAgent("curl/7.54.0")

	users, response, err := instance.Workspace.Permission.Members(context.TODO(), "ctreminiom", "permission=\"owner\"")
	if err != nil {

		log.Println(response.Endpoint)
		log.Println(response.Bytes.String())
		log.Fatal(err)
	}

	for _, user := range users.Values {
		fmt.Println(user)
	}
}
```

{% endcode %}

## Gets all repository permissions in a workspace

`GET /2.0/workspaces/{workspace}/permissions/repositories`

Returns an object for each repository permission for all of a workspace's repositories.

Permissions returned are effective permissions: the highest level of permission the user has. This does not distinguish between direct and indirect (group) privileges.

Only users with admin permission for the team may access this resource. The permissions can be:

* `admin`
* `write`
* `read`

Results may be further [filtered or sorted](https://developer.atlassian.com/cloud/bitbucket/rest/intro/#filtering) by repository, user, or permission by adding the following query string parameters:

* `q=repository.name="geordi"` or `q=permission>"read"`
* `sort=user.display_name`

{% code fullWidth="true" %}

```go
package main

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

func main() {

	token := os.Getenv("BITBUCKET_TOKEN")

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

	instance.Auth.SetBearerToken(token)
	instance.Auth.SetUserAgent("curl/7.54.0")

	repositories, response, err := instance.Workspace.Permission.Repositories(context.TODO(), "ctreminiom", "permission=\"admin\"", "")
	if err != nil {

		log.Println(response.Endpoint)
		log.Println(response.Bytes.String())
		log.Fatal(err)
	}

	for _, repo := range repositories.Values {
		fmt.Println(repo.Type, repo.Repository.Name, repo.Repository.Uuid, repo.Permission)
	}
}

```

{% endcode %}

## Get repository permission in a workspace

`GET /2.0/workspaces/{workspace}/permissions/repositories/{repo_slug}`

Returns an object for the repository permission of each user in the requested repository.

Permissions returned are effective permissions: the highest level of permission the user has. This does not distinguish between direct and indirect (group) privileges.

Only users with admin permission for the repository may access this resource, the permissions can be:

* `admin`
* `write`
* `read`

Results may be further [filtered or sorted](https://developer.atlassian.com/cloud/bitbucket/rest/intro/#filtering) by user, or permission by adding the following query string parameters:

* `q=permission>"read"`
* `sort=user.display_name`

Note that the query parameter values need to be URL escaped so that `=` would become `%3D`.

{% code fullWidth="true" %}

```go
package main

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

func main() {

	token := os.Getenv("BITBUCKET_TOKEN")

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

	instance.Auth.SetBearerToken(token)
	instance.Auth.SetUserAgent("curl/7.54.0")

	repositories, response, err := instance.Workspace.Permission.Repository(context.TODO(), "ctreminiom", "microservice-a", "permission=\"admin\"", "")
	if err != nil {

		log.Println(response.Endpoint)
		log.Println(response.Bytes.String())
		log.Fatal(err)
	}

	for _, repo := range repositories.Values {
		fmt.Println(repo.Type, repo.Repository.Name, repo.Repository.Uuid, repo.Permission)
	}
}

```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.go-atlassian.io/bitbucket-cloud/workspace/permissions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
