---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/api-ref/Repository-or-Roles/AddRepoRoles.md
  - https://sourcecraft.dev/portal/docs/ru/api-ref/Repository-or-Roles/AddRepoRoles.md
  - href: en/api-ref/Repository-or-Roles/AddRepoRoles.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt

<div class="openapi">

# Add Repository Roles

<!-- markdownlint-disable-file -->

## Request

<div class="openapi__requests">

<div class="openapi__request__wrapper" style="--method: var(--dc-openapi-methods-post);margin-bottom: 12px">

<div class="openapi__request">

POST {.openapi__method}
```text translate=no
https://api.sourcecraft.tech/repos/{org_slug}/{repo_slug}/roles
```

</div>

</div>

</div>

### Path parameters

#|
|| **Name** | **Description** ||
||

_org_slug_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_repo_slug_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
|#{.json-schema-properties}

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "subject_roles": [
    {
      "role": "viewer",
      "subject": {
        "type": "user",
        "id": "example"
      }
    }
  ]
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_subject_roles_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [SubjectRole](#entity-SubjectRole)[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "role": "viewer",
    "subject": {
      "type": "user",
      "id": "example"
    }
  }
]
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

</div>

<div class="openapi-entity">

### RepoRole {#entity-RepoRole}

**Type**: string

_Enum:_{.json-schema-reset .json-schema-value} `viewer`, `contributor`, `developer`, `maintainer`, `admin`

</div>

<div class="openapi-entity">

### SubjectType {#entity-SubjectType}

**Type**: string

_Enum:_{.json-schema-reset .json-schema-value} `user`, `invitee`, `team`

</div>

<div class="openapi-entity">

### Subject {#entity-Subject}

#|
|| **Name** | **Description** ||
||

_id_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_type_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [SubjectType](#entity-SubjectType)

_Enum:_{.json-schema-reset .json-schema-value} `user`, `invitee`, `team`
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "type": "user",
  "id": "example"
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### SubjectRole {#entity-SubjectRole}

#|
|| **Name** | **Description** ||
||

_role_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [RepoRole](#entity-RepoRole)

_Enum:_{.json-schema-reset .json-schema-value} `viewer`, `contributor`, `developer`, `maintainer`, `admin`
{.table-cell}
||
||

_subject_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [Subject](#entity-Subject)

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "type": "user",
  "id": "example"
}
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "role": "viewer",
  "subject": {
    "type": "user",
    "id": "example"
  }
}
```

{% endcut %}

</div>

## Responses

<div class="openapi__response__code__200">

## 200 OK

A successful response.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "subject_roles": [
    {
      "role": "viewer",
      "subject": {
        "type": "user",
        "id": "example"
      }
    }
  ],
  "next_page_token": "example"
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_next_page_token_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

A token, which can be sent as `page_token` to retrieve the next page.
If this field is omitted, there are no subsequent pages.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_subject_roles_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [SubjectRole](#entity-SubjectRole)[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "role": "viewer",
    "subject": {
      "type": "user",
      "id": "example"
    }
  }
]
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

</div>

</div>

<div class="openapi__response__code__default">

## default

Both Client Errors (4xx) and Server Errors (5xx) are serialized into this scheme

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "error_code": "example",
  "message": "example",
  "request_id": "example",
  "details": null
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_details_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: unknown

_Example:_{.json-schema-reset .json-schema-example} `null`
{.table-cell}
||
||

_error_code_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_message_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_request_id_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

</div>

</div>

</div>

[*Deprecated]: No longer supported, please use an alternative and newer version.