# API Reference

## Accounting Integrations
`GET /settings/accounting` renders the accounting integration settings page for users with `view_accounting_integrations`.

## Calendar Integrations
`GET /settings/calendar` renders the two-way Google Calendar and Outlook calendar integration settings page for users with `view_calendar_integrations`.

## Import and LLM Settings
`GET /import-data` renders the selected import workflow for users with `import_csv`. Supported query parameter: `type=customers|jobs|quotes|invoices|team`.

`GET /settings/llm` renders the LLM API settings foundation for users with `view_llm_settings`.

## AI Assistant
`GET /ai-assistant` renders the operational assistant for users with `use_ai_assistant`.

`POST /ai-assistant/generate` returns local assistant guidance for users with `use_ai_assistant`. It requires `_csrf`, `mode=quote|schedule|general`, optional `job_title`, and optional `details`. The response is JSON and currently uses the deterministic local assistant only; no external LLM provider is called and no operational records are changed.

The current implementation is UI and contract foundation only. Live OAuth callbacks, provider webhooks, and sync worker endpoints are intentionally deferred until provider credentials, redirect URLs, encryption keys, HTTPS callback URLs, and sandbox tenants are confirmed.

All API responses use `{ "success": true, "data": {}, "meta": {} }` or `{ "success": false, "error": { "code": "...", "message": "...", "fields": {} } }`.

- POST `/api/auth/token`: issue token; auth no; permission none.
- POST `/api/auth/revoke`: revoke token; auth yes; permission access_api.
- GET/POST `/api/clients`, GET/PATCH/DELETE `/api/clients/{id}`: client CRUD; auth yes; permissions view/create/update/delete clients.
- GET/POST `/api/jobs`, GET/PATCH/DELETE `/api/jobs/{id}`: job CRUD; auth yes; job permissions.
- GET/POST `/api/quotes`, GET/PATCH/DELETE `/api/quotes/{id}`: quote CRUD; auth yes; quote permissions.
- GET/POST `/api/invoices`, GET/PATCH/DELETE `/api/invoices/{id}`: invoice CRUD; auth yes; invoice permissions.
- GET `/api/dashboard`: dashboard stats; auth yes; view_dashboard.
- GET `/api/reports/summary`: reports summary; auth yes; view_reports.
- GET `/api/team`: team list; auth yes; manage_team.
