0% found this document useful (0 votes)
12 views14 pages

API Routes for User Authentication & Management

Uploaded by

Tripurari Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views14 pages

API Routes for User Authentication & Management

Uploaded by

Tripurari Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

API Routes Documentation

Generated from [Link]

1. Login
request url: /api/login

method type: POST

request payload: JSON body with user credentials.

{
"email": "user@[Link]",
"password": "plain-text-password"
}

success response: Example body:

{
"success": true,
"message": "Login successful!",
"token": "<JWT_TOKEN>",
"expires_in_minutes": 30
}

error response: Possible errors:

- HTTP status: 401

{
"success": false,
"message": "Invalid email or password."
}

- HTTP status: 500

{
"success": false,
"message": "An error occurred: <details>"
}

2. Logout
request url: /api/logout

method type: POST


headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: No body required.

success response: Example body:

{
"success": true,
"message": "Logged out successfully. Please delete token on client
side."
}

error response: Possible errors:

- HTTP status: 401

{
"success": false,
"message": "Invalid token"
}

- HTTP status: 500

{
"success": false,
"message": "An error occurred: <details>"
}

3. Index (Get Current User Profile)


request url: /api/index

method type: POST

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: No body required.

success response: Example body:

{
"success": true,
"message": "Login successful!",
"user": {
"id": "<user_id>",
"email": "user@[Link]",
"role": "CANDIDATE|RECRUITER|ADMIN",
"firstname": "John",
"lastname": "Doe",
"status": "ACTV",
"candidate": {
"candidate_id": "<candidate_id>",
"age": "25",
"education": "[Link]",
"resume_file_path": "C:/resumes/john_20250101_101010.pdf"
},
"recruiter": {
"recruiter_id": "<recruiter_id>",
"company": "Acme Corp",
"position": "HR Manager",
"linkdin_profile_path": "[Link]
}
}
}

error response: Possible errors:

- HTTP status: 401

{
"success": false,
"message": "Invalid email or password."
}

- HTTP status: 500

{
"success": false,
"message": "An error occurred: <details>"
}

4. Create Recruiter
request url: /api/register-recruiter

method type: POST

request payload: JSON body with recruiter and user fields.

{
"firstname": "Riya",
"lastname": "Shah",
"email": "[Link]@[Link]",
"password": "StrongPassword#1",
"company": "Acme Corp",
"position": "Talent Acquisition Lead",
"linkdin_profile_path": "[Link]
}

success response: Example body:

{
"message": "Recruiter register Successfully."
}

error response: Possible errors:

- HTTP status: 400

{
"error": "No input data provided"
}

- HTTP status: 400

{
"error": "Missing field: <field>"
}

- HTTP status: 500

{
"error": "<details>"
}

5. Update Recruiter
request url: /api/update-recruiter

method type: POST

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: JSON body with fields to update (firstname, lastname, email, company,
position, linkdin_profile_path). NOTE: Current server code assigns 'linkdin_profile_path'
from 'position' field, which appears to be a bug.

{
"firstname": "Riya",
"lastname": "Shah",
"email": "[Link]@[Link]",
"company": "Acme Corp",
"position": "Senior TA Lead",
"linkdin_profile_path": "[Link]
}

success response: Example body:

{
"message": "Recruiter details updated successfully!"
}

error response: Possible errors:

- HTTP status: 400

{
"error": "No input data provided"
}

- HTTP status: 404

{
"error": "User not found"
}

- HTTP status: 404

{
"error": "Recruiter not found"
}

- HTTP status: 500

{
"error": "<details>"
}

6. Get Jobs (for Recruiter)


request url: /api/jobs

method type: GET

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: No body required. Only accessible when the authenticated user role is
RECRUITER.
success response: Example body:

{
"count": 2,
"jobs": [
{
"job_id": 101,
"job_title": "Software Engineer",
"location": "Pune",
"job_type": "Full-time",
"description": "...",
"status": "ACTV"
}
]
}

error response: Possible errors:

- HTTP status: 400

{
"message": "Invalid Recruiter!"
}

- HTTP status: 500

{
"error": "Failed to fetch jobs: <details>"
}

7. Create Candidate
request url: /api/register-candidate

method type: POST

request payload: Multipart/form-data with file (resume) and user_data (JSON string).
Allowed file types: png, jpg, jpeg, gif, pdf.

{
"headers": {
"Content-Type": "multipart/form-data"
},
"form": {
"file": "<resume_file.pdf>",
"user_data":
"{\"firstname\": \"Aarav\", \"lastname\": \"Patil\", \"email\": \"aarav.
patil@[Link]\", \"password\": \"StrongPassword#1\", \"education\":
\"B.E.\", \"age\": 23}"
}
}

success response: Example body:

{
"message": "Candidate Register Successfully!"
}

error response: Possible errors:

- HTTP status: 400

{
"error": "Missing file or user data"
}

- HTTP status: 400

{
"error": "Invalid file type"
}

- HTTP status: 500

{
"error": "<details>"
}

8. Update Candidate
request url: /api/update-candidate

method type: POST

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: JSON body with optional fields to update: firstname, lastname, email,
education, age.

{
"firstname": "Aarav",
"lastname": "Patil",
"email": "[Link]@[Link]",
"education": "[Link]",
"age": 24
}
success response: Example body:

{
"message": "Candidate information updated successfully!"
}

error response: Possible errors:

- HTTP status: 400

{
"error": "Email is required"
}

- HTTP status: 404

{
"error": "User not found"
}

- HTTP status: 404

{
"error": "Candidate not found"
}

- HTTP status: 500

{
"error": "<details>"
}

9. Create Job
request url: /api/job

method type: POST

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: JSON body. Only for users with RECRUITER role.

{
"job_title": "Backend Developer",
"location": "Mumbai",
"job_type": "Full-time",
"description_keywords": "Python, Flask, REST, SQL"
}

success response: Example body:

{
"message": "Job created successfully!",
"generated_description": "<AI generated 100-word description>"
}

error response: Possible errors:

- HTTP status: 400

{
"errors": {
"job_title": "Job title is required."
}
}

- HTTP status: 400

{
"errors": {
"location": "Job Location is required."
}
}

- HTTP status: 400

{
"errors": {
"job_type": "Job Type is required."
}
}

- HTTP status: 400

{
"errors": {
"description_keywords": "Description keywords are required."
}
}

- HTTP status: 400

{
"errors": {
"job_title": "A job with this title already exists."
}
}
- HTTP status: 400

{
"message": "Invalid Requiter!"
}

- HTTP status: 500

{
"error": "<details>"
}

10. Update Job


request url: /api/job/<job_id>

method type: PUT

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: JSON body. Only for users with RECRUITER role. Path parameter: job_id
(integer).

{
"job_title": "Backend Developer",
"location": "Mumbai",
"job_type": "Contract",
"description_keywords": "Python, Flask, Microservices"
}

success response: Example body:

{
"message": "Job updated successfully!"
}

error response: Possible errors:

- HTTP status: 404

{
"error": "Job not found"
}

- HTTP status: 400


{
"errors": {
"job_title": "Job title is required."
}
}

- HTTP status: 400

{
"errors": {
"location": "Job location is required."
}
}

- HTTP status: 400

{
"errors": {
"job_type": "Job type is required."
}
}

- HTTP status: 400

{
"errors": {
"description_keywords": "Description is required."
}
}

- HTTP status: 400

{
"errors": {
"job_title": "A job with this title already exists."
}
}

- HTTP status: 400

{
"message": "Invalid Requiter!"
}

- HTTP status: 500

{
"error": "<details>"
}
11. Create Candidate Job Request
request url: /api/candidate-job-request

method type: POST

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: JSON body with job request details.

{
"job_id": 101,
"status": "APPLIED"
}

success response: Example body:

{
"message": "Candidate job request created successfully",
"id": 123
}

error response: Possible errors:

- HTTP status: 400

{
"error": "job_id is required"
}

- HTTP status: 400

{
"error": "status is required"
}

- HTTP status: 400

{
"error": "Invalid status"
}

12. Get Candidate Job Requests (for Recruiter’s Jobs)


request url: /api/candidate-job-requests

method type: GET


headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: No body required. Returns list of candidate requests mapped to jobs
created by the authenticated recruiter.

success response: Example body:

[
{
"candidate_job_request_id": 123,
"candidate_id": 456,
"candidate_name": "Aarav Patil",
"job_id": 101,
"job_title": "Backend Developer",
"test_score": 88,
"interview_scheduled_datetime": "2025-01-15 10:30:00",
"status": "SHORTLISTED",
"status_change_date": "2025-01-14 12:00:00"
}
]

13. Update Candidate Job Request


request url: /api/candidate-job-request/<request_id>

method type: PUT

headers: {
"Authorization": "Bearer <JWT_TOKEN>"
}

request payload: JSON body with fields to update. Path parameter: request_id (integer).
Valid status values: APPLIED, SHORTLISTED, INTERVIEWED, OFFERED, HIRED,
UNDER_TEST. Date-time format required for interview_scheduled_datetime: YYYY-MM-DD
HH:MM:SS.

{
"job_id": 101,
"test_score": 92,
"interview_scheduled_datetime": "2025-01-20 11:00:00",
"status": "INTERVIEWED"
}

success response: Example body:


{
"message": "Candidate job request updated successfully",
"id": 123
}

error response: Possible errors:

- HTTP status: 404

{
"error": "Candidate job request not found"
}

- HTTP status: 400

{
"error": "Invalid status"
}

- HTTP status: 400

{
"error": "Invalid datetime format. Use YYYY-MM-DD HH:MM:SS"
}

You might also like