> For the complete documentation index, see [llms.txt](https://access-hub.gitbook.io/access-hub-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://access-hub.gitbook.io/access-hub-docs/permissions.md).

# Permissions

Permission management and role-permission assignment

## List permissions

> Requires the \`permissions.read\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"schemas":{"Permission":{"allOf":[{"$ref":"#/components/schemas/PermissionInput"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}]},"PermissionInput":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","maxLength":100},"description":{"type":"string","nullable":true,"maxLength":255}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/permissions":{"get":{"tags":["Permissions"],"summary":"List permissions","description":"Requires the `permissions.read` permission.","operationId":"listPermissions","responses":{"200":{"description":"Permissions returned successfully.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Permission"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"}}}}}}
```

## Create a permission

> Requires the \`permissions.create\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"requestBodies":{"PermissionInput":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionInput"}}}}},"schemas":{"PermissionInput":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","maxLength":100},"description":{"type":"string","nullable":true,"maxLength":255}}},"Permission":{"allOf":[{"$ref":"#/components/schemas/PermissionInput"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}]},"ValidationErrors":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","additionalProperties":{"type":"string"}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"ValidationError":{"description":"Request validation or a business rule failed.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ValidationErrors"},{"$ref":"#/components/schemas/Error"}]}}}},"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/permissions":{"post":{"tags":["Permissions"],"summary":"Create a permission","description":"Requires the `permissions.create` permission.","operationId":"createPermission","requestBody":{"$ref":"#/components/requestBodies/PermissionInput"},"responses":{"201":{"description":"Permission created successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Permission"}}}},"400":{"$ref":"#/components/responses/ValidationError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"}}}}}}
```

## Get a permission

> Requires the \`permissions.read\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"schemas":{"Permission":{"allOf":[{"$ref":"#/components/schemas/PermissionInput"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}]},"PermissionInput":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","maxLength":100},"description":{"type":"string","nullable":true,"maxLength":255}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFoundError":{"description":"The requested user, role, or permission was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/permissions/{permission_id}":{"get":{"tags":["Permissions"],"summary":"Get a permission","description":"Requires the `permissions.read` permission.","operationId":"getPermission","responses":{"200":{"description":"Permission returned successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Permission"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}}}}
```

## Update a permission

> Requires the \`permissions.update\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"requestBodies":{"PermissionInput":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionInput"}}}}},"schemas":{"PermissionInput":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","maxLength":100},"description":{"type":"string","nullable":true,"maxLength":255}}},"Permission":{"allOf":[{"$ref":"#/components/schemas/PermissionInput"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}]},"ValidationErrors":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","additionalProperties":{"type":"string"}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"ValidationError":{"description":"Request validation or a business rule failed.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ValidationErrors"},{"$ref":"#/components/schemas/Error"}]}}}},"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/permissions/{permission_id}":{"put":{"tags":["Permissions"],"summary":"Update a permission","description":"Requires the `permissions.update` permission.","operationId":"updatePermission","requestBody":{"$ref":"#/components/requestBodies/PermissionInput"},"responses":{"200":{"description":"Permission updated successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Permission"}}}},"400":{"$ref":"#/components/responses/ValidationError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"}}}}}}
```

## Delete a permission

> Requires the \`permissions.delete\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"schemas":{"MessageResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFoundError":{"description":"The requested user, role, or permission was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/permissions/{permission_id}":{"delete":{"tags":["Permissions"],"summary":"Delete a permission","description":"Requires the `permissions.delete` permission.","operationId":"deletePermission","responses":{"200":{"description":"Permission deleted successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}}}}
```

## List permissions assigned to a role

> Requires the \`permissions.read\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"schemas":{"Permission":{"allOf":[{"$ref":"#/components/schemas/PermissionInput"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}]},"PermissionInput":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","maxLength":100},"description":{"type":"string","nullable":true,"maxLength":255}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFoundError":{"description":"The requested user, role, or permission was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/roles/{role_id}/permissions":{"get":{"tags":["Permissions"],"summary":"List permissions assigned to a role","description":"Requires the `permissions.read` permission.","operationId":"listRolePermissions","responses":{"200":{"description":"Assigned permissions returned successfully.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Permission"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}}}}
```

## Assign a permission to a role

> Requires the \`permissions.assign\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"schemas":{"Role":{"allOf":[{"$ref":"#/components/schemas/RoleInput"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}]},"RoleInput":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","maxLength":100},"description":{"type":"string","nullable":true,"maxLength":255}}},"ValidationErrors":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","additionalProperties":{"type":"string"}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"ValidationError":{"description":"Request validation or a business rule failed.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ValidationErrors"},{"$ref":"#/components/schemas/Error"}]}}}},"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/roles/{role_id}/permissions/{permission_id}":{"post":{"tags":["Permissions"],"summary":"Assign a permission to a role","description":"Requires the `permissions.assign` permission.","operationId":"assignPermissionToRole","responses":{"200":{"description":"Permission assigned successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Role"}}}},"400":{"$ref":"#/components/responses/ValidationError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"}}}}}}
```

## Remove a permission from a role

> Requires the \`permissions.assign\` permission.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Permissions","description":"Permission management and role-permission assignment"}],"servers":[{"url":"/","description":"Same server hosting this documentation"},{"url":"http://localhost:5000","description":"Local native Flask server"},{"url":"http://localhost:5001","description":"Local Docker Compose"},{"url":"https://authmicroservice.up.railway.app","description":"Railway deployment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Enter the access token returned by the login endpoint."}},"schemas":{"Role":{"allOf":[{"$ref":"#/components/schemas/RoleInput"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}]},"RoleInput":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","maxLength":100},"description":{"type":"string","nullable":true,"maxLength":255}}},"ValidationErrors":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","additionalProperties":{"type":"string"}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"JwtError":{"type":"object","required":["msg"],"properties":{"msg":{"type":"string"}}}},"responses":{"ValidationError":{"description":"Request validation or a business rule failed.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ValidationErrors"},{"$ref":"#/components/schemas/Error"}]}}}},"UnauthorizedError":{"description":"The token is missing, invalid, expired, revoked, or has the wrong type.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/JwtError"}]}}}},"ForbiddenError":{"description":"The authenticated user does not have the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/authorization/roles/{role_id}/permissions/{permission_id}":{"delete":{"tags":["Permissions"],"summary":"Remove a permission from a role","description":"Requires the `permissions.assign` permission.","operationId":"removePermissionFromRole","responses":{"200":{"description":"Permission removed successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Role"}}}},"400":{"$ref":"#/components/responses/ValidationError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://access-hub.gitbook.io/access-hub-docs/permissions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
