API Documentation
Fati-Market Backend - Kotlin Mobile App
Student Registration
Register a new student account with email, password, and student ID verification photo.
POST /api/register
Authentication: Not required
Content-Type: multipart/form-data
Request Parameters
| Field | Type | Required | Constraints |
|---|---|---|---|
first_name |
string | ✓ | Max 255 chars |
last_name |
string | ✓ | Max 255 chars |
email |
string | ✓ | Must end with @student.fatima.edu.ph, unique |
password |
string | ✓ | Min 8 characters |
password_confirmation |
string | ✓ | Must match password |
student_id_photo |
file | ✓ | jpg/jpeg/png, max 5MB |
verification_use |
string | ✓ | Either: registration_card OR student_id |
Success Response (HTTP 201)
Status: 201 Created
{
"message": "Registration successful. Please wait for admin approval.",
"data": {
"user_id": 42,
"student_id": 15,
"email": "juan.delacruz@student.fatima.edu.ph",
"first_name": "Juan",
"last_name": "Dela Cruz"
}
}
Error Responses
View Error Responses
Invalid Email Domain (HTTP 422)
Email must end with @student.fatima.edu.ph
{
"message": "The given data was invalid.",
"errors": {
"email": ["The email field must end with @student.fatima.edu.ph."]
}
}
Email Already Taken (HTTP 422)
Email address already registered
{
"message": "The given data was invalid.",
"errors": {
"email": ["The email has already been taken."]
}
}
Password Too Short (HTTP 422)
Password must be at least 8 characters
{
"message": "The given data was invalid.",
"errors": {
"password": ["The password field must be at least 8 characters."]
}
}
Passwords Don't Match (HTTP 422)
Confirmation password doesn't match
{
"message": "The given data was invalid.",
"errors": {
"password": ["The password field confirmation does not match."]
}
}
Invalid Photo Format (HTTP 422)
Must be jpg, jpeg, or png file
{
"message": "The given data was invalid.",
"errors": {
"student_id_photo": ["The student id photo field must be a valid image."]
}
}
Photo File Too Large (HTTP 422)
Max file size is 5MB
{
"message": "The given data was invalid.",
"errors": {
"student_id_photo": ["The student id photo field must not be greater than 5120 kilobytes."]
}
}
Database Schema
Three tables are created on successful registration:
users Table
user_id: INT (PK, auto-increment)
email: VARCHAR (UNIQUE)
password: VARCHAR (bcrypt hashed)
wallet_points: INT (default: 0)
role: ENUM ('student', 'admin')
is_active: BOOLEAN (default: FALSE)
created_at: TIMESTAMP
updated_at: TIMESTAMP
student_information Table
student_id: INT (PK, auto-increment)
user_id: INT (FK)
first_name: VARCHAR
last_name: VARCHAR
created_at: TIMESTAMP
updated_at: TIMESTAMP
student_verification Table
student_id: INT (PK, auto-increment)
user_id: INT (FK)
link: TEXT (Cloudinary URL)
is_verified: BOOLEAN (default: FALSE)
created_at: TIMESTAMP
updated_at: TIMESTAMP
Testing
cURL Command
curl -X POST http://localhost:8000/api/register \
-F "first_name=Juan" \
-F "last_name=Dela Cruz" \
-F "email=juan.delacruz@student.fatima.edu.ph" \
-F "password=SecurePass123" \
-F "password_confirmation=SecurePass123" \
-F "verification_use=student_id" \
-F "student_id_photo=@./id_photo.jpg"
Kotlin with OkHttp3
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("first_name", "Juan")
.addFormDataPart("last_name", "Dela Cruz")
.addFormDataPart("email", "juan.delacruz@student.fatima.edu.ph")
.addFormDataPart("password", "SecurePass123")
.addFormDataPart("password_confirmation", "SecurePass123")
.addFormDataPart("verification_use", "student_id")
.addFormDataPart(
"student_id_photo",
photoFile.name,
photoFile.asRequestBody("image/jpeg".toMediaType())
)
.build()
val request = Request.Builder()
.url("http://localhost:8000/api/register")
.post(requestBody)
.build()
client.newCall(request).enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
// Handle response
}
override fun onFailure(call: Call, e: IOException) {
// Handle error
}
})
Ready to test? Share this documentation with your Kotlin developer!