Skip to content
Ona Docs

GetMembership

client.groups.memberships.retrieve(MembershipRetrieveParams { subject, groupId } body, RequestOptionsoptions?): MembershipRetrieveResponse { member }
POST/gitpod.v1.GroupService/GetMembership

Gets a specific membership by group ID and subject.

Use this method to:

  • Check if a user or service account is a member of a group
  • Verify group membership for access control

Examples

  • Check user membership:

    Checks if a user is a member of a specific group.

    groupId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
    subject:
      id: "f53d2330-3795-4c5d-a1f3-453121af9c60"
      principal: PRINCIPAL_USER

Authorization

All organization members can check group membership (transparency model).

ParametersExpand Collapse
body: MembershipRetrieveParams { subject, groupId }
subject: Subject { id, principal }

Subject to check membership for

id?: string

id is the UUID of the subject

formatuuid
principal?: Principal

Principal is the principal of the subject

One of the following:
"PRINCIPAL_UNSPECIFIED"
"PRINCIPAL_ACCOUNT"
"PRINCIPAL_USER"
"PRINCIPAL_RUNNER"
"PRINCIPAL_ENVIRONMENT"
"PRINCIPAL_SERVICE_ACCOUNT"
"PRINCIPAL_RUNNER_MANAGER"
groupId?: string
formatuuid
ReturnsExpand Collapse
MembershipRetrieveResponse { member }
member?: GroupMembership { id, avatarUrl, groupId, 2 more }

The membership if found, nil if subject is not a member

id?: string

Unique identifier for the group membership

formatuuid
avatarUrl?: string

Subject’s avatar URL

groupId?: string

Group identifier

formatuuid
name?: string

Subject’s display name

subject?: Subject { id, principal }

Subject (user, runner, environment, service account, etc.)

id?: string

id is the UUID of the subject

formatuuid
principal?: Principal

Principal is the principal of the subject

One of the following:
"PRINCIPAL_UNSPECIFIED"
"PRINCIPAL_ACCOUNT"
"PRINCIPAL_USER"
"PRINCIPAL_RUNNER"
"PRINCIPAL_ENVIRONMENT"
"PRINCIPAL_SERVICE_ACCOUNT"
"PRINCIPAL_RUNNER_MANAGER"

GetMembership

import Gitpod from '@gitpod/sdk';

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

const membership = await client.groups.memberships.retrieve({
  subject: { id: 'f53d2330-3795-4c5d-a1f3-453121af9c60', principal: 'PRINCIPAL_USER' },
  groupId: 'd2c94c27-3b76-4a42-b88c-95a85e392c68',
});

console.log(membership.member);
{
  "member": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "avatarUrl": "avatarUrl",
    "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "name": "name",
    "subject": {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "principal": "PRINCIPAL_UNSPECIFIED"
    }
  }
}
Returns Examples
{
  "member": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "avatarUrl": "avatarUrl",
    "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "name": "name",
    "subject": {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "principal": "PRINCIPAL_UNSPECIFIED"
    }
  }
}