HTTP Method and Path
Request Body
The unique locker number identifier. Must be unique across all lockers.
The employee number to assign to this locker. Must be unique if provided and not empty. Leave empty for unassigned lockers.
The physical location of the locker
Whether the locker is empty. This value is automatically calculated based on the employeeNumber field (false if employeeNumber is provided, true if empty).
Validation Rules
- Unique Locker Number: The
lockerNo must be unique. If a locker with the same number already exists, the request will return a 400 Bad Request error.
- Unique Employee Number: The
employeeNumber must be unique if provided and not empty. If an employee number is already assigned to another locker, the request will return a 400 Bad Request error.
- Auto-calculated isEmpty: The
isEmpty field is automatically set based on whether an employeeNumber is provided.
Response
Returns the created locker object.
The unique locker number identifier
The employee number assigned to this locker
The physical location of the locker
Indicates whether the locker is currently empty
Example Request
Creating an assigned locker
curl -X POST https://api.example.com/api/lockers \
-H "Content-Type: application/json" \
-d '{
"lockerNo": "A001",
"employeeNumber": "EMP12345",
"size": 2,
"location": "Building A - Floor 1"
}'
Creating an empty locker
curl -X POST https://api.example.com/api/lockers \
-H "Content-Type: application/json" \
-d '{
"lockerNo": "A002",
"employeeNumber": "",
"size": 1,
"location": "Building A - Floor 1"
}'
Example Response
Success (201 Created)
{
"lockerNo": "A001",
"employeeNumber": "EMP12345",
"size": 2,
"location": "Building A - Floor 1",
"isEmpty": false
}
Error - Duplicate Locker Number (400 Bad Request)
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"detail": "Locker number A001 already exists"
}
Error - Duplicate Employee Number (400 Bad Request)
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"detail": "Employee number EMP12345 already exists"
}