This guide explains how developers and users can integrate with and use the TalentFlow Job Application & Hiring Management System API.
- Authentication Flow
- API Endpoints & Usage
- Testing Tools
- Code Examples
- Common Scenarios
- Error Handling
- Rate Limiting & Security
The TalentFlow API uses JWT (JSON Web Token) authentication. All protected endpoints require a valid token.
Endpoint: POST /api/auth/register
Public: Yes (no authentication required)
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "john_doe",
"email": "john@example.com",
"password": "Password123!"
}'Response:
{
"success": true,
"message": "User registered successfully",
"data": {
"id": 1,
"username": "john_doe",
"email": "john@example.com",
"role": "JOB_SEEKER"
}
}Response Codes:
200 OK— Registration successful400 Bad Request— Invalid input or user already exists500 Internal Server Error— Server error
Endpoint: POST /api/auth/login
Public: Yes (no authentication required)
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "john_doe",
"password": "Password123!"
}'Response:
{
"success": true,
"message": "Login successful",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
}Save the token for future requests:
$token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."Endpoint: GET /api/jobs
curl -X GET http://localhost:8080/api/jobsOptional Query Parameters:
curl -X GET "http://localhost:8080/api/jobs?page=0&size=10&sort=createdDate,desc"Response:
{
"success": true,
"data": [
{
"id": 1,
"title": "Senior Java Developer",
"description": "5+ years experience required",
"company": "TechCorp",
"location": "Remote",
"salary": "120000-150000",
"employmentType": "FULL_TIME",
"status": "OPEN",
"createdDate": "2025-12-28T10:30:00Z"
}
]
}Endpoint: GET /api/jobs/{id}
curl -X GET http://localhost:8080/api/jobs/1Endpoint: POST /api/jobs
Required Role: RECRUITER or ADMIN
curl -X POST http://localhost:8080/api/jobs \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"title": "Senior Java Developer",
"description": "5+ years experience with Spring Boot",
"company": "TechCorp",
"location": "Remote",
"salary": "120000-150000",
"employmentType": "FULL_TIME"
}'Response:
{
"success": true,
"message": "Job created successfully",
"data": {
"id": 1,
"title": "Senior Java Developer",
"createdDate": "2025-12-28T10:30:00Z"
}
}Endpoint: POST /api/applications
Required Role: JOB_SEEKER or RECRUITER
curl -X POST http://localhost:8080/api/applications \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"jobId": 1,
"coverLetter": "I am very interested in this position. I have 6 years of experience with Spring Boot..."
}'Response:
{
"success": true,
"message": "Application submitted successfully",
"data": {
"id": 5,
"jobId": 1,
"userId": 2,
"status": "PENDING",
"appliedDate": "2025-12-28T11:15:00Z"
}
}Endpoint: GET /api/applications
Required Role: Authenticated user
curl -X GET http://localhost:8080/api/applications \
-H "Authorization: Bearer YOUR_JWT_TOKEN"Response:
{
"success": true,
"data": [
{
"id": 5,
"jobId": 1,
"jobTitle": "Senior Java Developer",
"status": "PENDING",
"appliedDate": "2025-12-28T11:15:00Z"
}
]
}Endpoint: PATCH /api/applications/{id}/status
Required Role: RECRUITER (must own the job) or ADMIN
curl -X PATCH http://localhost:8080/api/applications/5/status \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"status": "ACCEPTED"
}'Valid Statuses: PENDING, ACCEPTED, REJECTED, UNDER_REVIEW
URL: http://localhost:8080/swagger-ui/index.html
How to use:
- Open the URL in your browser
- Click the "Authorize" button (top right)
- Paste your JWT token:
Bearer YOUR_TOKEN_HERE - Click "Authorize"
- Try any endpoint directly from the UI
- View responses, errors, and documentation
Advantages:
- ✅ Interactive testing
- ✅ Built-in documentation
- ✅ No tools required
- ✅ See request/response examples
Steps:
- Download Postman
- Import API spec:
- Click Import → Link
- URL:
http://localhost:8080/v3/api-docs
- Create a new request:
- Method:
POST - URL:
http://localhost:8080/api/auth/login - Body (raw JSON):
{ "username": "john_doe", "password": "Password123!" }
- Method:
- Set token as environment variable:
- Click Environments → Create new
- Add variable:
token= paste JWT response
- Use in Authorization header:
- Type:
Bearer Token - Value:
{{token}}
- Type:
Advantages:
- ✅ Professional testing
- ✅ Save requests/collections
- ✅ Environment variables
- ✅ Automated testing & CI/CD
Set token as variable:
$token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."Use in requests:
curl -X GET http://localhost:8080/api/jobs \
-H "Authorization: Bearer $token"// 1. Register
async function register() {
const response = await fetch('http://localhost:8080/api/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'user123',
email: 'user@example.com',
password: 'SecurePass123!'
})
});
const data = await response.json();
console.log(data);
}
// 2. Login & Store Token
async function login() {
const response = await fetch('http://localhost:8080/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'user123',
password: 'SecurePass123!'
})
});
const { data } = await response.json();
localStorage.setItem('token', data.token);
return data.token;
}
// 3. Get All Jobs
async function getJobs() {
const response = await fetch('http://localhost:8080/api/jobs');
const data = await response.json();
return data.data;
}
// 4. Apply for Job (Protected)
async function applyForJob(jobId, coverLetter) {
const token = localStorage.getItem('token');
const response = await fetch('http://localhost:8080/api/applications', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
jobId: jobId,
coverLetter: coverLetter
})
});
return await response.json();
}
// 5. Get User's Applications (Protected)
async function getMyApplications() {
const token = localStorage.getItem('token');
const response = await fetch('http://localhost:8080/api/applications', {
headers: { 'Authorization': `Bearer ${token}` }
});
return await response.json();
}import requests
import json
BASE_URL = 'http://localhost:8080'
# 1. Login
login_data = {
'username': 'john_doe',
'password': 'Password123!'
}
response = requests.post(f'{BASE_URL}/api/auth/login', json=login_data)
token = response.json()['data']['token']
# 2. Get Jobs
headers = {'Authorization': f'Bearer {token}'}
jobs = requests.get(f'{BASE_URL}/api/jobs', headers=headers).json()
print(jobs)
# 3. Apply for Job
application_data = {
'jobId': 1,
'coverLetter': 'I am interested...'
}
response = requests.post(f'{BASE_URL}/api/applications',
json=application_data,
headers=headers)
print(response.json())# 1. Register
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"alice","email":"alice@example.com","password":"Pass123!"}'
# 2. Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"alice","password":"Pass123!"}'
# Save token from response
# 3. Browse Jobs
curl -X GET http://localhost:8080/api/jobs
# 4. Apply for Job
curl -X POST http://localhost:8080/api/applications \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"jobId":1,"coverLetter":"I am interested..."}'
# 5. Check Application Status
curl -X GET http://localhost:8080/api/applications \
-H "Authorization: Bearer $TOKEN"# 1. Register as Recruiter
# Note: Default role is JOB_SEEKER. Contact admin to change to RECRUITER
# 2. Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"recruiter1","password":"Pass123!"}'
# Save token
# 3. Post a Job
curl -X POST http://localhost:8080/api/jobs \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"title":"Backend Developer",
"description":"Java Spring Boot experience required",
"company":"TechCorp",
"location":"New York, NY",
"salary":"100000-130000",
"employmentType":"FULL_TIME"
}'
# 4. View Applications on Your Jobs
curl -X GET http://localhost:8080/api/applications \
-H "Authorization: Bearer $TOKEN"
# 5. Update Application Status
curl -X PATCH http://localhost:8080/api/applications/2/status \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"status":"ACCEPTED"}'{
"timestamp": "2025-12-28T12:00:00.000Z",
"status": 401,
"error": "Unauthorized",
"message": "Full authentication is required to access this resource"
}Solution: Add valid JWT token to Authorization: Bearer header
{
"timestamp": "2025-12-28T12:00:00.000Z",
"status": 403,
"error": "Forbidden",
"message": "Access denied: You don't have permission to perform this action"
}Solution: Ensure user has required role (RECRUITER/ADMIN)
{
"success": false,
"message": "Validation failed",
"errors": {
"email": "Email should be valid"
}
}Solution: Check request body format and required fields
{
"success": false,
"message": "Resource not found: Job with id 999 not found"
}Solution: Verify resource ID exists
{
"timestamp": "2025-12-28T12:00:00.000Z",
"status": 500,
"error": "Internal Server Error",
"message": "Database connection failed"
}Solution: Check server logs and ensure MySQL is running
-
Never expose tokens:
- ❌ Don't commit tokens to git
- ✅ Store in environment variables
- ✅ Store in secure storage (localStorage in browsers, secure HTTP cookies)
-
HTTPS in Production:
- Configure SSL/TLS certificate
- Use
https://instead ofhttp://
-
Token Expiration:
- Tokens expire after a set time
- Re-login to get a new token
- Implement refresh token mechanism for frontend
-
Validate Input:
- Check email format
- Use strong passwords (8+ chars, mix of uppercase, numbers, special chars)
- Sanitize user inputs
-
CORS Configuration:
- Currently accepts all origins
- In production, restrict to your frontend domain only
| Endpoint | Method | Auth | Purpose |
|---|---|---|---|
/api/auth/register |
POST | No | Create new account |
/api/auth/login |
POST | No | Get JWT token |
/api/jobs |
GET | No | List all jobs |
/api/jobs/{id} |
GET | No | Get single job |
/api/jobs |
POST | Yes (RECRUITER) | Create job posting |
/api/applications |
POST | Yes | Apply for job |
/api/applications |
GET | Yes | Get user's applications |
/api/applications/{id}/status |
PATCH | Yes (RECRUITER) | Update application status |
- API Documentation:
http://localhost:8080/swagger-ui/index.html - OpenAPI Spec:
http://localhost:8080/v3/api-docs - Issues: Check RUNNING_PROJECT_STEPS.md for troubleshooting
Last Updated: December 28, 2025
Version: 1.0.0