Skip to content
Ona Docs

CreateProjectPolicy

client.projects.policies.create(PolicyCreateParams { groupId, projectId, role } body, RequestOptionsoptions?): PolicyCreateResponse { policy }
POST/gitpod.v1.ProjectService/CreateProjectPolicy

Creates a new policy for a project.

Use this method to:

  • Set up access controls
  • Define group permissions
  • Configure role-based access

Examples

  • Create admin policy:

    Grants admin access to a group.

    projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
    groupId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
    role: PROJECT_ROLE_ADMIN
ParametersExpand Collapse
body: PolicyCreateParams { groupId, projectId, role }
groupId?: string

group_id specifies the group_id identifier

formatuuid
projectId?: string

project_id specifies the project identifier

formatuuid
One of the following:
"PROJECT_ROLE_UNSPECIFIED"
"PROJECT_ROLE_ADMIN"
"PROJECT_ROLE_USER"
"PROJECT_ROLE_EDITOR"
ReturnsExpand Collapse
PolicyCreateResponse { policy }
policy?: ProjectPolicy { groupId, role }
groupId?: string
formatuuid

role is the role assigned to the group

One of the following:
"PROJECT_ROLE_UNSPECIFIED"
"PROJECT_ROLE_ADMIN"
"PROJECT_ROLE_USER"
"PROJECT_ROLE_EDITOR"

CreateProjectPolicy

import Gitpod from '@gitpod/sdk';

const client = new Gitpod({
  bearerToken: process.env['GITPOD_API_KEY'], // This is the default and can be omitted
});

const policy = await client.projects.policies.create({
  groupId: 'f53d2330-3795-4c5d-a1f3-453121af9c60',
  projectId: 'b0e12f6c-4c67-429d-a4a6-d9838b5da047',
  role: 'PROJECT_ROLE_ADMIN',
});

console.log(policy.policy);
{
  "policy": {
    "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "role": "PROJECT_ROLE_UNSPECIFIED"
  }
}
Returns Examples
{
  "policy": {
    "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "role": "PROJECT_ROLE_UNSPECIFIED"
  }
}