> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Role Assignment

> Creates a role assignment for a group on a resource.

`Unary` · [`Groups`](/docs/api-reference/generated/group/overview)

Creates a role assignment for a group on a resource.

Use this method to:

* Assign specific roles to groups on runners, projects, or environments
* Grant group-based access to resources

### Examples

* Assign admin role on a runner:

  Grants the group admin access to a runner.

  ```yaml theme={null}
  groupId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  resourceType: RESOURCE_TYPE_RUNNER
  resourceId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
  resourceRole: RESOURCE_ROLE_RUNNER_ADMIN
  ```

* Assign user role on a project:

  Grants the group user access to a project.

  ```yaml theme={null}
  groupId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  resourceType: RESOURCE_TYPE_PROJECT
  resourceId: "a1b2c3d4-5678-90ab-cdef-1234567890ab"
  resourceRole: RESOURCE_ROLE_PROJECT_USER
  ```

### Authorization

Requires admin role on the specific resource.

## Endpoint

```text theme={null}
POST /api/gitpod.v1.GroupService/CreateRoleAssignment
```

Send a Bearer token as described in [Authentication](/docs/api-reference#authenticate-requests). If your organization uses a custom management-plane domain, replace `https://app.ona.com` with that domain.

## Request example

<CodeGroup>
  ```bash cURL theme={null}
  export ONA_HOST=https://app.ona.com
  export ONA_API_KEY=<your-token>

  curl --request POST \
    --url "$ONA_HOST/api/gitpod.v1.GroupService/CreateRoleAssignment" \
    --header "Authorization: Bearer $ONA_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{
    "groupId": "<group-id>"
  }'
  ```

  ```python Python theme={null}
  import gitpod.v1.group_pb2 as group_pb2
  from ona_sdk import create_client_from_env

  ona = create_client_from_env()
  request = group_pb2.CreateRoleAssignmentRequest(
      group_id="<group-id>",
  )
  response = ona.services.group.create_role_assignment(request)
  print(response)
  ```

  ```typescript TypeScript theme={null}
  import { create } from "@bufbuild/protobuf";
  import { createClientFromEnv } from "@gitpod/sdk";
  import { CreateRoleAssignmentRequestSchema } from "@gitpod/sdk/gitpod/v1/group_pb";

  async function main() {
    const ona = createClientFromEnv();
    const request = create(CreateRoleAssignmentRequestSchema, {
      groupId: "<group-id>",
    });
    const response = await ona.services.group.createRoleAssignment(request);
    console.log(response);
  }

  main().catch(console.error);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	"connectrpc.com/connect"
  	"github.com/gitpod-io/gitpod-sdk-go/sdk"
  	gitpodpb "github.com/gitpod-io/gitpod-sdk-go/v1"
  )

  func main() {
  	ona, err := sdk.NewFromEnv()
  	if err != nil {
  		log.Fatal(err)
  	}

  	request := connect.NewRequest(&gitpodpb.CreateRoleAssignmentRequest{
  		GroupId: "<group-id>",
  	})
  	response, err := ona.Services.Group.CreateRoleAssignment(context.Background(), request)
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(response.Msg)
  }
  ```

  ```json Request body theme={null}
  {
    "groupId": "<group-id>"
  }
  ```
</CodeGroup>

## Request

`gitpod.v1.CreateRoleAssignmentRequest`

CreateRoleAssignment messages

| Field          | Type                                          | Required | Description                      |
| -------------- | --------------------------------------------- | -------- | -------------------------------- |
| `groupId`      | string                                        | No       | Constraints: `string.uuid=true`. |
| `resourceType` | [ResourceType](#enum-gitpod-v1-resource-type) | No       |                                  |
| `resourceId`   | string                                        | No       | Constraints: `string.uuid=true`. |
| `resourceRole` | [ResourceRole](#enum-gitpod-v1-resource-role) | No       |                                  |

## Response

`gitpod.v1.CreateRoleAssignmentResponse`

| Field        | Type                                              | Required | Description |
| ------------ | ------------------------------------------------- | -------- | ----------- |
| `assignment` | [RoleAssignment](#type-gitpod-v1-role-assignment) | No       |             |

## Related types

<a id="type-gitpod-v1-role-assignment" />

<Accordion title="RoleAssignment">
  RoleAssignment represents a role assigned to a group on a specific resource

  `gitpod.v1.RoleAssignment`

  | Field                | Type                                          | Required | Description                                                                                                                                                                                                                                                |
  | -------------------- | --------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `id`                 | string                                        | No       | Unique identifier for the role assignment Constraints: `string.uuid=true`.                                                                                                                                                                                 |
  | `groupId`            | string                                        | No       | Group identifier Constraints: `string.uuid=true`.                                                                                                                                                                                                          |
  | `organizationId`     | string                                        | No       | Organization identifier Constraints: `string.uuid=true`.                                                                                                                                                                                                   |
  | `resourceId`         | string                                        | No       | Resource identifier Constraints: `string.uuid=true`.                                                                                                                                                                                                       |
  | `resourceType`       | [ResourceType](#enum-gitpod-v1-resource-type) | No       | Type of resource (runner, project, environment, etc.)                                                                                                                                                                                                      |
  | `resourceRole`       | [ResourceRole](#enum-gitpod-v1-resource-role) | No       | Role assigned to the group on this resource                                                                                                                                                                                                                |
  | `derivedFromOrgRole` | [ResourceRole](#enum-gitpod-v1-resource-role) | No       | The org-level role that created this assignment, if any. RESOURCE\_ROLE\_UNSPECIFIED means this is a direct share (manually created). Non-zero (e.g., ORG\_PROJECTS\_ADMIN, ORG\_RUNNERS\_ADMIN) means this assignment was derived from an org-level role. |
</Accordion>

<a id="enum-gitpod-v1-resource-role" />

<Accordion title="ResourceRole">
  ResourceRole represents roles that can be assigned to groups on resources
  These map directly to the roles defined in backend/db/rule/rbac/role/role.go

  | Value                                             | Number | Description                     |
  | ------------------------------------------------- | -----: | ------------------------------- |
  | `RESOURCE_ROLE_UNSPECIFIED`                       |      0 |                                 |
  | `RESOURCE_ROLE_ORG_ADMIN`                         |      1 | Organization roles              |
  | `RESOURCE_ROLE_ORG_MEMBER`                        |      2 |                                 |
  | `RESOURCE_ROLE_ORG_RUNNERS_ADMIN`                 |     50 |                                 |
  | `RESOURCE_ROLE_ORG_PROJECTS_ADMIN`                |     51 |                                 |
  | `RESOURCE_ROLE_ORG_AUTOMATIONS_ADMIN`             |     52 |                                 |
  | `RESOURCE_ROLE_ORG_GROUPS_ADMIN`                  |     53 |                                 |
  | `RESOURCE_ROLE_ORG_ENVIRONMENTS_READER`           |     66 |                                 |
  | `RESOURCE_ROLE_ORG_AUDIT_LOG_READER`              |     64 |                                 |
  | `RESOURCE_ROLE_ORG_BILLING_VIEWER`                |     67 |                                 |
  | `RESOURCE_ROLE_ORG_INSIGHTS_VIEWER`               |     68 |                                 |
  | `RESOURCE_ROLE_ORG_SECURITY_ADMIN`                |     69 |                                 |
  | `RESOURCE_ROLE_ORG_DEFENCE_FACTORY_ADMIN`         |     72 |                                 |
  | `RESOURCE_ROLE_GROUP_ADMIN`                       |      3 | Group roles                     |
  | `RESOURCE_ROLE_GROUP_VIEWER`                      |      4 |                                 |
  | `RESOURCE_ROLE_USER_IDENTITY`                     |      5 | User roles                      |
  | `RESOURCE_ROLE_USER_VIEWER`                       |      6 |                                 |
  | `RESOURCE_ROLE_USER_ADMIN`                        |      7 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_IDENTITY`              |      8 | Environment roles               |
  | `RESOURCE_ROLE_ENVIRONMENT_ADMIN`                 |      9 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_USER`                  |     10 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_VIEWER`                |     11 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_RUNNER`                |     12 |                                 |
  | `RESOURCE_ROLE_RUNNER_IDENTITY`                   |     13 | Runner roles                    |
  | `RESOURCE_ROLE_RUNNER_ADMIN`                      |     14 |                                 |
  | `RESOURCE_ROLE_RUNNER_LOCAL_ADMIN`                |     15 |                                 |
  | `RESOURCE_ROLE_RUNNER_MANAGED_ADMIN`              |     16 |                                 |
  | `RESOURCE_ROLE_RUNNER_USER`                       |     17 |                                 |
  | `RESOURCE_ROLE_RUNNER_CONFIGURATION_READER`       |     18 |                                 |
  | `RESOURCE_ROLE_HOST_AUTHENTICATION_TOKEN_ADMIN`   |     19 | Host authentication token roles |
  | `RESOURCE_ROLE_HOST_AUTHENTICATION_TOKEN_UPDATER` |     20 |                                 |
  | `RESOURCE_ROLE_PROJECT_ADMIN`                     |     21 | Project roles                   |
  | `RESOURCE_ROLE_PROJECT_USER`                      |     22 |                                 |
  | `RESOURCE_ROLE_PROJECT_EDITOR`                    |     23 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_SERVICE_ADMIN`         |     24 | Environment service roles       |
  | `RESOURCE_ROLE_ENVIRONMENT_SERVICE_VIEWER`        |     25 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_SERVICE_USER`          |     26 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_SERVICE_ENV`           |     27 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_TASK_ADMIN`            |     28 | Environment task roles          |
  | `RESOURCE_ROLE_ENVIRONMENT_TASK_VIEWER`           |     29 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_TASK_USER`             |     30 |                                 |
  | `RESOURCE_ROLE_ENVIRONMENT_TASK_ENV`              |     31 |                                 |
  | `RESOURCE_ROLE_SERVICE_ACCOUNT_IDENTITY`          |     32 | Service account roles           |
  | `RESOURCE_ROLE_SERVICE_ACCOUNT_ADMIN`             |     33 |                                 |
  | `RESOURCE_ROLE_AGENT_EXECUTION_USER`              |     35 |                                 |
  | `RESOURCE_ROLE_AGENT_EXECUTION_ADMIN`             |     36 |                                 |
  | `RESOURCE_ROLE_AGENT_EXECUTION_RUNNER`            |     37 |                                 |
  | `RESOURCE_ROLE_AGENT_EXECUTION_OUTPUTS_REPORTER`  |     46 |                                 |
  | `RESOURCE_ROLE_AGENT_EXECUTION_VIEWER`            |     65 |                                 |
  | `RESOURCE_ROLE_AGENT_ADMIN`                       |     38 | Agent roles                     |
  | `RESOURCE_ROLE_AGENT_VIEWER`                      |     39 |                                 |
  | `RESOURCE_ROLE_AGENT_EXECUTOR`                    |     40 |                                 |
  | `RESOURCE_ROLE_WORKFLOW_ADMIN`                    |     41 | Workflow roles                  |
  | `RESOURCE_ROLE_WORKFLOW_USER`                     |     42 |                                 |
  | `RESOURCE_ROLE_WORKFLOW_VIEWER`                   |     43 |                                 |
  | `RESOURCE_ROLE_WORKFLOW_EXECUTOR`                 |     47 |                                 |
  | `RESOURCE_ROLE_SNAPSHOT_ADMIN`                    |     44 | Snapshot roles                  |
  | `RESOURCE_ROLE_SNAPSHOT_RUNNER`                   |     45 |                                 |
  | `RESOURCE_ROLE_WEBHOOK_ADMIN`                     |     48 | Webhook roles                   |
  | `RESOURCE_ROLE_WEBHOOK_VIEWER`                    |     49 |                                 |
  | `RESOURCE_ROLE_WARMPOOL_RUNNER`                   |     54 |                                 |
  | `RESOURCE_ROLE_WARMPOOL_ADMIN`                    |     55 |                                 |
  | `RESOURCE_ROLE_WARMPOOL_VIEWER`                   |     56 |                                 |
  | `RESOURCE_ROLE_SESSION_ADMIN`                     |     60 | Session roles                   |
  | `RESOURCE_ROLE_SESSION_USER`                      |     61 |                                 |
  | `RESOURCE_ROLE_TEAM_ADMIN`                        |     62 |                                 |
  | `RESOURCE_ROLE_TEAM_VIEWER`                       |     63 |                                 |
  | `RESOURCE_ROLE_SECURITY_POLICY_ADMIN`             |     70 |                                 |
  | `RESOURCE_ROLE_SECURITY_POLICY_VIEWER`            |     71 |                                 |
</Accordion>

<a id="enum-gitpod-v1-resource-type" />

<Accordion title="ResourceType">
  | Value                                        | Number | Description |
  | -------------------------------------------- | -----: | ----------- |
  | `RESOURCE_TYPE_UNSPECIFIED`                  |      0 |             |
  | `RESOURCE_TYPE_ENVIRONMENT`                  |      1 |             |
  | `RESOURCE_TYPE_RUNNER`                       |      2 |             |
  | `RESOURCE_TYPE_PROJECT`                      |      3 |             |
  | `RESOURCE_TYPE_TASK`                         |      4 |             |
  | `RESOURCE_TYPE_TASK_EXECUTION`               |      5 |             |
  | `RESOURCE_TYPE_SERVICE`                      |      6 |             |
  | `RESOURCE_TYPE_ORGANIZATION`                 |      7 |             |
  | `RESOURCE_TYPE_USER`                         |      8 |             |
  | `RESOURCE_TYPE_ENVIRONMENT_CLASS`            |      9 |             |
  | `RESOURCE_TYPE_RUNNER_SCM_INTEGRATION`       |     10 |             |
  | `RESOURCE_TYPE_HOST_AUTHENTICATION_TOKEN`    |     11 |             |
  | `RESOURCE_TYPE_GROUP`                        |     12 |             |
  | `RESOURCE_TYPE_PERSONAL_ACCESS_TOKEN`        |     13 |             |
  | `RESOURCE_TYPE_USER_PREFERENCE`              |     14 |             |
  | `RESOURCE_TYPE_SERVICE_ACCOUNT`              |     15 |             |
  | `RESOURCE_TYPE_SECRET`                       |     16 |             |
  | `RESOURCE_TYPE_SSO_CONFIG`                   |     17 |             |
  | `RESOURCE_TYPE_DOMAIN_VERIFICATION`          |     18 |             |
  | `RESOURCE_TYPE_AGENT_EXECUTION`              |     19 |             |
  | `RESOURCE_TYPE_RUNNER_LLM_INTEGRATION`       |     20 |             |
  | `RESOURCE_TYPE_AGENT`                        |     21 |             |
  | `RESOURCE_TYPE_ENVIRONMENT_SESSION`          |     22 |             |
  | `RESOURCE_TYPE_USER_SECRET`                  |     23 |             |
  | `RESOURCE_TYPE_ORGANIZATION_POLICY`          |     24 |             |
  | `RESOURCE_TYPE_ORGANIZATION_SECRET`          |     25 |             |
  | `RESOURCE_TYPE_PROJECT_ENVIRONMENT_CLASS`    |     26 |             |
  | `RESOURCE_TYPE_BILLING`                      |     27 |             |
  | `RESOURCE_TYPE_PROMPT`                       |     28 |             |
  | `RESOURCE_TYPE_COUPON`                       |     29 |             |
  | `RESOURCE_TYPE_COUPON_REDEMPTION`            |     30 |             |
  | `RESOURCE_TYPE_ACCOUNT`                      |     31 |             |
  | `RESOURCE_TYPE_INTEGRATION`                  |     32 |             |
  | `RESOURCE_TYPE_WORKFLOW`                     |     33 |             |
  | `RESOURCE_TYPE_WORKFLOW_EXECUTION`           |     34 |             |
  | `RESOURCE_TYPE_WORKFLOW_EXECUTION_ACTION`    |     35 |             |
  | `RESOURCE_TYPE_SNAPSHOT`                     |     36 |             |
  | `RESOURCE_TYPE_PREBUILD`                     |     37 |             |
  | `RESOURCE_TYPE_ORGANIZATION_LLM_INTEGRATION` |     38 |             |
  | `RESOURCE_TYPE_CUSTOM_DOMAIN`                |     39 |             |
  | `RESOURCE_TYPE_ROLE_ASSIGNMENT_CHANGED`      |     40 |             |
  | `RESOURCE_TYPE_GROUP_MEMBERSHIP_CHANGED`     |     41 |             |
  | `RESOURCE_TYPE_WEBHOOK`                      |     42 |             |
  | `RESOURCE_TYPE_SCIM_CONFIGURATION`           |     43 |             |
  | `RESOURCE_TYPE_SERVICE_ACCOUNT_SECRET`       |     44 |             |
  | `RESOURCE_TYPE_ANNOUNCEMENT_BANNER`          |     45 |             |
  | `RESOURCE_TYPE_SERVICE_ACCOUNT_TOKEN`        |     46 |             |
  | `RESOURCE_TYPE_ROLE_ASSIGNMENT`              |     47 |             |
  | `RESOURCE_TYPE_WARM_POOL`                    |     48 |             |
  | `RESOURCE_TYPE_NOTIFICATION`                 |     49 |             |
  | `RESOURCE_TYPE_SECURITY_POLICY`              |     50 |             |
</Accordion>
