Spaces:
Sleeping
Sleeping
File size: 22,679 Bytes
44ca2cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | # Project Manager Dashboard - API Reference
**Version:** 1.0
**Last Updated:** 2025-11-19
**Audience:** Frontend Development Team
---
## Overview
This document provides all API endpoints needed to build a comprehensive Project Manager (PM) dashboard. The PM role requires visibility across sales, operations, finance, and resources to orchestrate daily field service operations.
### PM Core Responsibilities
- Convert sales orders to work tickets
- Assign tickets to field agents
- Approve expenses and manage finances
- Track inventory and resources
- Generate payroll and invoices
- Monitor team performance
---
## Dashboard Layout Structure
### Recommended Sections
1. **Today's Overview** - Key metrics at a glance
2. **Financial Snapshot** - Cash position and pending payments
3. **Quick Actions** - Common PM tasks
4. **Pending Sales Orders** - Orders awaiting conversion
5. **Active Tickets** - Work in progress
6. **Pending Approvals** - Expenses, payroll, invoices
7. **Inventory Status** - Stock levels and alerts
8. **Map View** - Geographic visualization
9. **Team Status** - Agent availability
---
## API Endpoints by Feature
### 1. Dashboard Overview Statistics
#### Get Platform Dashboard Stats
```
GET /api/v1/analytics/platform-admin/dashboard
Authorization: Bearer {token}
```
**Response Fields:**
- `users` - User statistics (total, active, by role)
- `organizations` - Client and contractor counts
- `tickets` - Ticket counts by status and type
- `projects` - Project statistics
- `assignments` - Assignment statistics
- `recent_activity` - Latest 10 audit logs
- `system_health` - 30-day trends
**Use Case:** Main dashboard metrics widget
---
### 2. Sales Order Management
#### List Sales Orders
```
GET /api/v1/sales-orders
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- project_id (UUID, optional)
- status (string, optional) - "pending", "processed", "cancelled", "duplicate"
- project_region_id (UUID, optional)
- sales_agent_id (UUID, optional)
- from_date (date, optional)
- to_date (date, optional)
- pending_processing (boolean, optional) - Show only pending orders
- customer_phone (string, optional)
```
**Response:**
- `items[]` - Array of sales orders with computed properties
- `total` - Total count
- `skip`, `limit` - Pagination info
**Key Fields per Item:**
- `id`, `order_number`, `customer_name`, `customer_preferred_package`
- `package_price`, `installation_address_line1`, `installation_latitude`, `installation_longitude`
- `status`, `project_title`, `region_name`, `sales_agent_name`
- `is_pending`, `has_ticket`, `can_promote_to_ticket`
#### Get Sales Order Statistics
```
GET /api/v1/sales-orders/stats
Authorization: Bearer {token}
Query Parameters:
- project_id (UUID, optional)
- project_region_id (UUID, optional)
- sales_agent_id (UUID, optional)
```
**Response:** Metrics on orders by status, region, agent
#### Assign Sales Order to Region
```
POST /api/v1/sales-orders/{sales_order_id}/assign-region
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"project_region_id": "uuid"
}
```
#### Promote Sales Order to Ticket (Single)
```
POST /api/v1/sales-orders/{sales_order_id}/promote
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"priority": "normal",
"scheduled_date": "2025-01-20",
"scheduled_time_slot": "morning",
"work_description": "Install fiber",
"notes": "Customer prefers morning"
}
```
**Response:**
- `message`, `sales_order_id`, `ticket_id`, `ticket_name`, `status`
#### Bulk Promote Sales Orders to Tickets
```
POST /api/v1/sales-orders/bulk-promote
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"sales_order_ids": ["uuid1", "uuid2"],
"priority": "normal",
"notes": "Batch promotion"
}
```
**Response:**
- `total`, `successful`, `failed`, `errors[]`, `created_ticket_ids[]`
---
### 3. Ticket Management
#### List Tickets
```
GET /api/v1/tickets
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- project_id (UUID, optional)
- status (enum, optional) - "open", "assigned", "in_progress", "pending_review", "completed", "cancelled"
- ticket_type (enum, optional) - "installation", "support", "infrastructure"
- priority (enum, optional) - "low", "normal", "high", "urgent"
- project_region_id (UUID, optional)
- source (enum, optional) - "sales_order", "incident", "task"
- from_date (date, optional)
- to_date (date, optional)
- is_overdue (boolean, optional)
```
**Response:**
- `tickets[]` - Array of tickets
- `total`, `skip`, `limit`
**Key Fields per Ticket:**
- `id`, `ticket_name`, `status`, `priority`, `ticket_type`
- `work_description`, `scheduled_date`, `scheduled_time_slot`
- `project_title`, `region_name`, `customer_name`
- `is_overdue`, `can_be_assigned`
#### Get Ticket Statistics
```
GET /api/v1/tickets/stats
Authorization: Bearer {token}
Query Parameters:
- project_id (UUID, optional)
- project_region_id (UUID, optional)
```
**Response:**
- Counts by status, type, priority
- `overdue_tickets`, `avg_completion_time_hours`, `completion_rate`
#### Update Ticket
```
PUT /api/v1/tickets/{ticket_id}
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"priority": "urgent",
"work_description": "Updated description",
"notes": "Additional notes"
}
```
#### Reschedule Ticket
```
POST /api/v1/tickets/{ticket_id}/reschedule
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"scheduled_date": "2025-01-25",
"scheduled_time_slot": "afternoon",
"reason": "Customer requested later date"
}
```
#### Cancel Ticket
```
POST /api/v1/tickets/{ticket_id}/cancel
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"reason": "Customer cancelled service"
}
```
---
### 4. Ticket Assignment & Dispatch
#### List Ticket Assignments
```
GET /api/v1/ticket-assignments
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50)
- ticket_id (UUID, optional)
- user_id (UUID, optional)
- status (string, optional)
- project_id (UUID, optional)
- from_date (date, optional)
- to_date (date, optional)
```
#### Get Available Agents for Assignment
```
GET /api/v1/ticket-assignments/available-agents
Authorization: Bearer {token}
Query Parameters:
- ticket_id (UUID, required)
```
**Response:** List of agents available to be assigned to the ticket
#### Assign Ticket to Agent
```
POST /api/v1/ticket-assignments
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"ticket_id": "uuid",
"user_id": "uuid",
"notes": "Assigned to John"
}
```
#### Reassign Ticket
```
POST /api/v1/ticket-assignments/{assignment_id}/reassign
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"new_user_id": "uuid",
"reason": "Original agent unavailable"
}
```
---
### 5. Expense Management
#### List Expenses
```
GET /api/v1/expenses
Authorization: Bearer {token}
Query Parameters:
- page (int, default: 1)
- page_size (int, default: 50, max: 100)
- ticket_id (UUID, optional)
- assignment_id (UUID, optional)
- approval_status (string, optional) - "pending", "approved", "rejected"
- payment_status (string, optional) - "pending", "paid"
- from_date (date, optional)
- to_date (date, optional)
```
**Response:**
- `items[]` - Array of expenses
- `total`, `page`, `page_size`
**Key Fields per Expense:**
- `id`, `expense_type`, `amount`, `currency`
- `description`, `receipt_url`
- `approval_status`, `payment_status`
- `submitted_by_name`, `approved_by_name`
#### Get Expense Statistics
```
GET /api/v1/expenses/stats
Authorization: Bearer {token}
Query Parameters:
- ticket_id (UUID, optional)
- assignment_id (UUID, optional)
```
**Response:** Total expenses, pending approvals, payment status breakdown
#### Approve/Reject Expense
```
POST /api/v1/expenses/{expense_id}/approve
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"approved": true,
"notes": "Approved - receipt verified"
}
```
#### Mark Expense as Paid
```
POST /api/v1/expenses/{expense_id}/mark-paid
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"payment_date": "2025-01-20",
"payment_method": "mobile_money",
"payment_reference": "TXN123456",
"notes": "Paid via M-Pesa"
}
```
---
### 6. Financial Management
#### List Financial Transactions
```
GET /api/v1/finance
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- project_id (UUID, optional)
- transaction_type (string, optional) - "inflow", "outflow"
- status (string, optional) - "pending", "approved", "paid", "rejected", "cancelled"
- category (string, optional)
- from_date (date, optional)
- to_date (date, optional)
- pending_approval (boolean, optional)
```
#### Get Cash Flow Summary
```
GET /api/v1/finance/cash-flow/{project_id}
Authorization: Bearer {token}
Query Parameters:
- from_date (date, optional)
- to_date (date, optional)
```
**Response:**
- Total inflows, outflows, net cash flow
- Breakdown by category
- Pending transactions
#### Create Financial Transaction
```
POST /api/v1/finance
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"project_id": "uuid",
"transaction_type": "outflow",
"amount": 50000,
"currency": "KES",
"category": "equipment_purchase",
"description": "Purchased 50 ONTs",
"transaction_date": "2025-01-20"
}
```
#### Approve Transaction
```
POST /api/v1/finance/{transaction_id}/approve
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"notes": "Approved by PM"
}
```
---
### 7. Contractor Invoice Management
#### List Contractor Invoices
```
GET /api/v1/invoices
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 100, max: 500)
- contractor_id (UUID, optional)
- client_id (UUID, optional)
- project_id (UUID, optional)
- status (string, optional) - "draft", "sent", "partially_paid", "paid", "cancelled"
- overdue_only (boolean, optional)
- unpaid_only (boolean, optional)
- latest_versions_only (boolean, default: true)
```
**Response:**
- `invoices[]` - Array of invoices
- `total`, `skip`, `limit`
**Key Fields per Invoice:**
- `id`, `invoice_number`, `contractor_name`, `client_name`
- `subtotal_amount`, `tax_amount`, `total_amount`
- `amount_paid`, `amount_due`
- `status`, `due_date`, `is_overdue`
#### Create Contractor Invoice
```
POST /api/v1/invoices
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"contractor_id": "uuid",
"client_id": "uuid",
"project_id": "uuid",
"invoice_date": "2025-01-20",
"due_date": "2025-02-20",
"currency": "KES",
"tax_rate": 16.0,
"notes": "Monthly invoice"
}
```
**Response:** Created invoice with auto-generated invoice number
#### Add Line Item to Invoice
```
POST /api/v1/invoices/{invoice_id}/line-items
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"line_item_type": "ticket",
"ticket_id": "uuid",
"description": "Installation service",
"quantity": 1,
"unit_price": 5000,
"amount": 5000
}
```
**Note:** Creates new invoice version
#### Record Payment
```
POST /api/v1/invoices/{invoice_id}/payments
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"amount": 50000,
"payment_date": "2025-01-20",
"payment_method": "bank_transfer",
"payment_reference": "TXN123456",
"notes": "Partial payment"
}
```
**Response:** Updated invoice with new payment recorded
---
### 8. Inventory Management
#### List Main Office Inventory
```
GET /api/v1/inventory
Authorization: Bearer {token}
Query Parameters:
- page (int, default: 1)
- page_size (int, default: 50, max: 100)
- project_id (UUID, optional)
- item_type (string, optional) - "tool", "equipment", "consumable", "ppe"
- status (string, optional)
- is_active (boolean, optional)
- search (string, optional)
```
**Response:**
- `items[]` - Inventory batches
- `total`, `page`, `page_size`
**Key Fields per Item:**
- `id`, `equipment_type`, `equipment_name`, `item_type`
- `quantity_received`, `quantity_available`, `quantity_distributed`
- `status`, `received_date`
#### Create Inventory Batch
```
POST /api/v1/inventory
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"project_id": "uuid",
"equipment_type": "ONT",
"equipment_name": "Huawei HG8145V5",
"item_type": "equipment",
"quantity_received": 100,
"received_date": "2025-01-20",
"supplier_name": "TechSupply Ltd",
"unit_cost": 2500,
"currency": "KES"
}
```
#### List Regional Distributions
```
GET /api/v1/inventory/distributions
Authorization: Bearer {token}
Query Parameters:
- page (int, default: 1)
- page_size (int, default: 50)
- project_id (UUID, optional)
- region_id (UUID, optional)
- inventory_id (UUID, optional)
- item_type (string, optional)
- is_active (boolean, optional)
```
**Response:** Inventory distributed to regional hubs
#### Distribute Inventory to Regional Hub
```
POST /api/v1/inventory/distributions
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"inventory_id": "uuid",
"project_region_id": "uuid",
"quantity_distributed": 20,
"distributed_date": "2025-01-20",
"notes": "Distribution to Nairobi hub"
}
```
#### List Inventory Assignments (Issued to Agents)
```
GET /api/v1/inventory/assignments
Authorization: Bearer {token}
Query Parameters:
- page (int, default: 1)
- page_size (int, default: 50)
- user_id (UUID, optional)
- region_id (UUID, optional)
- status (string, optional)
- is_returned (boolean, optional)
- ticket_id (UUID, optional)
```
**Response:** Equipment issued to field agents
---
### 9. Payroll Management
#### List Payroll Records
```
GET /api/v1/payroll
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- user_id (UUID, optional)
- project_id (UUID, optional)
- period_start (date, optional)
- period_end (date, optional)
- status (string, optional)
```
**Response:**
- `items[]` - Payroll records
- `total`, `skip`, `limit`
**Key Fields per Record:**
- `id`, `user_name`, `period_start`, `period_end`
- `total_earnings`, `deductions`, `net_pay`
- `status`, `payment_status`
#### Generate Payroll
```
POST /api/v1/payroll/generate
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"project_id": "uuid",
"period_start": "2025-01-01",
"period_end": "2025-01-31",
"user_ids": ["uuid1", "uuid2"]
}
```
**Response:** Generated payroll records
#### Approve Payroll
```
POST /api/v1/payroll/{payroll_id}/approve
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"notes": "Approved for payment"
}
```
---
### 10. Timesheet Management
#### List Timesheets
```
GET /api/v1/timesheets
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- user_id (UUID, optional)
- project_id (UUID, optional)
- from_date (date, optional)
- to_date (date, optional)
- status (string, optional) - "present", "absent", "on_leave", "sick_leave", "half_day"
```
#### Get Timesheet Statistics
```
GET /api/v1/timesheets/stats
Authorization: Bearer {token}
Query Parameters:
- user_id (UUID, optional)
- project_id (UUID, optional)
- from_date (date, optional)
- to_date (date, optional)
```
**Response:** Attendance metrics, days worked, absences
---
### 11. User Management
#### List Users
```
GET /api/v1/users
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- role (string, optional)
- client_id (UUID, optional)
- contractor_id (UUID, optional)
- is_active (boolean, optional)
- status (string, optional)
- search (string, optional)
```
**Response:**
- `users[]` - Array of users
- `total`, `skip`, `limit`
#### Search Users
```
GET /api/v1/users/search
Authorization: Bearer {token}
Query Parameters:
- q (string, required) - Search query
- role (string, optional)
- limit (int, default: 20)
```
**Response:** Matching users (useful for assignment dropdowns)
#### Invite New User
```
POST /api/v1/invitations
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"email": "john@example.com",
"name": "John Doe",
"phone": "+254712345678",
"role": "field_agent",
"contractor_id": "uuid"
}
```
---
### 12. Map & Location Services
#### Get Map Entities
```
GET /api/v1/map/entities
Authorization: Bearer {token}
Query Parameters:
- project_id (UUID, required)
- entity_types (array, optional) - ["customers", "tickets", "sales_orders", "agents", "regions"]
- status (string, optional)
```
**Response:**
- `customers[]` - Customer locations
- `tickets[]` - Ticket locations
- `sales_orders[]` - Sales order locations
- `agents[]` - Agent current locations
- `regions[]` - Regional hub locations
**Use Case:** Render all entities on map view
#### Get Regional Hub Locations
```
GET /api/v1/map/regions/{project_id}
Authorization: Bearer {token}
Query Parameters:
- include_inactive (boolean, default: false)
```
**Response:** Regional hubs with coordinates, coverage radius, active tickets/agents count
#### Get Journey Details
```
GET /api/v1/map/journey/{assignment_id}
Authorization: Bearer {token}
```
**Response:**
- Timeline (start, arrival, completion times)
- GPS breadcrumb trail (array of coordinates with timestamps)
- Journey statistics (distance, duration, speed)
- Location information
**Use Case:** Track agent movement during work assignment
#### Find Nearest Regional Hub
```
GET /api/v1/map/nearest-region
Authorization: Bearer {token}
Query Parameters:
- project_id (UUID, required)
- latitude (float, required)
- longitude (float, required)
- max_distance_km (float, optional)
```
**Response:** Nearest regional hub with distance
---
### 13. Task Management
#### List Tasks
```
GET /api/v1/tasks
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- project_id (UUID, optional)
- status (string, optional) - "pending", "assigned", "in_progress", "completed", "cancelled", "blocked"
- assigned_to (UUID, optional)
- priority (string, optional)
- from_date (date, optional)
- to_date (date, optional)
```
#### Create Task
```
POST /api/v1/tasks
Authorization: Bearer {token}
Content-Type: application/json
Body:
{
"project_id": "uuid",
"task_type": "installation",
"title": "Install fiber cable",
"description": "Install cable from pole A to B",
"priority": "high",
"due_date": "2025-01-25",
"assigned_to": "uuid"
}
```
---
### 14. Customer Management
#### List Customers
```
GET /api/v1/customers
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50, max: 100)
- client_id (UUID, optional)
- search (string, optional)
- phone (string, optional)
```
#### Get Customer Details
```
GET /api/v1/customers/{customer_id}
Authorization: Bearer {token}
```
**Response:** Customer profile with all related data (subscriptions, tickets, sales orders)
---
### 15. Notifications
#### List Notifications
```
GET /api/v1/notifications
Authorization: Bearer {token}
Query Parameters:
- skip (int, default: 0)
- limit (int, default: 50)
- is_read (boolean, optional)
- type (string, optional)
```
#### Get Unread Count
```
GET /api/v1/notifications/unread-count
Authorization: Bearer {token}
```
**Response:** `{ "count": 5 }`
#### Mark Notification as Read
```
PUT /api/v1/notifications/{notification_id}/read
Authorization: Bearer {token}
```
---
## Authentication
All endpoints require Bearer token authentication:
```
Authorization: Bearer {access_token}
```
**Token Refresh:**
```
POST /api/v1/auth/refresh
Content-Type: application/json
Body:
{
"refresh_token": "your_refresh_token"
}
```
**Response:**
```json
{
"access_token": "new_access_token",
"refresh_token": "new_refresh_token",
"token_type": "bearer",
"expires_in": 3600
}
```
---
## Error Handling
All endpoints follow standard HTTP status codes:
- `200 OK` - Success
- `201 Created` - Resource created
- `204 No Content` - Success with no response body
- `400 Bad Request` - Invalid input
- `401 Unauthorized` - Missing or invalid token
- `403 Forbidden` - Insufficient permissions
- `404 Not Found` - Resource not found
- `409 Conflict` - Duplicate or conflicting resource
- `422 Unprocessable Entity` - Validation error
- `500 Internal Server Error` - Server error
**Error Response Format:**
```json
{
"detail": "Error message here"
}
```
---
## Pagination
List endpoints use offset-based pagination:
**Request:**
- `skip` - Number of items to skip (default: 0)
- `limit` - Number of items to return (default: 50, max varies by endpoint)
**Response:**
- `items[]` or `users[]` or similar - Array of results
- `total` - Total count of items
- `skip` - Current offset
- `limit` - Current limit
---
## Date/Time Formats
- **Dates:** ISO 8601 format `YYYY-MM-DD` (e.g., `2025-01-20`)
- **DateTimes:** ISO 8601 with timezone `YYYY-MM-DDTHH:MM:SSZ` (e.g., `2025-01-20T14:30:00Z`)
- **Time Slots:** `"morning"`, `"afternoon"`, `"evening"`, `"any"`
---
## Filtering Best Practices
1. **Combine filters** - Most list endpoints support multiple filters simultaneously
2. **Use pagination** - Always paginate large result sets
3. **Cache where appropriate** - Dashboard stats can be cached for 1-5 minutes
4. **Real-time updates** - Use polling or WebSockets for live data (tickets, assignments)
---
## Common UI Patterns
### Dashboard Widgets
- Fetch stats on page load
- Refresh every 30-60 seconds for live data
- Show loading skeletons during fetch
### List Views
- Implement infinite scroll or traditional pagination
- Add filters in sidebar or top bar
- Show total count and current range
### Map Views
- Lazy load entities based on viewport
- Cluster markers when zoomed out
- Show details on marker click
### Approval Workflows
- Show pending count badge
- Provide bulk approve/reject actions
- Confirm destructive actions (reject, cancel)
---
## Performance Recommendations
1. **Lazy load** - Don't fetch all data at once
2. **Debounce searches** - Wait 300ms before searching
3. **Cache reference data** - Roles, statuses, regions rarely change
4. **Optimize map rendering** - Use clustering for large datasets
5. **Batch operations** - Use bulk endpoints when available
---
## Support & Questions
For API questions or issues:
- Backend Team Lead: [Contact Info]
- API Documentation: `/api/v1/docs` (Swagger UI)
- Base URL: `https://api.swiftops.example.com`
---
**End of Document**
|