# Resources

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

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 resources

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

Retrieve a paginated list of resources. Filter by resource_type, the organization they belong to (or instance_level for those in none), a parent (its direct children), and external_id, or search the name and external id by free text.

Operation ID: `ListResources`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_type` | string |  | Filter by resource type |
| `organization_id` | string |  | Only resources belonging to this organization |
| `instance_level` | boolean |  | Only resources in no organization: the instance's own. Exclusive with organization_id |
| `parent_id` | string |  | Only the direct children of this organization or resource, or of the instance root (its instance id, or root) |
| `external_id` | string |  | Exact match on the id the caller gave the resource |
| `search` | string |  | Free text matched against the name and the external id, case-insensitively |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |

### Responses

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

## Create resource

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

Register an object another system owns, so members, roles and authorization can refer to it. It may belong to an organization (and is then deleted with it), and may sit under one parent — the organization it belongs to, or a resource belonging to it; for one in no organization, another such resource or the instance root (its instance id, or root) — of one of the parent types its resource type declares; roles held on the parent reach it by its type's inheritance rules. The parent is required: no resource is under nothing.

Operation ID: `CreateResource`

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

Resource creation details

### Responses

- `201` Created: Resource
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` The resource type, organization or a parent does not exist: ErrResponse
- `409` A resource of this type is already registered with this external_id: ErrResponse
- `500` Internal Server Error: ErrResponse

## Get resource

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

Retrieve a resource by its ID, with its parent.

Operation ID: `GetResource`

### Path parameters

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

### Responses

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

## Update resource

```http
PATCH https://api.{region}.pontive.com/v1/resources/{resource_id}
```

Change a resource's name or metadata. Its type, external id and organization never change; its parent changes through the parent endpoints.

Operation ID: `UpdateResource`

### Path parameters

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

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

Fields to change

### Responses

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

## Delete resource

```http
DELETE https://api.{region}.pontive.com/v1/resources/{resource_id}
```

Deregister a resource. One that has children is refused with 409 unless cascade=true, which also deregisters its whole subtree.

Operation ID: `DeleteResource`

### Path parameters

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

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `cascade` | boolean |  | Also deregister its whole subtree (required when it has children) |

### Responses

- `200` OK: DeleteResourceResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `409` The resource has children and cascade is not set: ErrResponse
- `500` Internal Server Error: ErrResponse

## List resource members

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

List the users holding roles on a resource itself. Users who reach it only by inheritance from a parent are not members and are not listed.

Operation ID: `ListResourceMembers`

### Path parameters

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

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_ids` | string[] |  | Filter by user IDs |
| `emails` | string[] |  | Filter by emails |
| `roles` | string[] |  | Filter by roles |
| `search` | string |  | search query |
| `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, joined_at, email. Default: -created_at |

### Responses

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

## Add a member to a resource

```http
POST https://api.{region}.pontive.com/v1/resources/{resource_id}/members
```

Add a user to a resource with roles of the resource's type. A user who is not a member of the resource's organization joins it too, with the membership settings' roles_on_join (none by default). A user who would take the organization past its member limit is refused 409 seat_limit_reached, and nothing is written.

Operation ID: `CreateResourceMember`

### Path parameters

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

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

Member to add

### Responses

- `201` Created: Member
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `500` Internal Server Error: ErrResponse

## Get a resource member

```http
GET https://api.{region}.pontive.com/v1/resources/{resource_id}/members/{user_id}
```

Get one member of a resource by user ID

Operation ID: `GetResourceMember`

### Path parameters

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

### Responses

- `200` OK: Member
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `500` Internal Server Error: ErrResponse

## Update a resource member's roles

```http
PATCH https://api.{region}.pontive.com/v1/resources/{resource_id}/members/{user_id}
```

Replace the roles a member holds on a resource

Operation ID: `UpdateResourceMember`

### Path parameters

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

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

New roles

### Responses

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

## Remove a member from a resource

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

Remove a user from a resource. Their membership of the resource's organization stays.

Operation ID: `DeleteResourceMember`

### Path parameters

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

### Responses

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

## Move a resource under a parent

```http
PUT https://api.{region}.pontive.com/v1/resources/{resource_id}/parent
```

Set the resource's parent, replacing the one it had: a move, with its subtree. The parent is the organization the resource belongs to, or a resource belonging to it; for a resource in no organization, another such resource or the instance root, by its instance id or root — of one of the parent types the resource's type declares. Roles held on the parent then reach the resource. A move that would make the resource its own ancestor is refused with 409, one that would nest it more than 8 levels deep with 400. Setting the parent it already has succeeds.

Operation ID: `ReplaceResourceParent`

### Path parameters

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

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

The parent

### Responses

- `200` OK: Resource
- `400` Invalid parent, or the move would exceed the depth limit: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `409` The move would close a cycle: ErrResponse
- `500` Internal Server Error: ErrResponse

## Schemas

### ListResourcesResponse

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

### ErrResponse

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

### CreateResourceRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `external_id` | string |  |  |
| `metadata` | Metadata |  | Metadata replaces the resource's metadata when set. |
| `name` | string |  |  |
| `organization_id` | string |  |  |
| `parent` | ResourceParent |  | Parent is always set. |
| `resource_type` | string | yes |  |

### Resource

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `external_id` | string |  |  |
| `id` | string |  |  |
| `metadata` | Metadata |  | Metadata replaces the resource's metadata when set. |
| `name` | string |  |  |
| `object` | string |  |  |
| `organization_id` | string |  |  |
| `parent` | ResourceParent |  | Parent is always set. |
| `resource_type` | string |  |  |
| `updated_at` | string |  |  |

### UpdateResourceRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `clear_metadata` | boolean |  | ClearMetadata empties the metadata; metadata must then be omitted. |
| `metadata` | Metadata |  | Metadata replaces the resource's metadata when set. |
| `name` | string |  |  |

### DeleteResourceResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `deregistered_ids` | string[] |  |  |

### ListMembersResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | Member[] |  | List of members |
| `object` | string |  | The object type |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### AddResourceMemberRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `roles` | string[] | yes |  |
| `user_id` | string | yes |  |

### Member

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `instance_id` | string |  |  |
| `joined_at` | string |  |  |
| `last_active_at` | string |  |  |
| `object` | string |  |  |
| `resource_id` | string |  |  |
| `resource_name` | string |  |  |
| `resource_type` | string |  |  |
| `roles` | RoleRef[] |  |  |
| `updated_at` | string |  |  |
| `user` | MemberUser |  |  |

### UpdateResourceMemberRolesRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `roles` | string[] | yes |  |

### SetResourceParentRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_id` | string | yes | The parent: org_…, res_…, or the instance root (its instance id, or "root"). |

### 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 resource's metadata when set.

Type: Record<string, string>

### ResourceParent

Parent is always set.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_id` | string | yes |  |
| `resource_type` | string |  |  |

### RoleRef

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string |  |  |
| `name` | string |  |  |

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

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