Files
igny8/master-docs/20-api/ENDPOINTS/accounts.md
IGNY8 VPS (Salman) 3cbed65601 revamps docs complete
2025-12-07 14:14:29 +00:00

57 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Account Endpoints
## Purpose
Document account management endpoints for settings, team management, and usage analytics.
## Code Locations (exact paths)
- Routing: `backend/igny8_core/api/urls.py`
- Views: `backend/igny8_core/api/account_views.py`
- Settings/tenancy middleware: `backend/igny8_core/auth/middleware.py`
## High-Level Responsibilities
- Provide account settings retrieval/update, team member management, and usage analytics summaries for the authenticated account.
## Detailed Behavior
- Base path: `/api/v1/account/`
- Settings:
- `GET /api/v1/account/settings/` → returns account settings (ViewSet `retrieve`).
- `PATCH /api/v1/account/settings/` → partial update of account settings.
- Team:
- `GET /api/v1/account/team/` → list team members.
- `POST /api/v1/account/team/` → create/add a team member.
- `DELETE /api/v1/account/team/<id>/` → remove a team member.
- Usage analytics:
- `GET /api/v1/account/usage/analytics/` → returns usage analytics overview (implementation in `UsageAnalyticsViewSet.overview`).
- Permissions/tenancy: views expect authenticated users; account context from middleware; data scoped to `request.account`.
## Data Structures / Models Involved (no code)
- Account, User, and related analytics data as computed in account views.
## Execution Flow
- Requests hit `account_views` ViewSets; account context derived from session/JWT via middleware; view methods return unified responses.
## Cross-Module Interactions
- Usage analytics may summarize module usage (planner/writer/etc.) depending on `UsageAnalyticsViewSet` implementation.
## State Transitions
- Account settings updates; team membership changes.
## Error Handling
- Standard unified responses for validation/auth errors; 404 when deleting non-existent team members.
## Tenancy Rules
- All endpoints scoped to authenticated users account; no cross-tenant access.
## Billing Rules
- None directly; account limits and credits are exposed via billing endpoints.
## Background Tasks / Schedulers
- None.
## Key Design Considerations
- Non-router endpoints used for simplicity; still leverage DRF ViewSet actions.
## How Developers Should Work With This Module
- Keep settings/team/usage endpoints under `/api/v1/account/`; ensure account context is required for all operations.