API Reference
StudioSync provides a comprehensive RESTful API powered by Django REST Framework. This document outlines the available endpoints, authentication, and usage examples.
Base URL
Authentication
JWT Token Authentication
StudioSync uses JSON Web Tokens (JWT) for API authentication.
Obtaining Tokens
Endpoint: POST /api/auth/login/
Request:
{
"email": "[email protected]",
"password": "secure_password"
}
Response:
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"user": {
"id": "uuid-here",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"role": "teacher"
}
}
Using Tokens
Include the access token in the Authorization header:
Refreshing Tokens
Endpoint: POST /api/auth/refresh/
Request:
Response:
Logout
Endpoint: POST /api/auth/logout/
Invalidates the refresh token.
Core Endpoints
User Management
Get Current User Profile
Response:
{
"id": "uuid",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"role": "teacher",
"phone_number": "+1234567890",
"avatar": "url-to-avatar",
"created_at": "2025-01-01T00:00:00Z"
}
Update User Profile
Request:
Change Password
Request:
Studio Management
List Studios
Returns studios the current user has access to.
Get Current Studio
Returns the active studio for the current user.
Update Studio Settings
Request:
{
"name": "Updated Studio Name",
"settings": {
"timezone": "America/New_York",
"currency": "USD"
}
}
Teachers
List Teachers
Query Parameters:
is_accepting_students: Filter by availabilityspecialty: Filter by instrument/specialty
Get Teacher Details
Response:
{
"id": "uuid",
"user": {
"id": "uuid",
"email": "[email protected]",
"first_name": "John",
"last_name": "Smith"
},
"bio": "Experienced piano teacher...",
"specialties": ["piano", "theory"],
"hourly_rate": "50.00",
"is_accepting_students": true
}
Create Teacher Profile
Students
List Students
Query Parameters:
family: Filter by family IDteacher: Filter by primary teacheris_active: Filter by active status
Get Student Details
Create Student
Request:
{
"user": {
"email": "[email protected]",
"first_name": "Sarah",
"last_name": "Johnson",
"password": "secure_password"
},
"instrument": "violin",
"specialties": ["violin"],
"date_of_birth": "2010-05-15",
"emergency_contact_name": "Parent Name",
"emergency_contact_phone": "+1234567890"
}
Update Student
Delete Student
Families
List Families
Create Family
Request:
{
"name": "Johnson Family",
"primary_contact": "user-uuid",
"phone_number": "+1234567890",
"billing_email": "[email protected]",
"address": "123 Main St, City, State 12345"
}
Lessons Endpoints
Lessons
List Lessons
Query Parameters:
teacher: Filter by teacher IDstudent: Filter by student IDstatus: Filter by lesson statusstart_date: Filter lessons after dateend_date: Filter lessons before date
Response:
{
"count": 100,
"next": "url-to-next-page",
"previous": null,
"results": [
{
"id": "uuid",
"teacher": {...},
"student": {...},
"scheduled_start": "2025-01-15T14:00:00Z",
"scheduled_end": "2025-01-15T15:00:00Z",
"location": "Room 101",
"lesson_type": "private",
"status": "scheduled"
}
]
}
Create Lesson
Request:
{
"teacher": "teacher-uuid",
"student": "student-uuid",
"scheduled_start": "2025-01-20T14:00:00Z",
"scheduled_end": "2025-01-20T15:00:00Z",
"location": "Room 101",
"lesson_type": "private"
}
Update Lesson
Cancel Lesson
Request:
Get Calendar View
Query Parameters:
start: Calendar start date (ISO format)end: Calendar end date (ISO format)teacher: Filter by teacherstudent: Filter by student
Returns lessons formatted for calendar display.
Lesson Notes
List Lesson Notes
Create Lesson Note
Request:
{
"summary": "Great progress on scales today",
"topics_covered": ["C Major scale", "Music theory basics"],
"assignments": ["Practice scale 10 min daily", "Read chapter 3"],
"strengths": ["Good rhythm", "Improving technique"],
"challenges": ["Hand position needs work"],
"visible_to_student": true,
"visible_to_parent": true
}
Student Goals
List Student Goals
Query Parameters:
student: Filter by student IDstatus: Filter by status (active, achieved, abandoned)
Create Goal
Request:
{
"student": "student-uuid",
"title": "Learn Für Elise",
"description": "Master the complete piece",
"target_date": "2025-06-01",
"progress_percentage": 0
}
Update Goal Progress
Request:
Recurring Patterns
List Recurring Patterns
Create Recurring Pattern
Request:
{
"teacher": "teacher-uuid",
"student": "student-uuid",
"frequency": "weekly",
"day_of_week": "tuesday",
"time": "14:00:00",
"duration_minutes": 60,
"start_date": "2025-01-15",
"end_date": "2025-06-01"
}
Lesson Plans
List Lesson Plans
Query Parameters:
specialty: Filter by instrumentis_public: Show only public plans
Create Lesson Plan
Billing Endpoints
Invoices
List Invoices
Query Parameters:
status: Filter by invoice statusband: Filter by band/familystart_date,end_date: Filter by date range
Get Invoice Details
Response:
{
"id": "uuid",
"invoice_number": "INV-2025-001",
"band": {...},
"status": "sent",
"issue_date": "2025-01-01",
"due_date": "2025-01-15",
"subtotal": "200.00",
"tax": "16.00",
"total": "216.00",
"amount_paid": "0.00",
"balance_due": "216.00",
"line_items": [
{
"description": "Piano Lesson - 60 min",
"quantity": 4,
"unit_price": "50.00",
"total_price": "200.00"
}
]
}
Create Invoice
Request:
{
"band": "band-uuid",
"issue_date": "2025-01-01",
"due_date": "2025-01-15",
"line_items": [
{
"description": "Piano Lessons",
"quantity": 4,
"unit_price": "50.00"
}
]
}
Send Invoice
Sends invoice email to the customer.
Payments
List Payments
Record Payment
Request:
{
"invoice": "invoice-uuid",
"amount": "216.00",
"payment_method": "credit_card",
"transaction_id": "txn_123456",
"notes": "Paid via Stripe"
}
Inventory Endpoints
Inventory Items
List Inventory
Query Parameters:
category: Filter by categorystatus: Filter by statusis_borrowable: Filter borrowable items
Get Item Details
Create Inventory Item
Request:
{
"name": "Yamaha Acoustic Guitar",
"category": "instrument",
"quantity": 3,
"available_quantity": 3,
"condition": "excellent",
"location": "Room 5 - Cabinet A",
"value": "500.00",
"is_borrowable": true,
"max_checkout_days": 7
}
Checkouts
List Checkouts
Query Parameters:
status: Filter by checkout statusstudent: Filter by studentitem: Filter by inventory item
Request Checkout
Request:
Approve Checkout
Mark as Returned
Request:
Practice Rooms
List Practice Rooms
Create Room Reservation
Request:
{
"room": "room-uuid",
"start_time": "2025-01-20T14:00:00Z",
"end_time": "2025-01-20T16:00:00Z",
"notes": "Need practice for recital"
}
Resources Endpoints
Resources
List Resources
Query Parameters:
resource_type: Filter by type (pdf, audio, video, etc.)category: Filter by categorytags: Filter by tags (comma-separated)search: Search in title and description
Get Resource Details
Upload Resource
Request: (multipart/form-data)
file: <file upload>
title: "Bach Prelude in C - Sheet Music"
description: "Piano piece"
category: "Sheet Music"
tags: ["piano", "bach", "classical"]
is_public: true
Download Resource
Returns a redirect to the file URL or serves the file directly.
Share Resource
Request:
Resource Checkouts
Request Physical Resource
Return Physical Resource
Messaging Endpoints
Message Threads
List Threads
Returns conversation threads for the current user.
Create Thread
Request:
{
"subject": "Question about lesson schedule",
"participants": ["user-uuid-1", "user-uuid-2"],
"initial_message": "Hi, I have a question about..."
}
Get Thread Messages
Messages
Send Message
Request:
Mark as Read
Notifications Endpoints
Notifications
List Notifications
Query Parameters:
is_read: Filter by read status
Response:
{
"count": 15,
"unread_count": 5,
"results": [
{
"id": "uuid",
"title": "Lesson Reminder",
"message": "Your lesson is tomorrow at 2:00 PM",
"notification_type": "lesson_reminder",
"is_read": false,
"link": "/lessons/uuid",
"created_at": "2025-01-14T10:00:00Z"
}
]
}
Mark Notification as Read
Mark All as Read
Error Responses
The API uses standard HTTP status codes:
200 OK: Successful request201 Created: Resource created successfully204 No Content: Successful request with no response body400 Bad Request: Invalid request data401 Unauthorized: Authentication required403 Forbidden: Insufficient permissions404 Not Found: Resource not found500 Internal Server Error: Server error
Error Response Format:
{
"detail": "Error message here",
"field_errors": {
"email": ["This field is required"],
"password": ["Password must be at least 8 characters"]
}
}
Pagination
List endpoints support pagination:
Query Parameters:
page: Page number (default: 1)page_size: Results per page (default: 20, max: 100)
Response Format:
{
"count": 150,
"next": "http://api.example.com/resource/?page=2",
"previous": null,
"results": [...]
}
Filtering & Search
Most list endpoints support filtering:
Common Query Parameters:
search: Full-text searchordering: Sort field (prefix with-for descending)created_after,created_before: Date range filters
Example:
Rate Limiting
API requests are rate-limited:
- Authenticated users: 1000 requests/hour
- Unauthenticated: 100 requests/hour
Rate limit headers included in responses:
Interactive Documentation
Full interactive API documentation is available at:
- Swagger UI:
/api/docs/ - ReDoc:
/api/redoc/
These provide:
- Complete endpoint listings
- Request/response schemas
- Interactive testing
- Authentication setup
WebSocket API
Real-time features use WebSocket connections:
Connect
Authentication
Include JWT token in connection:
Message Format
Incoming:
{
"type": "notification",
"data": {
"id": "uuid",
"title": "New Message",
"message": "You have a new message from John Doe"
}
}
SDKs & Libraries
Official client libraries:
- JavaScript/TypeScript:
@studiosync/js-sdk - Python:
studiosync-python - React Hooks:
@studiosync/react-hooks
Example (JavaScript):
import StudioSync from "@studiosync/js-sdk";
const client = new StudioSync({
apiUrl: "http://localhost:8000/api",
token: "your-jwt-token",
});
const lessons = await client.lessons.list({
student: "student-uuid",
status: "scheduled",
});
Related Documentation
- Database Schema - Data models
- Authentication - Security and privacy