# Resource types

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

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 resource types

```http
GET https://api.{region}.pontive.com/v1/authz/resource-types
```

List the instance's resource types: the reserved root and org types (org in b2b instances only), and the custom types.

Operation ID: `ListResourceTypes`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |
| `sort` | string |  | Sort field; prefix with - for descending (e.g. -created_at). Allowed: created_at, updated_at, name, key. Default: -created_at |

### Responses

- `200` OK: ListResourceTypesResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## Create resource type

```http
POST https://api.{region}.pontive.com/v1/authz/resource-types
```

Register a resource type in the instance's registry. Only custom types can be created: root and org are reserved and seeded.

Operation ID: `CreateResourceType`

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

Create Resource Type Request

### Responses

- `201` Created: ResourceType
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## Get resource type

```http
GET https://api.{region}.pontive.com/v1/authz/resource-types/{resource_type}
```

Get a resource type by its key.

Operation ID: `GetResourceType`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_type` | string | yes | Resource type key |

### Responses

- `200` OK: ResourceType
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `500` Internal Server Error: ErrResponse

## Update resource type

```http
PATCH https://api.{region}.pontive.com/v1/authz/resource-types/{resource_type}
```

Update a resource type. Cannot update: key (immutable). The reserved root and org types accept only name and description.

Operation ID: `UpdateResourceType`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_type` | string | yes | Resource type key |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `If-Match` | string |  | The ETag the document was read with: a stale one is refused 412 precondition_failed (D42) |

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

Update Resource Type Request

### Responses

- `200` OK: ResourceType
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `412` precondition_failed: the document changed since it was read: ErrResponse
- `500` Internal Server Error: ErrResponse

## Delete resource type

```http
DELETE https://api.{region}.pontive.com/v1/authz/resource-types/{resource_type}
```

Delete a resource type from the registry by its key. The reserved root and organization types cannot be deleted.

Operation ID: `DeleteResourceType`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_type` | string | yes | Resource type key |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `If-Match` | string |  | The ETag the document was read with: a stale one is refused 412 precondition_failed (D42) |

### Responses

- `204` No Content
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `412` precondition_failed: the document changed since it was read: ErrResponse
- `500` Internal Server Error: ErrResponse

## Schemas

### ListResourceTypesResponse

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

### ErrResponse

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

### CreateResourceTypeRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `allow_members_to_leave` | boolean |  | The membership policy. Roles on join are set once the type's roles exist. |
| `description` | string |  |  |
| `invitation_expiry_days` | integer |  |  |
| `key` | string | yes |  |
| `name` | string |  |  |
| `parents` | string[] |  | The parent type keys: at least one (parents_required). The type's shortest chain of parent types from root or org, self-references aside, is at most 8 levels (max_depth_exceeded) and must exist (cycle_detected): deeper, or with no chain, no resource of the type could ever be registered. |

### ResourceType

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `description` | string |  |  |
| `instance_id` | string |  |  |
| `key` | string |  |  |
| `name` | string |  |  |
| `object` | string |  |  |
| `parents` | string[] |  | Parents are the types this type's objects may sit under: at least one on every type but root. Each is one edge, whose relation in the authorization model is the parent's key. |
| `policy` | MembershipPolicy |  | Policy is a custom type's membership policy; defaults on the reserved types. |
| `reserved` | boolean |  | Reserved is true for the seeded root and org types: they cannot be deleted, and only their name and description change. |
| `updated_at` | string |  |  |

### UpdateResourceTypeRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `allow_members_to_leave` | boolean |  | The membership policy fields; each omitted is left unchanged. |
| `description` | string |  |  |
| `invitation_expiry_days` | integer |  | 0 clears it to the instance's. |
| `name` | string |  |  |
| `parents` | string[] |  | Replaces the parent type keys when present; an empty list is refused (parents_required), a type never loses its last parent type. The new set must leave this type, and every type under it, within 8 levels of root or org (max_depth_exceeded) and with a chain of parent types to root (cycle_detected). |
| `roles_on_join` | 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. |

### MembershipPolicy

Policy is a custom type's membership policy; defaults on the reserved
types.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `allow_members_to_leave` | boolean |  | AllowMembersToLeave lets a member remove their own membership. |
| `invitation_expiry_days` | integer |  | InvitationExpiryDays overrides the instance's invitation expiry; absent is the instance's. |
| `roles_on_join` | string[] |  | RolesOnJoin are given when someone is added to or invited into one of the type's resources without roles. That resource only. |

### 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. |
