Skip to content

API Versioning

Current Version

The CPR API is at v1. All endpoints are prefixed with /api/v1/.

GET /api/v1/patients
POST /api/v1/auth/login

Versioning Strategy

The API uses URI-based versioning — the version is included in the URL path.

Route Organization

API v1 routes are organized in modular files under routes/api/v1/:

routes/
├── api.php                    # Main entry point
└── api/
    ├── v1.php                 # V1 route registration
    └── v1/
        ├── patients.php       # Patient routes
        ├── patient_visits.php # Visit routes
        ├── queue.php          # Queue routes
        ├── branches.php       # Branch routes (admin)
        ├── medicines.php      # Medicine routes
        └── ... (43 route files)

Each route file is responsible for a single resource module and is included in v1.php under the appropriate middleware group (branch-scoped, global, or admin).

Adding New Endpoints

New endpoints should be added to the v1 routes. Non-breaking additions don't require a version bump:

  • Adding new endpoints
  • Adding optional query parameters
  • Adding new fields to responses
  • Adding new enum values

Breaking Changes

If breaking changes are needed in the future:

  1. Create routes/api/v2/ directory
  2. Create new controllers in app/Http/Controllers/Api/V2/
  3. Keep v1 endpoints functional during transition
  4. Document migration path for API consumers

CPR - Clinical Patient Records