API & Views
ChargeSol exposes a RESTful API built with Django REST Framework. All endpoints follow consistent conventions.
API Conventions
Base URL
All endpoints are prefixed with /api/v1/.
Authentication
JWT-based authentication using SimpleJWT:
POST /api/v1/auth/login/— obtain access + refresh tokensPOST /api/v1/auth/refresh/— refresh access tokenInclude token in header:
Authorization: Bearer <access_token>Access token TTL: 15 minutes
Refresh token TTL: 7 days
Pagination
Cursor-based pagination for list endpoints:
Default page size: 20
Max page size: 100
Response includes
nextandpreviouscursor URLs
Response Envelope
All responses follow a standard envelope:
{
"status": "success",
"data": { },
"message": "Operation completed"
}
Error responses:
{
"status": "error",
"data": null,
"message": "Validation failed",
"errors": {
"field_name": ["Error description"]
}
}
HTTP Status Codes
Code |
Usage |
|---|---|
200 |
Successful GET, PATCH, PUT |
201 |
Successful POST (resource created) |
204 |
Successful DELETE |
400 |
Validation error |
401 |
Authentication required |
403 |
Permission denied (role-based) |
404 |
Resource not found |
409 |
Conflict (e.g., invalid status transition) |
429 |
Rate limit exceeded |
Filtering & Search
Filter by field:
?status=new&city=MumbaiDate range:
?created_after=2026-01-01&created_before=2026-03-31Search:
?search=customer+nameOrdering:
?ordering=-created_at