# Assign a group (Team) to a repository for access


[API catalog](/reference/api/) · [Docker Hub overview](/reference/api/hub/latest/) · [Product manual](https://docs.docker.com/docker-hub/) · [OpenAPI specification](/reference/api/hub/latest.yaml)

API version: 2-beta



`POST /v2/repositories/{namespace}/{repository}/groups`

Assigns an organization group (team) to a repository with a specified permission level.

This operation accepts bearer tokens issued from organization access tokens (OATs). The token must have the required resource access and scopes.


## Connection and access

[API connection and authentication guidance](/reference/api/hub/latest/#authentication)


Server: `https://hub.docker.com`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
[
  {
    "bearerAuth": []
  }
]
```
## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request POST \
  --header "Authorization: Bearer ${TOKEN}" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "group_id": 12345,
  "permission": "write"
}' \
  'https://hub.docker.com/v2/repositories/<NAMESPACE>/<REPOSITORY>/groups'
```

## Parameters

### namespace

Location: path. Required: yes.

Namespace of the repository, such as a user or organization name.

```json
{
  "description": "Namespace of the repository, such as a user or organization name.",
  "in": "path",
  "name": "namespace",
  "pointer": "/paths/~1v2~1repositories~1{namespace}~1{repository}~1groups/parameters/0",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### repository

Location: path. Required: yes.

Name of the repository within the namespace.

```json
{
  "description": "Name of the repository within the namespace.",
  "in": "path",
  "name": "repository",
  "pointer": "/paths/~1v2~1repositories~1{namespace}~1{repository}~1groups/parameters/1",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

## Request and responses

### Request  application/json




Schema:

```json
{
  "$ref": "#/components/schemas/RepositoryGroupCreationRequest"
}
```




Example:
```json
{
  "group_id": 12345,
  "permission": "write"
}
```


### Response 200 application/json

Repository group permission created successfully


Schema:

```json
{
  "$ref": "#/components/schemas/RepositoryGroup"
}
```




Example:
```json
{
  "group_id": 12345,
  "group_name": "developers",
  "permission": "write"
}
```


### Response 400 application/json

Bad Request - Invalid request parameters


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "bad request"
}
```


### Response 401 application/json

Unauthorized


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "unauthorized"
}
```


### Response 403 application/json

Forbidden


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "permission denied"
}
```


### Response 404 application/json

Not Found


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "not found"
}
```


## Complete operation contract

```json
{
  "description": "Assigns an organization group (team) to a repository with a specified permission level.\n\nThis operation accepts bearer tokens issued from organization access tokens (OATs). The token must have the required resource access and scopes.\n",
  "operationId": "CreateRepositoryGroup",
  "requestBody": {
    "content": {
      "application/json": {
        "example": {
          "group_id": 12345,
          "permission": "write"
        },
        "schema": {
          "$ref": "#/components/schemas/RepositoryGroupCreationRequest"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "example": {
            "group_id": 12345,
            "group_name": "developers",
            "permission": "write"
          },
          "schema": {
            "$ref": "#/components/schemas/RepositoryGroup"
          }
        }
      },
      "description": "Repository group permission created successfully"
    },
    "400": {
      "content": {
        "application/json": {
          "examples": {
            "error": {
              "summary": "Example error response",
              "value": {
                "errinfo": null,
                "message": "bad request"
              }
            }
          },
          "schema": {
            "$ref": "#/components/schemas/error"
          }
        }
      },
      "description": "Bad Request - Invalid request parameters"
    },
    "401": {
      "$ref": "#/components/responses/unauthorized"
    },
    "403": {
      "$ref": "#/components/responses/forbidden"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "summary": "Assign a group (Team) to a repository for access",
  "tags": [
    "repositories"
  ]
}
```

## Referenced schemas

- `#/components/responses/NotFound`

- `#/components/responses/forbidden`

- `#/components/responses/unauthorized`

- [#/components/schemas/RepositoryGroup](/reference/api/hub/latest/schemas/RepositoryGroup/)

- [#/components/schemas/RepositoryGroupCreationRequest](/reference/api/hub/latest/schemas/RepositoryGroupCreationRequest/)

- [#/components/schemas/error](/reference/api/hub/latest/schemas/error/)




