Deletes all schedule entries that fall within the specified date range.
The duration of the specified date range cannot exceed 5 days.
You may only delete schedule entries that occur in the future. Scheduled entries that occurred in the past cannot be deleted. Attempting to delete the currently active schedule entryIdentifies a schedule entry that is currently serving as the source for the live channel's feed. will truncate it.
Request
Request syntax:
DELETE /channels/Live Channel ID/schedules?start=Start Timestamp&end=End Timestamp
Define the following variables when submitting the above request:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Live Channel ID Required | Identifies a live channel by its system-defined ID. |
Start Time Required | Identifies the start of the time period for which schedule entries will be deleted. Specify a timestamp (ISO 8601 - milliseconds; UTC). If you specify a time in the past, then the start query string parameter will be set to the present. Syntax: YYYY-MM-DDThh:mm:ss.sssZ Example: start=2023-01-08T20:31:11.510Z Default value: The default value varies according to whether the end parameter has been defined. If the end parameter has been defined, then the default value is: End Time - 15 minutes If the end parameter has been omitted, then the default value is the point-in-time at which the request is submitted. |
End Time Required | Identifies the end of the time period for which schedule entries will be deleted. Specify a timestamp (ISO 8601 - milliseconds; UTC). Syntax: YYYY-MM-DDThh:mm:ss.sssZ Example: end=2023-01-08T20:31:11.510Z Default value: The default value varies according to whether the start parameter has been defined. If the start parameter has been defined, then the default value is: Start Time + 15 minutes If the start parameter has been omitted, then the default value is the point-in-time at which the request is submitted. |
keep_live | Set to 1 to exclude the currently active schedule entryIdentifies a schedule entry that is currently serving as the source for the live channel's feed. from deletion. Default behavior: If this parameter is not defined, then attempting to delete the currently active schedule entry will truncate it to the point-in-time at which this API request is processed. |
Response
The response for a successful request is a 200 OK and it contains the following properties:
Name | Data Type | Description |
---|---|---|
@id | String | Indicates the relative path to this endpoint. |
@type | String | Returns Schedule. |
message | String | Returns the following value for successful deletions: Deleted entries: Number of Deleted Entries |
If one or more schedule entries cannot be deleted, then this endpoint will not delete any schedule entries and it will return one of the following status codes:
- 400 Bad Request: An invalid request was submitted. Verify that the start and end query string parameters were set to valid timestamps.
- 403 Unauthorized: A request to delete one or more current or past schedule entries was submitted. Set the end query string parameter to a point-in-time in the future.
- 500 Internal Server Error: An unknown error occurred. Check the request and resubmit it.
Sample Request/Response
Call the delete_multiple_schedule_entries module (Python 3) to delete all of the schedule entries that fall within a specified date range. This module imports names from the api_auth module.
import json, requests, datetime, time
from api_auth import APICredentials, APIParams
channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel.
def convert_ts(utc_tstamp):
"""
Convert a UTC timestamp to ISO 8601 format (YYYY-MM-DDThh:mm:ss.sZ).
:param utc_tstamp: The UTC timestamp to convert (expected milliseconds)
"""
iso_format = "%Y-%m-%dT%H:%M:%S.%fZ"
try:
_ts = float("{0:.3f}".format(utc_tstamp/1000.0))
return "{}{}".format(datetime.datetime.utcfromtimestamp(_ts).strftime(iso_format)[:-4], "Z")
except Exception:
print ("Invalid timestamp: {}".format(utc_tstamp))
raise
class DeleteMultipleScheduleEntries:
def __init__(self):
self.host = "https://services.uplynk.com"
def run(self):
"""
Deletes a schedule entry.
"""
self._delete_schedule_entry()
def _delete_schedule_entry(self):
start = int((time.time() + 3600) * 1000.0) # 1 hour from now
start = convert_ts(start)
end = int((time.time() + 7200) * 1000.0) # 2 hours from now
end = convert_ts(end)
url = "{}{}{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules?start=", start, "&end=", end)
response = requests.delete(
url, params=APIParams(APICredentials()).get_params({})
)
print(response.json())
DeleteMultipleScheduleEntries().run()
Response:
{
'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules?start=2021-04-28T23:08:35.769Z&end=2021-04-29T00:08:35.771Z',
'@type': 'Schedule',
'message': 'Deleted entries: 1'
}