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
Header | Required | Description |
---|---|---|
Content-Type | Yes | Must be application/json |
Authorization | Yes | Format: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature |
📝 Request Structure
Required Fields
Field | Type | Required | Description | Example |
---|---|---|---|---|
name | string | Yes | The name of the weekly schedule | "Default Working Week" |
Optional Fields
Field | Type | Required | Description | Default |
---|---|---|---|---|
calendarId | string | No | The unique identifier of the calendar this schedule belongs to | "123e4567-e89b-12d3-a456-426614174000" |
configuration | object | No | Configuration object describing weekly working hours, date overrides, and out-of-office periods | See configuration structure |
serviceIds | string[] | No | List of service IDs associated with this schedule | ["123e4567-e89b-12d3-a456-426614174000"] |
timezone | string | No | IANA timezone name (e.g., "Europe/Berlin", "America/New_York"). Used to interpret working hours and overrides | "Europe/Berlin" |
Configuration Structure
Field | Type | Required | Description |
---|---|---|---|
workingHours | object | Yes | Day-based schedule (0=Monday to 6=Sunday) |
dateOverrides | object | No | Special schedules for specific dates |
outsOfTheOffice | array | No | Time 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
-
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
-
Working Hours
- Each day can have multiple slots
- No overlapping time slots
- Empty array for closed days
-
Date Overrides
- Must be valid dates
- Format: "YYYY-MM-DD"
- Cannot be in the past
-
Services
- Must be valid service UUIDs
- Services must exist in the system
- Services must belong to your organization