Training Management API

API Endpoints
Complete documentation for all available API endpoints with examples.
GET/api/trainings
Get all training programs
[
  {
    "id": "cm1x2y3z4a5b6c7d8e9f0g1h",
    "title": "React Development Bootcamp",
    "description": "Learn modern React development with hooks and context",
    "duration": 40,
    "level": "intermediate",
    "category": "Web Development",
    "company": "TechCorp",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "author": {
      "id": "demo-user-id",
      "name": "Demo User",
      "email": "demo@example.com"
    },
    "_count": {
      "applicants": 5
    }
  }
]
curl -X GET "http://localhost:3000/api/trainings" \
     -H "Content-Type: application/json"
GET/api/trainings/{id}
Get a specific training program by ID
{
  "id": "cm1x2y3z4a5b6c7d8e9f0g1h",
  "title": "React Development Bootcamp",
  "description": "Learn modern React development with hooks and context",
  "duration": 40,
  "level": "intermediate",
  "category": "Web Development",
  "company": "TechCorp",
  "createdAt": "2024-01-15T10:30:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "authorId": "demo-user-id",
  "author": {
    "id": "demo-user-id",
    "name": "Demo User",
    "email": "demo@example.com"
  },
  "applicants": [],
  "_count": {
    "applicants": 0
  }
}
curl -X GET "http://localhost:3000/api/trainings/cm1x2y3z4a5b6c7d8e9f0g1h" \
     -H "Content-Type: application/json"
POST/api/trainings
Create a new training program
{
  "title": "Advanced JavaScript",
  "description": "Deep dive into JavaScript concepts and patterns",
  "duration": 30,
  "level": "advanced",
  "category": "Programming",
  "company": "CodeAcademy"
}
{
  "id": "cm2x3y4z5a6b7c8d9e0f1g2h",
  "title": "Advanced JavaScript",
  "description": "Deep dive into JavaScript concepts and patterns",
  "duration": 30,
  "level": "advanced",
  "category": "Programming",
  "company": "CodeAcademy",
  "createdAt": "2024-01-15T10:30:00.000Z",
  "author": {
    "id": "demo-user-id",
    "name": "Demo User",
    "email": "demo@example.com"
  }
}
curl -X POST "http://localhost:3000/api/trainings" \
     -H "Content-Type: application/json" \
     -d '{
       "title": "Advanced JavaScript",
       "description": "Deep dive into JavaScript concepts and patterns",
       "duration": 30,
       "level": "advanced",
       "category": "Programming",
       "company": "CodeAcademy"
     }'
DELETE/api/trainings/{id}
Delete a training program
{
  "message": "Training deleted successfully"
}
curl -X DELETE "http://localhost:3000/api/trainings/cm1x2y3z4a5b6c7d8e9f0g1h" \
     -H "Content-Type: application/json"
POST/api/trainings/{id}/apply
Apply for a training program
{
  "applicantName": "John Doe",
  "applicantEmail": "john@example.com",
  "applicantPhone": "+1234567890"
}
{
  "id": "cm3x4y5z6a7b8c9d0e1f2g3h",
  "status": "applied",
  "appliedAt": "2024-01-15T10:30:00.000Z",
  "applicantName": "John Doe",
  "applicantEmail": "john@example.com",
  "applicantPhone": "+1234567890",
  "user": {
    "id": "demo-user-id",
    "name": "Demo User",
    "email": "demo@example.com"
  },
  "training": {
    "id": "cm1x2y3z4a5b6c7d8e9f0g1h",
    "title": "React Development Bootcamp"
  }
}
curl -X POST "http://localhost:3000/api/trainings/cm1x2y3z4a5b6c7d8e9f0g1h/apply" \
     -H "Content-Type: application/json" \
     -d '{
       "applicantName": "John Doe",
       "applicantEmail": "john@example.com",
       "applicantPhone": "+1234567890"
     }'
GET/api/trainings/{id}/applicants
Get all applicants for a training program
[
  {
    "id": "cm3x4y5z6a7b8c9d0e1f2g3h",
    "status": "applied",
    "appliedAt": "2024-01-15T10:30:00.000Z",
    "applicantName": "John Doe",
    "applicantEmail": "john@example.com",
    "applicantPhone": "+1234567890"
  }
]
curl -X GET "http://localhost:3000/api/trainings/cm1x2y3z4a5b6c7d8e9f0g1h/applicants" \
     -H "Content-Type: application/json"
DELETE/api/applicants/{id}
Delete an applicant
{
  "message": "Applicant deleted successfully"
}
curl -X DELETE "http://localhost:3000/api/applicants/cm3x4y5z6a7b8c9d0e1f2g3h" \
     -H "Content-Type: application/json"

Training Management API