API Versioning Strategy
API versioning is crucial for maintaining backward compatibility while allowing your API to evolve. This guide covers versioning strategies and best practices for ServITech Backend API.Current Implementation
ServITech Backend currently implements a single version API without explicit version prefixes. All endpoints are accessible at:The current implementation assumes all clients are using the latest version. This works well for early-stage projects but should evolve as the API matures.
Why Version Your API?
API versioning allows you to:- Maintain backward compatibility while introducing breaking changes
- Support multiple client versions (mobile apps that users haven’t updated)
- Deprecate features gradually without breaking existing integrations
- Test new features in parallel with stable versions
Versioning Strategies
1. URL Path Versioning (Recommended)
Include the version number in the URL path:- Clear and explicit
- Easy to test with tools like Postman
- Cache-friendly
- Easy to route in Laravel
routes/api.php
2. Header Versioning
Specify version in custom header:- Clean URLs
- More “RESTful”
- Less visible
- Harder to test
- Requires custom middleware
3. Accept Header Versioning
Use the Accept header with custom media types:- Follows REST principles
- Fine-grained content negotiation
- More complex to implement
- Less intuitive for developers
4. Query Parameter Versioning
Include version as a query parameter:- Simple to implement
- Mixes versioning with query parameters
- Can interfere with caching
- Not recommended for production APIs
Recommendation: URL Path Versioning is the most common and developer-friendly approach for REST APIs.
Migration Plan for ServITech
Version Management Best Practices
Semantic Versioning
Follow semantic versioning principles:- v1.x.x → Major version (breaking changes)
- v1.2.x → Minor version (new features, backward compatible)
- v1.2.3 → Patch version (bug fixes)
When to Create a New Version
Create a new major version when making breaking changes:- Removing or renaming endpoints
- Changing request/response structure
- Removing required fields
- Changing authentication mechanism
- Modifying error response format
Non-Breaking Changes
These can be added without a new version:- Adding new endpoints
- Adding optional parameters
- Adding new fields to responses
- Adding new error codes
- Improving performance
Version-Specific Controllers
For significantly different logic between versions:routes/api.php
Deprecation Strategy
Announce Deprecation
Communicate deprecation plans well in advance:
- Add deprecation warnings to API responses
- Update documentation
- Notify integration partners
- Send in-app notifications
Current Endpoints Overview
ServITech currently has the following endpoint groups:Public Endpoints
POST /api/auth/login— User loginPOST /api/auth/register— User registrationPOST /api/auth/reset-password— Password reset requestPUT /api/auth/reset-password— Password reset confirmationGET /api/articles— List articlesGET /api/articles/{category}— Get article by categoryGET /api/subcategories— List subcategories
Protected Endpoints (JWT Required)
POST /api/auth/logout— User logoutGET /api/user/profile— Get user profilePUT /api/user/profile— Update user profilePUT /api/user/password— Change passwordGET/POST/PUT/DELETE /api/support-request/*— Support requests
Admin-Only Endpoints (Role Required)
GET/POST/PUT/DELETE /api/category/*— Category managementPOST/PUT/DELETE /api/articles/*— Article managementPOST/PUT/DELETE /api/subcategories/*— Subcategory managementGET/POST/PUT/DELETE /api/repair-request/*— Repair request management
All endpoints support localization through the
Accept-Language header (es/en).Next Steps
- Review Security Best Practices
- Learn about Gitflow Workflow
- Explore the API Reference