Skip to main content

Creating a Schedule

This endpoint allows operators to create a new schedule with a list of entries defining their availability.

Endpoint

POST /operator/schedules

Required Fields

NameTypeRequiredDescriptionDefault
namestringNoName for the new schedule"Untitled Schedule"
entriesarrayYesList of schedule entries to create

Schedule Entry Object

FieldTypeRequiredDescriptionDefault
start_timedatetimeYesStart time for this schedule entry (ISO 8601)
end_timedatetimeYesEnd time for this schedule entry (ISO 8601)
availability_statusstringYesAvailability status during this time period (e.g., AVAILABLE, UNAVAILABLE)
start_positionobjectYesStarting location coordinates (latitude, longitude)
end_positionobjectYesEnding location coordinates (latitude, longitude)

Example Request

curl -X POST "https://api.opteverything.com/operator/schedules" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_TOKEN>" \
-d '{
"name": "Morning Shift",
"entries": [
{
"start_time": "2024-06-01T08:00:00Z",
"end_time": "2024-06-01T12:00:00Z",
"availability_status": "AVAILABLE",
"start_position": {"latitude": 40.7128, "longitude": -74.0060},
"end_position": {"latitude": 40.7589, "longitude": -73.9851}
}
]
}'

Responses

Success (201 Created)

Status Code: 201 Created

{
"schedule_id": 0,
"created_at": "2024-07-29T12:00:00Z",
"name": "Morning Shift",
"entries": [
{
"entry_id": 0,
"schedule_id": 0,
"start_time": "2024-06-01T08:00:00Z",
"end_time": "2024-06-01T12:00:00Z",
"start_position_id": 0,
"end_position_id": 0,
"availability_status": "AVAILABLE"
}
]
}
FieldTypeDescription
schedule_idintegerUnique identifier for the newly created schedule
created_atdatetimeTimestamp when the schedule was created
namestringName of the schedule
entriesarrayList of schedule entries

For more details, see the API documentation or the schema in schemas/schedule.py.