Skip to main content

Create Weekly Availability

This endpoint allows you to create a new weekly availability schedule for a calendar. The schedule defines regular working hours, special dates, and out-of-office periods.

πŸ”Ή Endpoint Details​

POST /api/v1/weekly-schedules

πŸ”’ Authentication​

HeaderRequiredDescription
Content-TypeYesMust be application/json
AuthorizationYesFormat: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature

πŸ“ Request Structure​

Required Fields​

FieldTypeRequiredDescriptionExample
namestringYesThe name of the weekly schedule"Default Working Week"

Optional Fields​

FieldTypeRequiredDescriptionDefault
calendarIdstringNoThe unique identifier of the calendar this schedule belongs to"123e4567-e89b-12d3-a456-426614174000"
configurationobjectNoConfiguration object describing weekly working hours, date overrides, and out-of-office periodsSee configuration structure
serviceIdsstring[]NoList of service IDs associated with this schedule["123e4567-e89b-12d3-a456-426614174000"]
timezonestringNoIANA timezone name (e.g., "Europe/Berlin", "America/New_York"). Used to interpret working hours and overrides"Europe/Berlin"

Configuration Structure​

FieldTypeRequiredDescription
workingHoursobjectYesDay-based schedule (0=Monday to 6=Sunday)
dateOverridesobjectNoSpecial schedules for specific dates
outsOfTheOfficearrayNoTime periods for unavailability

🧩 Request Example​

curl -X POST "https://openapi.onlive.site/api/v1/weekly-schedules" \
-H "Content-Type: application/json" \
-H "Authorization: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature" \
-d '{
"name": "Test Drive Availability",
"calendarId": "4fb502ee-35cf-4e75-ad68-49b46b505a46",
"timezone": "Europe/Madrid",
"configuration": {
"workingHours": {
"0": [
[
"09:00",
"14:00"
],
[
"16:00",
"20:30"
]
],
"1": [
[
"09:00",
"14:00"
],
[
"16:00",
"20:30"
]
],
"2": [
[
"09:00",
"14:00"
],
[
"16:00",
"20:30"
]
],
"3": [
[
"09:00",
"14:00"
],
[
"16:00",
"20:30"
]
],
"4": [
[
"09:00",
"14:00"
],
[
"16:00",
"20:30"
]
],
"5": [
[
"10:00",
"14:00"
]
],
"6": []
},
"dateOverrides": {
"2025-03-19": [
[
"08:00",
"12:00"
]
]
},
"outsOfTheOffice": [
[
"2025-03-06T18:57",
"2025-03-07T18:57"
]
]
},
"serviceIds": [
"1c79cfed-2076-438c-99f4-1c26da94ab0b",
"1c79cfed-2076-438c-99f4-1c26da94ab43"
]
}'

πŸ“€ Response Format​

Successful Response (201 Created)​

{
"id": "f57b71ad-c1cc-4af6-853b-616ecb7d234c",
"createdAt": "2025-05-22T12:45:06.490Z",
"updatedAt": "2025-05-22T12:45:06.490Z",
"name": "Test Drive Availability",
"calendarId": "4fb502ee-35cf-4e75-ad68-49b46b505a46",
"timezone": "Europe/Madrid",
"configuration": {
// ... configuration as in request
},
"serviceIds": [
"1c79cfed-2076-438c-99f4-1c26da94ab0b",
"1c79cfed-2076-438c-99f4-1c26da94ab43"
]
}

❌ Error Responses​

400 Bad Request​

{
"statusCode": 400,
"message": "Invalid input",
"errors": [
{
"field": "configuration.workingHours",
"message": "Invalid time format"
}
]
}

401 Unauthorized​

{
"statusCode": 401,
"message": "Invalid or missing authorization credentials"
}

403 Forbidden​

{
"statusCode": 403,
"message": "User does not have permission to create schedules"
}

πŸ“˜ Notes​

  • The organizationId is automatically set from your authentication credentials
  • Times in workingHours must be in 24-hour format ("HH:mm")
  • Day numbers are 0 (Monday) through 6 (Sunday)
  • Empty arrays [] indicate closed/unavailable days
  • Out-of-office dates should be in ISO 8601 format
  • Time slots are interpreted in the schedule's timezone
  • Multiple time slots per day are allowed for split shifts

βœ… Common Use Cases​

  • πŸ“… Regular Hours: Set up standard business hours
  • πŸ•’ Split Shifts: Configure morning and afternoon sessions
  • πŸ“† Holiday Schedule: Define special holiday hours
  • 🌍 International Business: Handle different timezone operations
  • 🏒 Branch Schedule: Set up location-specific availability

πŸ” Validation Rules​

  1. Time Format

    • Must be in "HH:mm" format
    • End time must be after start time
    • Valid hour range: 00-23
    • Valid minute range: 00-59
  2. Working Hours

    • Each day can have multiple slots
    • No overlapping time slots
    • Empty array for closed days
  3. Date Overrides

    • Must be valid dates
    • Format: "YYYY-MM-DD"
    • Cannot be in the past
  4. Services

    • Must be valid service UUIDs
    • Services must exist in the system
    • Services must belong to your organization