# Groups

Source: https://www.pontive.com/docs/api-reference/management/groups

Base URL: `https://api.{region}.pontive.com/v1` (operations that name another server say so).

Authentication: send `Authorization: Bearer <token>` with a secret key (`pontive_sk_…`, which implies its instance) or an access token issued for this API. A token that can reach several instances also names one with `X-Pontive-Instance-ID: inst_…`. Secret keys are for servers only.

## List groups

```http
GET https://api.{region}.pontive.com/v1/groups
```

List the instance's groups, filtered by owner (D6, D15, D44): owner_type root lists the instance's own groups, org the organizations', a resource type key that type's resources'; owner_id narrows to one owner's. Neither lists every group.

Operation ID: `ListGroups`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner_type` | string |  | root, org, or the owning resource's type key |
| `owner_id` | string |  | One owner's prefixed id: inst_, org_ or res_ |
| `search` | string |  | Matches the name |
| `external_id` | string |  | An identity provider's id for the group |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |
| `sort` | string |  | Sort field; prefix with - for descending. Allowed: created_at, updated_at, name. Default: -created_at |

### Responses

- `200` OK: ListGroupsResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse

## Create a group

```http
POST https://api.{region}.pontive.com/v1/groups
```

Create a group, owned by the instance root, an organization or a resource (D5, D6, D44): owner_type is root (the default), org or the owning resource's type key, owner_id its prefixed id (org_, res_; for root the inst_ id or empty). An instance group (root) holds any of the instance's users and is granted roles only on the instance root and resources in no organization; an organization's is a set of its members granted on the organization or its resources; a resource's holds its organization's members and is granted only on the resource and the resources beneath it.

Operation ID: `CreateGroup`

### Request body (`application/json`, required): CreateOwnedGroupRequest

Group

### Responses

- `201` Created: Group
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse

## Get a group

```http
GET https://api.{region}.pontive.com/v1/groups/{group_id}
```

Operation ID: `GetGroup`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |

### Responses

- `200` OK: Group
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse

## Update a group

```http
PATCH https://api.{region}.pontive.com/v1/groups/{group_id}
```

Operation ID: `UpdateGroup`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |

### Request body (`application/json`, required): UpdateGroupRequest

Changes

### Responses

- `200` OK: Group
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse

## Delete a group

```http
DELETE https://api.{region}.pontive.com/v1/groups/{group_id}
```

Delete a group with its members and grants. Its members lose what the group gave them.

Operation ID: `DeleteGroup`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |

### Responses

- `204` No Content
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse

## List a group's members

```http
GET https://api.{region}.pontive.com/v1/groups/{group_id}/members
```

Operation ID: `ListGroupMembers`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `search` | string |  | Matches email and name |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |

### Responses

- `200` OK: ListGroupMembersResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse

## Add members to a group

```http
POST https://api.{region}.pontive.com/v1/groups/{group_id}/members
```

Add users to a group. Each must be a member of the group's organization (user_not_in_organization); one already in the group is left as they are.

Operation ID: `CreateGroupMembers`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |

### Request body (`application/json`, required): AddGroupMembersRequest

Users

### Responses

- `200` OK: AddGroupMembersResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse

## Remove a member from a group

```http
DELETE https://api.{region}.pontive.com/v1/groups/{group_id}/members/{user_id}
```

Operation ID: `DeleteGroupMember`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |
| `user_id` | string | yes | User ID |

### Responses

- `204` No Content
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse

## List a group's roles

```http
GET https://api.{region}.pontive.com/v1/groups/{group_id}/roles
```

List the roles a group holds, per resource

Operation ID: `ListGroupGrants`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |

### Responses

- `200` OK: ListGroupGrantsResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse

## Set a group's roles on a resource

```http
PUT https://api.{region}.pontive.com/v1/groups/{group_id}/roles
```

Replace the roles a group holds on one resource — its organization, or a resource of it (resource_not_in_organization) — with roles of that resource's type. No roles removes the grant.

Operation ID: `ReplaceGroupRoles`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string | yes | Group ID |

### Request body (`application/json`, required): SetGroupRolesRequest

Grant

### Responses

- `200` OK: GroupGrant
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse

## List the groups holding roles on an organization

```http
GET https://api.{region}.pontive.com/v1/organizations/{organization}/group-roles
```

The groups holding roles on an organization itself, each with its roles there (api-route-review D43). A group holding roles only on the organization's resources is not listed; the groups the organization owns are GET /groups?owner_type=org&owner_id=….

Operation ID: `ListOrganizationGroupRoles`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `organization` | string | yes | The organization's id, or its slug |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |

### Responses

- `200` OK: ListGroupGrantsResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse

## List the groups holding roles on a resource

```http
GET https://api.{region}.pontive.com/v1/resources/{resource_id}/group-roles
```

The groups holding roles on a resource, whoever owns them, each with its roles there (api-route-review D43). The groups the resource owns are GET /groups?owner_type=<its type>&owner_id=….

Operation ID: `ListResourceGroupRoles`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_id` | string | yes | Resource ID |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |

### Responses

- `200` OK: ListGroupGrantsResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse

## List the groups holding roles on the instance root

```http
GET https://api.{region}.pontive.com/v1/root/group-roles
```

The groups holding roles on the instance root, each with its roles there (api-route-review D43): the read edge from the other side of GET /groups/{group_id}/roles. The groups the root owns are GET /groups?owner_type=root.

Operation ID: `ListRootGroupRoles`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |

### Responses

- `200` OK: ListGroupGrantsResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse

## Schemas

### ListGroupsResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | Group[] |  |  |
| `object` | string |  |  |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### ErrResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | ErrBody |  |  |

### CreateOwnedGroupRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `external_id` | string |  | ExternalID is an identity provider's id for the group, unique in its owner. |
| `metadata` | Metadata |  | Metadata replaces the group's metadata when set. |
| `name` | string | yes |  |
| `owner_id` | string |  | OwnerID is the owner's prefixed id: org_ or res_; for root the inst_ id or empty. |
| `owner_type` | string |  | OwnerType is root (the default), org, or the owning resource's type key, which must be that resource's type. |

### Group

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `external_id` | string |  |  |
| `id` | string |  |  |
| `member_count` | integer |  |  |
| `metadata` | Metadata |  | Metadata replaces the group's metadata when set. |
| `name` | string |  |  |
| `object` | string |  |  |
| `owner_id` | string |  | OwnerID is the owner's prefixed id: inst_, org_ or res_. |
| `owner_type` | string |  | OwnerType is the owner's resource-type key: root, org, or the owning resource's type key. |
| `updated_at` | string |  |  |

### UpdateGroupRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `external_id` | string |  | ExternalID, when set, replaces it; an empty string clears it. |
| `metadata` | Metadata |  | Metadata replaces the group's metadata when set. |
| `name` | string |  |  |

### ListGroupMembersResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | GroupMember[] |  |  |
| `object` | string |  |  |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### AddGroupMembersRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `user_ids` | string[] | yes | Each must be a member of the group's organization; an instance group takes any of the instance's users. |

### AddGroupMembersResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `added` | integer |  | How many were added; users already in the group are not counted. |

### ListGroupGrantsResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | GroupGrant[] |  |  |
| `object` | string |  |  |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### SetGroupRolesRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_id` | string | yes | ResourceID is org_…, res_…, or for the root the instance id (inst_…) or the alias "root". |
| `resource_type` | string | yes |  |
| `roles` | string[] |  |  |

### GroupGrant

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string |  |  |
| `object` | string |  |  |
| `resource_id` | string |  |  |
| `resource_type` | string |  |  |
| `roles` | string[] |  |  |

### Pagination

Pagination is the page answered (api-route-review D9).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer |  | Limit is the maximum number of items per page. |
| `page` | integer |  | Page is the 1-based index of the returned page. |
| `total` | integer |  | Total is the total number of items across all pages. |
| `total_pages` | integer |  | TotalPages is the total number of pages available. |

### ErrBody

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code is the spec's machine-readable code for this error, in snake case: a domain code such as seat_limit_reached where the refusal has one, otherwise a generic one such as permission_denied, not_found, conflict, invalid_request or service_unavailable. |
| `details` | ErrDetail[] |  | Details are per-field findings, present only on a refusal that has them, e.g. a 422 invalid_theme names each invalid value by its path, a 422 package_invalid each problem, and a 409 capability_in_use each count by its name. |
| `doc_url` | string |  | DocURL links to documentation about this error, when available. |
| `message` | string |  | Message is a human-readable description of what went wrong. |
| `object` | string |  | Object is the discriminator; always "error". |
| `param` | string |  | Param names the request parameter this error refers to, when applicable. |
| `type` | "validation_error" \| "authentication_error" \| "authorization_error" \| "not_found" \| "conflict_error" \| "rate_limit_error" \| "internal_error" |  | Type is the error's category, set by its HTTP status: one of validation_error, authentication_error, authorization_error, not_found, conflict_error, rate_limit_error, internal_error. |

### Metadata

Metadata replaces the group's metadata when set.

Type: Record<string, string>

### GroupMember

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `group_id` | string |  |  |
| `joined_at` | string |  |  |
| `object` | string |  |  |
| `user` | MemberUser |  |  |

### ErrDetail

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string |  | Field is where the finding is: for a theme, its dotted path. |
| `message` | string |  | Message is what is wrong there. |

### MemberUser

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string |  |  |
| `email_verified` | boolean |  |  |
| `family_name` | string |  |  |
| `given_name` | string |  |  |
| `id` | string |  |  |
| `name` | string |  |  |
| `picture` | string |  |  |
| `status` | string |  |  |
| `username` | string |  |  |
