Complete API documentation
Last Updated: December 4, 2025
Get the API running in 2 simple steps:
# 1. Start the server php -S localhost:8000 -t public # 2. Test the API php test_api.php # Or visit in browser http://localhost:8000/api/health
Base URL: http://localhost:8000/api
Secure token-based authentication with bcrypt password hashing
Super admin and party admin permissions
Automatic party answers, codes, and admin accounts
Calculate party positions on 2D compass
Find top 3 party matches for users
Profile pictures and party logos with auto-cleanup
Transaction-based bulk updates
Comprehensive analytics and reporting
Track unanswered questions with empty string state
Authenticate user with username or email and receive token
{
"username": "testuser",
"password": "password123"
}
{
"email_address": "test@example.com",
"password": "password123"
}
{
"status": "success",
"message": "Login successful",
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"user": {
"user_id": 1,
"username": "testuser",
"role": "user"
}
}
}
{
"status": "error",
"message": "Invalid credentials",
"timestamp": "2024-12-04T12:00:00+00:00",
"status_code": 401
}
Register new user account
{
"username": "newuser",
"password": "securepassword123",
"email_address": "newuser@example.com"
}
{
"status": "success",
"message": "user account created successfully",
"data": {
"user_id": 2,
"username": "newuser",
"email_address": "newuser@example.com",
"role": "user",
"profile_url": null,
"date_created": "2025-12-03 11:30:00"
}
}
{
"status": "error",
"message": "Username already exists"
}
Invalidate authentication token
Authorization: Bearer {your_token}
{
"status": "success",
"message": "Logged out successfully",
"data": null
}
{
"status": "error",
"message": "Token not provided"
}
Validate current token and get user info
Authorization: Bearer {your_token}
{
"status": "success",
"message": "Token is valid",
"data": {
"user_id": 1,
"role": "user",
"expires_at": "2025-12-04 10:00:00"
}
}
{
"status": "error",
"message": "Invalid or expired token"
}
List all users with filtering and pagination
role: Filter by role (user|admin) search: Search by username limit: Results per page (default: 50) offset: Results to skip (default: 0)
{
"status": "success",
"message": "Users retrieved successfully",
"data": {
"users": [
{
"user_id": 1,
"role": "user",
"username": "john",
"email_address": "john@example.com",
"profile_url": "http://...",
"patient_number": null,
"date_created": "2024-01-01 12:00:00"
}
],
"total": 100,
"limit": 50,
"offset": 0
}
}
Get a single user by ID (own profile or admin)
{
"status": "success",
"message": "User retrieved successfully",
"data": {
"user_id": 1,
"role": "user",
"username": "john",
"email_address": "john@example.com",
"profile_url": "http://...",
"patient_number": null,
"date_created": "2024-01-01 12:00:00"
}
}
{
"status": "error",
"message": "User not found",
"timestamp": "2024-12-04T12:00:00+00:00",
"status_code": 404
}
Create a new user
{
"role": "user",
"username": "john",
"email_address": "john@example.com",
"password": "password123",
"profile_url": null,
"patient_number": null
}
{
"status": "success",
"message": "User created successfully",
"data": {
"message": "User created",
"user_id": 1
}
}
{
"status": "error",
"message": "Validation failed",
"timestamp": "2024-12-04T12:00:00+00:00",
"status_code": 422,
"errors": {
"username": "Username is required",
"email_address": "Invalid email address format",
"password": "Password must be at least 6 characters"
}
}
Update user (full replacement)
{
"role": "admin",
"username": "updated",
"email_address": "updated@example.com",
"profile_url": "http://...",
"patient_number": 88
}
{
"status": "success",
"message": "User updated successfully",
"data": {
"message": "User updated"
}
}
Update user (partial update - own profile or admin)
{
"profile_url": "https://newimage.com/me.png"
}
role, username, email_address, profile_url, patient_number
{
"status": "success",
"message": "User updated successfully",
"data": {
"message": "User updated"
}
}
Change user password (own password or admin)
{
"old_password": "old123",
"new_password": "new123"
}
{
"status": "success",
"message": "Password updated successfully",
"data": {
"message": "Password updated"
}
}
{
"status": "error",
"message": "Old password is incorrect",
"timestamp": "2024-12-04T12:00:00+00:00",
"status_code": 401
}
Delete a user
{
"status": "success",
"message": "User deleted successfully",
"data": {
"message": "User deleted"
}
}
Cascading deletes will remove all related records.
{
"status": "error",
"message": "Error description",
"errors": {
"field_name": ["Error detail"]
},
"code": 400
}
Complete API specification with all endpoint details, request/response formats, and examples.
View Specification