# Support Desk API (UI Endpoints)

This page lists the API endpoints used by the Support Desk UI (`ticket-admin.blade.php`).
All requests are authenticated with a Bearer token.

## Authentication
- `GET /admin/api/tokens/current`
  - Returns a short-lived Bearer token for subsequent API calls.

## Dashboard KPIs and Charts
- `GET /admin/api/support/dashboard-detail`
  - Query params used by UI: `from_date`, `to_date`, `category`, `status`
  - Returns KPI counts and chart data for status distribution, category breakdown, and volume trend.

## Ticket Listing (DataTables)
- `GET /admin/api/support/tickets/get-listing`
  - Query params used by UI:
    - `from_date`, `to_date`
    - `status` (tab filter: `unresolved`, `resolved`, `escalated`, `refunds`, etc.)
    - `category`
    - `search`
    - DataTables params: `draw`, `start`, `length`, `order`, `columns`
  - Returns paginated rows for the tickets table.

## Ticket Actions
- `POST /admin/api/support/tickets/create`
  - Body params used by UI: `sms_cust_id`, `subject`, `description`, `category`, `priority`, `assigned_to`
  - Creates a new ticket.

- `POST /admin/api/support/tickets/{ticketId}/update`
  - Body params used by UI: `status`, `priority`, `assigned_to`, `resolution_note`
  - Updates ticket status/metadata.

- `POST /admin/api/support/tickets/{ticketId}/escalate`
  - Escalates the ticket (sets status to `ESCALATED`).

## Ticket Details (Conversation/History/Attachments)
- `GET /admin/api/support/tickets/{ticketId}/details`
  - Returns `ticket`, `messages`, `history`, and `attachments` arrays.

- `POST /admin/api/support/tickets/{ticketId}/messages`
  - Body params used by UI: `message`
  - Adds a message from the authenticated admin user.

## Attachments
- `POST /admin/api/support/tickets/{ticketId}/attachments`
  - FormData: `file`
  - Uploads a file and stores a row in `ticket_attachments`.

## Support Metadata
- `GET /admin/api/support/categories`
  - Returns the category list used by the Category dropdown.

- `GET /admin/api/support/customers/search?q={query}`
  - Returns matching customers for the Create Ticket modal search box.

## Notes
- Status values are enums: `OPEN`, `IN_PROGRESS`, `RESOLVED`, `CLOSED`, `ESCALATED`.
- Category values are enums: `BILLING`, `TECHNICAL`, `ACCOUNT`, `PRODUCT`, `REFUND`, `COUPON`, `VOUCHER`, `OTHER`.
