> 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/security.md).

# Security

Password recovery, account controls, and security events

## Request password-reset instructions

> Always returns the same public message to avoid revealing registered emails.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Security","description":"Password recovery, account controls, and security events"}],"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"}],"paths":{"/api/v1/security/forgot-password":{"post":{"tags":["Security"],"summary":"Request password-reset instructions","description":"Always returns the same public message to avoid revealing registered emails.","operationId":"requestPasswordReset","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgotPasswordRequest"}}}},"responses":{"200":{"description":"The request was accepted regardless of account existence.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"400":{"$ref":"#/components/responses/ValidationError"}}}}},"components":{"schemas":{"ForgotPasswordRequest":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"}}},"MessageResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"ValidationErrors":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","additionalProperties":{"type":"string"}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"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"}]}}}}}}}
```

## Reset a password

> Uses an unused, unexpired one-time token to replace the password.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Security","description":"Password recovery, account controls, and security events"}],"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"}],"paths":{"/api/v1/security/reset-password":{"post":{"tags":["Security"],"summary":"Reset a password","description":"Uses an unused, unexpired one-time token to replace the password.","operationId":"resetPassword","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordRequest"}}}},"responses":{"200":{"description":"Password changed successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"400":{"$ref":"#/components/responses/ValidationError"}}}}},"components":{"schemas":{"ResetPasswordRequest":{"type":"object","required":["token","password"],"properties":{"token":{"type":"string","description":"Raw one-time token received in the reset link."},"password":{"type":"string","format":"password","minLength":8,"writeOnly":true}}},"MessageResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"ValidationErrors":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","additionalProperties":{"type":"string"}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"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"}]}}}}}}}
```

## Suspend a user account

> Requires \`users.suspend\`; administrators cannot suspend themselves.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Security","description":"Password recovery, account controls, and security events"}],"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"}}},"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/security/users/{user_id}/suspend":{"post":{"tags":["Security"],"summary":"Suspend a user account","description":"Requires `users.suspend`; administrators cannot suspend themselves.","operationId":"suspendUser","responses":{"200":{"description":"Account suspended successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"400":{"$ref":"#/components/responses/ValidationError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"}}}}}}
```

## Reactivate a user account

> Requires \`users.suspend\`; administrators cannot reactivate themselves.

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Security","description":"Password recovery, account controls, and security events"}],"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"}}},"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/security/users/{user_id}/activate":{"post":{"tags":["Security"],"summary":"Reactivate a user account","description":"Requires `users.suspend`; administrators cannot reactivate themselves.","operationId":"activateUser","responses":{"200":{"description":"Account reactivated successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"400":{"$ref":"#/components/responses/ValidationError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"}}}}}}
```

## List security audit events

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

```json
{"openapi":"3.0.3","info":{"title":"Access Hub API","version":"0.2.0"},"tags":[{"name":"Security","description":"Password recovery, account controls, and security events"}],"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."}},"parameters":{"Page":{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":1}},"PerPage":{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":10}}},"schemas":{"AuditLogPage":{"type":"object","required":["events","page","per_page","total","total_pages"],"properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/AuditLog"}},"page":{"type":"integer"},"per_page":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}}},"AuditLog":{"type":"object","required":["id","action","status","created_at"],"properties":{"id":{"type":"integer"},"user_id":{"type":"integer","nullable":true},"action":{"type":"string"},"status":{"type":"string"},"ip_address":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"}}},"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/security/audit-logs":{"get":{"tags":["Security"],"summary":"List security audit events","description":"Requires the `audit.read` permission.","operationId":"listAuditLogs","parameters":[{"$ref":"#/components/parameters/Page"},{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated audit events returned successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuditLogPage"}}}},"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/security.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.
