Create Course
Description
Create a new course.
Authentication
- Required: No (Note: This endpoint doesn't require authentication based on the route configuration)
Request
Headers
POST /v1/customer/course
Content-Type: application/json
Authorization: Bearer <token>
Request Body
{
"publicId": "COURSE001",
"name": "Introduction to Programming",
"description": "A comprehensive course covering programming fundamentals",
"imageUrl": "https://example.com/course-image.jpg",
"instructionVideoUrl": "https://example.com/instruction-video.mp4",
"price": 99.99,
"durationInHours": 40,
"sessionUnit": 8,
"parentId": 1,
"customerId": 1
}
Field Descriptions
publicId:
- Type: string
- Required: Yes
- Description: Unique public identifier for the course (1-25 characters)
name:
- Type: string
- Required: Yes
- Description: Course name (1-100 characters)
description:
- Type: string
- Required: No
- Description: Course description (1-3000 characters)
imageUrl:
- Type: string
- Required: No
- Description: Course image URL (6-250 characters)
instructionVideoUrl:
- Type: string
- Required: No
- Description: Instruction video URL (1-250 characters)
price:
- Type: number
- Required: No
- Description: Course price
durationInHours:
- Type: number
- Required: Yes
- Description: Course duration in hours
sessionUnit:
- Type: number
- Required: No
- Description: Number of sessions (minimum 1)
parentId:
- Type: number
- Required: No
- Description: Parent course ID for course hierarchy
customerId:
- Type: number
- Required: Yes
- Description: Customer ID who owns the course
Response
Success Response (201)
{
"data": {
"id": 1,
"publicId": "COURSE001",
"name": "Introduction to Programming",
"description": "A comprehensive course covering programming fundamentals",
"imageUrl": "https://example.com/course-image.jpg",
"instructionVideoUrl": "https://example.com/instruction-video.mp4",
"price": 99.99,
"durationInHours": 40,
"sessionUnit": 8,
"parentId": 1,
"customerId": 1,
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}
Error Responses
- 422: Validation errors (see Error Response Format)
Error Codes
- E001_BAD_MISSING_DATA: Missing required fields
- E009_BAD_RESOURCE_EXISTS: Course with this publicId already exists
Example Usage
curl -X POST https://api.stepx.io.vn/v1/customer/course \
-H "Content-Type: application/json" \
-d '{
"publicId": "COURSE001",
"name": "Introduction to Programming",
"description": "A comprehensive course covering programming fundamentals",
"durationInHours": 40,
"customerId": 1
}'
const response = await fetch('https://api.stepx.io.vn/v1/customer/course', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
publicId: 'COURSE001',
name: 'Introduction to Programming',
description: 'A comprehensive course covering programming fundamentals',
durationInHours: 40,
customerId: 1
})
});
const data = await response.json();