# Permissions

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

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 permissions

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

Get a paginated list of all permissions (system and custom) in the directory. Filter by type (system/custom), resource_type, name (partial match).

Operation ID: `ListPermissions`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Filter by permission type (system, custom) |
| `resource_type` | string |  | Filter by resource type |
| `name` | string |  | Filter by permission name (partial match) |
| `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: ListPermissionsResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## List a resource type's permissions

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

The permissions of one resource type (D18), filtered as GET /authz/permissions is.

Operation ID: `ListResourceTypePermissions`

### Path parameters

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

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Filter by permission type (system, custom) |
| `name` | string |  | Filter by permission name (partial match) |
| `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: ListPermissionsResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## Create custom permission

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

Create a custom permission. Required: key, resource_type. Optional: description, name. Name format: resource:action or resource:sub_resource:action.

Operation ID: `CreatePermission`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_type` | string | yes | resource_type |

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

Create Permission Request

### Responses

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

## Get permission details

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

Get a permission by name. Returns name, key, description, type, resource_type, created_at, updated_at, used_in_roles. Works for both system and custom permissions.

Operation ID: `GetPermission`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `permission_key` | string | yes | Permission Key |
| `resource_type` | string | yes | Permission resource type |

### Responses

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

## Update custom permission

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

Update a custom permission. Can update: description, name. Cannot update: key (immutable), resource_type (immutable). System permissions cannot be updated.

Operation ID: `UpdatePermission`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `permission_key` | string | yes | Permission Key |
| `resource_type` | string | yes | Permission resource type |

### 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`): UpdatePermissionRequest

Update Permission Request (description, name)

### Responses

- `200` OK: Permission
- `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 custom permission

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

Delete a custom permission. System permissions cannot be deleted. Returns 204 No Content on success.

Operation ID: `DeletePermission`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_type` | string | yes | Permission resource type |
| `permission_key` | string | yes | Permission Key |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `force` | boolean |  | Force delete (bypass confirmation when permission is used in roles) |

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

### ListPermissionsResponse

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

### ErrResponse

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

### CreatePermissionRequest

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

### Permission

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `description` | string |  |  |
| `key` | string |  |  |
| `name` | string |  |  |
| `object` | string |  |  |
| `resource_type` | string |  |  |
| `type` | "system" \| "custom" |  |  |
| `updated_at` | string |  |  |
| `used_in_roles` | RoleRef[] |  |  |

### UpdatePermissionRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  |  |
| `name` | 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. |

### RoleRef

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string |  |  |
| `name` | 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. |
