Create new schedule with specified rules, timezone, account, user and calendar associations.
POST https://services.leadconnectorhq.com/calendars/schedules
Autorización
Bearer token generado desde el portal Leadway. Ver Autenticación.
Version
string
default:"2021-07-28"
required
Versión de la API.
Body
Schedule rules defining when the schedule is active
type
string
default:"wday"
required
Type of schedule rule - weekday (recurring) or date (specific date) Posibles valores: ‘wday’, ‘date’
Time intervals for the rule (e.g., 9 AM to 5 PM)
from
string
default:"09:00"
required
Start time in HH:MM format (24-hour format)
to
string
default:"17:00"
required
End time in HH:MM format (24-hour format)
date
string
default:"2023-04-15"
Specific date in YYYY-MM-DD format (only for date-type rules)
Day of week (only for weekday-type rules) Posibles valores: ‘sunday’, ‘monday’, ‘tuesday’, ‘wednesday’, ‘thursday’, ‘friday’, ‘saturday’
timezone
string
default:"America/New_York"
required
Timezone for the schedule (IANA timezone identifier)
locationId
string
default:"IkqiJlXJ7o9h61tCHHod"
required
Account ID where this schedule applies
name
string
default:"Business Hours Schedule"
required
Human-readable name for the schedule
userId
string
default:"IkqiJlXJ7o9h61tCHHod"
required
User ID associated with the schedule
Calendar IDs associated with the schedule
Respuestas
201 - Schedule created successfully
400 - Invalid request parameters
401 - User not authenticated
422 - Validation errors in schedule rules or conflicting data
Ejemplo
curl -X POST 'https://services.leadconnectorhq.com/calendars/schedules' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Version: 2021-07-28' \
-H 'Content-Type: application/json' \
-d '{
"rules": [
{
"type": "wday",
"day": "monday",
"intervals": [
{
"from": "09:00",
"to": "17:00"
}
]
}
],
"timezone": "America/New_York",
"locationId": "IkqiJlXJ7o9h61tCHHod",
"name": "Business Hours Schedule",
"userId": "IkqiJlXJ7o9h61tCHHod",
"calendarIds": [
"WvVX9LpvlBO6K506xLbp",
"XyZ8MnQrStUvWxYzAbCdEf"
]
}'
const response = await fetch('https://services.leadconnectorhq.com/calendars/schedules', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
Version: '2021-07-28',
'Content-Type': 'application/json',
},
body: JSON.stringify({"rules": [{"type": "wday", "day": "monday", "intervals": [{"from": "09:00", "to": "17:00"}]}], "timezone": "America/New_York", "locationId": "IkqiJlXJ7o9h61tCHHod", "name": "Business Hours Schedule", "userId": "IkqiJlXJ7o9h61tCHHod", "calendarIds": ["WvVX9LpvlBO6K506xLbp", "XyZ8MnQrStUvWxYzAbCdEf"]}),
});
const data = await response.json();
import os, requests
response = requests.request(
'POST',
'https://services.leadconnectorhq.com/calendars/schedules',
headers={
'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
'Version': '2021-07-28',
'Content-Type': 'application/json',
},
json={"rules": [{"type": "wday", "day": "monday", "intervals": [{"from": "09:00", "to": "17:00"}]}], "timezone": "America/New_York", "locationId": "IkqiJlXJ7o9h61tCHHod", "name": "Business Hours Schedule", "userId": "IkqiJlXJ7o9h61tCHHod", "calendarIds": ["WvVX9LpvlBO6K506xLbp", "XyZ8MnQrStUvWxYzAbCdEf"]},
)
data = response.json()
<?php
$ch = curl_init('https://services.leadconnectorhq.com/calendars/schedules');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
'Version: 2021-07-28',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({'rules': [{'type': 'wday', 'day': 'monday', 'intervals': [{'from': '09:00', 'to': '17:00'}]}], 'timezone': 'America/New_York', 'locationId': 'IkqiJlXJ7o9h61tCHHod', 'name': 'Business Hours Schedule', 'userId': 'IkqiJlXJ7o9h61tCHHod', 'calendarIds': ['WvVX9LpvlBO6K506xLbp', 'XyZ8MnQrStUvWxYzAbCdEf']}),
]);
$data = json_decode(curl_exec($ch), true);