Overview
The Registrations API allows students to register for events, view their registrations, cancel registrations, and allows organizers/admins to view participant lists.
Register for Event
curl -X POST https://api.example.com/api/registrations/event/1 \
-H "Authorization: Bearer YOUR_TOKEN"
POST /api/registrations/event/{eventID}
Authorization : Bearer YOUR_TOKEN
Register the authenticated student for an event.
Authentication
Required Role: STUDENT (enforced by @PreAuthorize("hasRole('STUDENT')"))
Path Parameters
ID of the event to register for
Response
HTTP status code (201 for successful registration)
Success message: “Registration successful”
No data returned for this endpoint
{
"statusCode" : 201 ,
"message" : "Registration successful" ,
"data" : null ,
"timestamp" : "2024-03-07T10:30:00"
}
Error Responses
Event Full (400)
Already Registered (409)
Event Not Found (404)
{
"statusCode" : 400 ,
"message" : "Event is at full capacity" ,
"timestamp" : "2024-03-07T10:30:00"
}
Get My Registrations
curl -X GET https://api.example.com/api/registrations/me \
-H "Authorization: Bearer YOUR_TOKEN"
GET /api/registrations/me
Authorization : Bearer YOUR_TOKEN
Retrieve all registrations for the authenticated student.
Authentication
Required Role: STUDENT (enforced by @PreAuthorize("hasRole('STUDENT')"))
Response
Success message: “Registrations retrieved successfully”
Array of registration objects
Unique registration identifier
Date of the event (formatted string)
Registration status: REGISTERED, ATTENDED, CANCELLED
ISO 8601 timestamp when registration was created
{
"statusCode" : 200 ,
"message" : "Registrations retrieved successfully" ,
"data" : [
{
"registrationID" : 1 ,
"eventID" : 5 ,
"eventTitle" : "Spring Career Fair 2024" ,
"eventDate" : "2024-04-15" ,
"venue" : "University Hall A" ,
"status" : "REGISTERED" ,
"registeredAt" : "2024-03-01T14:30:00"
},
{
"registrationID" : 2 ,
"eventID" : 7 ,
"eventTitle" : "Tech Workshop Series" ,
"eventDate" : "2024-04-20" ,
"venue" : "Lab Building 201" ,
"status" : "REGISTERED" ,
"registeredAt" : "2024-03-05T09:15:00"
},
{
"registrationID" : 3 ,
"eventID" : 3 ,
"eventTitle" : "Alumni Networking Night" ,
"eventDate" : "2024-02-15" ,
"venue" : "Student Center" ,
"status" : "ATTENDED" ,
"registeredAt" : "2024-02-01T10:00:00"
}
],
"timestamp" : "2024-03-07T10:30:00"
}
Cancel Registration
curl -X DELETE https://api.example.com/api/registrations/1 \
-H "Authorization: Bearer YOUR_TOKEN"
DELETE /api/registrations/{registrationID}
Authorization : Bearer YOUR_TOKEN
Cancel an existing registration. Students can only cancel their own registrations.
Authentication
Required Role: STUDENT (enforced by @PreAuthorize("hasRole('STUDENT')"))
Path Parameters
ID of the registration to cancel
Response
Success message: “Registration cancelled”
No data returned for this endpoint
{
"statusCode" : 200 ,
"message" : "Registration cancelled" ,
"data" : null ,
"timestamp" : "2024-03-07T10:30:00"
}
Error Responses
Not Found (404)
Forbidden (403)
Too Late (400)
{
"statusCode" : 404 ,
"message" : "Registration not found" ,
"timestamp" : "2024-03-07T10:30:00"
}
Get Event Participants
curl -X GET https://api.example.com/api/registrations/event/1/participants \
-H "Authorization: Bearer YOUR_TOKEN"
GET /api/registrations/event/{eventID}/participants
Authorization : Bearer YOUR_TOKEN
Retrieve the list of participants for a specific event. Only accessible to admins and the event organizer.
Authentication
Required Roles: ADMIN or ORGANIZER (enforced by @PreAuthorize("hasAnyRole('ADMIN','ORGANIZER')"))
Path Parameters
Response
Success message: “Participants fetched”
Array of participant objects (Map of String to String)
{
"statusCode" : 200 ,
"message" : "Participants fetched" ,
"data" : [
{
"studentID" : "S123456" ,
"firstName" : "John" ,
"lastName" : "Doe" ,
"email" : "[email protected] " ,
"major" : "Computer Science" ,
"yearOfStudy" : "3" ,
"registeredAt" : "2024-03-01T14:30:00" ,
"status" : "REGISTERED"
},
{
"studentID" : "S789012" ,
"firstName" : "Jane" ,
"lastName" : "Smith" ,
"email" : "[email protected] " ,
"major" : "Business Administration" ,
"yearOfStudy" : "2" ,
"registeredAt" : "2024-03-02T10:15:00" ,
"status" : "REGISTERED"
}
],
"timestamp" : "2024-03-07T10:30:00"
}
Error Responses
Forbidden (403)
Event Not Found (404)
{
"statusCode" : 403 ,
"message" : "You can only view participants for your own events" ,
"timestamp" : "2024-03-07T10:30:00"
}
Registration Status Enum
Registrations can have the following statuses:
REGISTERED - Student is registered and confirmed
ATTENDED - Student attended the event
CANCELLED - Registration was cancelled
Implementation Note
From RegistrationController.java:69-72:
List < Map < String , String >> participants =
registrationService . getParticipantDetails (eventID, userDetails . getUser ());
The service layer handles authorization checks to ensure organizers can only view participants for their own events.