Schedule Entries API

This API is only compatible with live channels that can leverage schedule entries.
Learn more.

Administer schedule entries associated with a live channel through the following endpoints:

Endpoint Description

Add Schedule Entry

POST /channels/Live Channel ID/schedules

Adds a schedule entry to a live channel.

Add Schedule Entries by Playlist

POST /channels/Live Channel ID/schedule-playlist

Adds a playlist's assets and ad breaks as entries within a live channel's schedule.

Delete Multiple Schedule Entries

DELETE /channels/Live Channel ID/schedules

Deletes all schedule entries that fall within the specified date range.

Delete Schedule Entry / Linked Schedule Entries

DELETE /channels/Live Channel ID/schedules/Schedule Entry ID

Delete linked schedule entries:

DELETE /channels/Live Channel ID/schedules/Schedule Entry ID?include_linked=true

Deletes a schedule entry from a live channel. If the entry was scheduled as a result of a playlist, then you may also delete all of the other entries that were scheduled at that time.

Get Multiple Schedule Entries

GET /channels/Live Channel ID/schedules

Retrieves the set of schedule entries associated with a live channel for a specific time period.

Get Schedule Entry

GET /channels/Live Channel ID/schedules/Schedule Entry ID

Retrieves a specific schedule entry.

Update Schedule Entry

PATCH /channels/Live Channel ID/schedules/Schedule Entry ID

Updates a specific schedule entry.

Add Schedule Entry

Adds a schedule entry to a live channel.

By default, a new schedule entry cannot conflict with an existing one. Use the conflict_resolution property to resolve scheduling conflicts.

Request

Request syntax:

POST /channels/Live Channel ID/schedules

Define the following variable 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.

Request body:

Define a schedule entry through the following properties:

Name

Data Type

Description

ad_breaks

List of integers

Determines the duration for each ad break associated with the asset.

Key information:

  • Define ad break duration in the order in which ad breaks appear in the asset.

    Example:

    The following configuration indicates that the asset contains four ad breaks. It sets the duration of the first and third ad break to 90 seconds and the second and fourth ad break to 120 seconds:

    'ad_breaks': [90, 120, 90, 120],
  • Specify a duration for each ad break associated with the asset.

    This endpoint returns an error when the number of ad breaks associated with the asset do not match the number of ad breaks defined in this list. An exception to this rule occurs if you are skipping all ad breaks by setting this property to an empty list.

  • Skip an ad break by setting its duration to 0.

    Example:

    The following configuration sets the duration of the first and last ad break to 90 seconds and skips the second ad break:

    'ad_breaks': [90, 0, 90],
  • Skip all ad breaks by omitting this property or setting it to an empty list.

conflict_resolution

String

Determines how scheduling conflicts are handled. Valid values are:

  • replace: Overwrite previously scheduled entries with the new entry being scheduled.

    Overwriting a schedule entry that is currently being streamed truncates it at the point-in-time defined by the new schedule entry's start time.

  • trim-start: Trim the beginning of the asset to fit within the current scheduling gap.

  • trim-end: Trim from the end of the asset to fit within the current scheduling gap.

Prevent previously scheduled entries from being overwritten by excluding this property from the request. Omitting this property causes our service to respond with a 409 Conflict when a scheduling conflict arises.

Trimming an asset can affect the number of ads served. Specifically, we will not serve ads for an ad break positioned within a portion of the asset that is trimmed.

content_id

Required

content_id

String

Required for content_type: asset or slicer

Identifies an asset by its system-defined ID or a Live Slicer by the ID defined within the SlicerID setting of its Live Slicer configuration file.

You may only schedule another user's Live Slicer if it is streaming to a library shared with your account.

content_owner

String

content_type: slicer Only

Identifies the user that owns the scheduled Live Slicer by its system-defined ID.

content_type

Required

String

Determines whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are:

ad | asset | slicer | replay_source

desc

String

Defines the schedule entry's description.

dur

Required

Integer

Determines the schedule entry's duration in milliseconds.

Key information:

  • This property is always required for scheduled ad breaks and Live Slicers.
  • A schedule entry's duration cannot exceed 12 hours.
  • content_type: asset Only

    • This property is required for scheduled assets when the ad_breaks property has been defined.
    • If the ad_breaks property has not been defined, then the default value for this property is the asset's duration.
    • Set a scheduled asset's duration to a value that is equal to or less than the sum of the asset's duration and all of its ad breaks. Ad break duration is determined by the ad_breaks property.

      Setting a duration that exceeds the sum of the asset's duration and all of its ad breaks generates an error.

      Example:

      The following payload indicates that the asset contains three 90 second ad breaks.

      'content_type': 'asset',

      'ad_breaks': [90, 90, 90],

      ...

      If the asset's duration is 25 minutes, then you should set dur to 1500270.

      (25 * 60 * 1000) + 90 + 90 + 90 = 1500270

external_id

String

Defines a schedule entry's custom ID.

overwrite

Deprecated

String

Determines how scheduling conflicts are handled.

The conflict_resolution property takes precedence over this deprecated property.

replaced_by

String

Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry.

replay_source String

content_type only

Specifies the time frame of the content that should be played.

Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end.

replay_source_end String

content_type: replay_source only

Specifies the time (UTC) the content should stop playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ
replay_source_start String

content_type: replay_source only

Specifies the time (UTC) the content should begin playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

start

Required

String

Determines the schedule entry's start time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

Key information:

  • Missing content slate occurs when there is a gap between scheduled entries.

    Set a schedule entry's start time to the previous entry's end time to prevent missing content slate.

  • content_type: asset only

    A schedule entry's start time determines the point-in-time at which the asset will start streaming. If a schedule entry's start time is in the past, then the system behaves as if the asset had been streaming since the specified start time. This means that the portion of the video that occurred in the past is excluded from your live channel's feed.

    You may not schedule an asset so that it ends in the past. Ensure that an asset's duration is sufficient to extend into the future when scheduling in the past.

    Example:

    If you schedule an asset 45 seconds into the past, then your live channel's feed will start streaming 45 seconds into the asset. If the asset's duration is 30 minutes, then only 29 minutes and 15 seconds of that asset's content will be included in your live channel's feed. On the other hand, if the asset's duration is 30 seconds, then this endpoint returns an error indicating that a schedule entry cannot end in the past.

Authentication

Pass a digital signature based off of msg.

Learn more.

Response

The response for a successful request contains the following properties:

Name

Data Type

Description

@id

String

Indicates the relative path to an endpoint that returns this schedule entry.

You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-.

@type

String

Returns Schedule.

ad_breaks

List of integers

Indicates the duration for each ad break associated with the asset.

content_id

String

content_type: asset or slicer

Identifies an asset by its system-defined ID or a Live Slicer by the ID defined within the SlicerID setting of its Live Slicer configuration file.

content_owner

String

content_type: slicer Only

Identifies the user that owns the scheduled Live Slicer by its system-defined ID.

This property is only returned for Live Slicers that belong to another user.

content_type

String

Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are:

ad | asset | slicer | replay_source

created

String

Indicates the timestamp (UTC) at which the schedule entry was created.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

deleted

String

include_deleted=1 Only

Indicates the timestamp (UTC) at which the schedule entry was deleted.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

desc

String

Indicates the schedule entry's description. If the schedule entry does not have a description, then this property's value varies by the type of schedule entry.

  • Asset: Indicates the name assigned to the asset.
  • Ad Break: Returns Ad Break.
  • Slicer: Returns an empty string.

Schedule entries created through the CMS are not assigned a description.

dur

Integer

Indicates the schedule entry's duration in milliseconds.

end

String

Indicates the schedule entry's end time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

external_id

String

Indicates a schedule entry's custom ID.

id

String

Identifies a schedule entry by its system-defined ID.

lastmod

String

Indicates the timestamp (UTC) at which the schedule entry was last modified.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

offset

Integer

Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past.

Example:

An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000.

owner

String

Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry.

replaced_by

String

Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry.

replay_source String

content_type only

Specifies the time frame of the content that should be played.

Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end.

replay_source_end String

content_type: replay_source only

Specifies the time (UTC) the content should stop playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ
replay_source_start String

content_type: replay_source only

Specifies the time (UTC) the content should begin playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

start

String

Indicates the schedule entry's start time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

type

String

Indicates the type of schedule entry. Valid values are:

  • Time: Identifies an actual schedule entry.
  • Empty: Identifies a placeholder schedule entry that identifies a gap in the schedule.

 

Sample Request/Response

Call the add_schedule_entry module (Python 3) to adds a schedule entry. 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.
asset_id = 'ae071e89574248c2ab179fe73d436c3e' # Replace with the ID for the desired asset.

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 ScheduleEntry:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Create a schedule entry.
        """
        self._create_schedule_entry()

    def _create_schedule_entry(self):
        url = "{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules")

        start = int((time.time() + 3600) * 1000.0) # 1 hour from now
        start = convert_ts(start)
        
        payload = {
            'content_id': asset_id,
            'content_type': 'asset',
            'start': start
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.post(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

ScheduleEntry().run()

Response:

{
	'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12',
	'@type': 'Schedule',
	'created': '2021-02-16T00:57:10.402Z',
	'lastmod': '2021-02-16T00:57:10.402Z',
	'id': '2158c7452b7841158972e019a5bd5f12',
	'owner': 'ab533864a92b46a1a286cdd49b0a9bd3',
	'content_id': 'ae071e89574248c2ab179fe73d436c3e',
	'content_type': 'asset',
	'desc': 'Sports Segment',
	'dur': 2343598,
	'external_id': '',
	'start': '2021-02-16T00:57:10.402Z',
	'end': '2021-02-16T01:36:14.000Z',
	'type': 'Time',
	'ad_breaks': []
}

Add Schedule Entries by Playlist

Adds a playlist's assets and ad breaks as entries within a live channel's schedule.

By default, a new schedule entry cannot conflict with an existing one. Use the conflict_resolution property to resolve scheduling conflicts.

Request

Request syntax:

POST /channels/Live Channel ID/schedule-playlist

Define the following variable 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.

Request body:

Define a schedule entry through the following properties:

Name

Data Type

Description

conflict_resolution

String

Determines how scheduling conflicts are handled. Valid values are:

  • replace: Overwrite previously scheduled entries with the new entry being scheduled.

    Overwriting a schedule entry that is currently being streamed truncates it at the point-in-time defined by the new schedule entry's start time.

  • trim-start: Trim the beginning of the asset to fit within the current scheduling gap.

  • trim-end: Trim from the end of the asset to fit within the current scheduling gap.

Prevent previously scheduled entries from being overwritten by excluding this property from the request. Omitting this property causes our service to respond with a 409 Conflict when a scheduling conflict arises.

Trimming an asset can affect the number of ads served. Specifically, we will not serve ads for an ad break positioned within a portion of the asset that is trimmed.

overwrite

Deprecated

String

Determines how scheduling conflicts are handled.

The conflict_resolution property takes precedence over this deprecated property.

playlist_id

Required

String

Identifies a playlist by its system-defined ID.

Use the Get All Virtual Linear Playlists endpoint to retrieve a list of virtual linear playlists and their system-defined IDs.

start

Required

String

Indicates the start time (UTC) for the starting point at which schedule entries will be inserted.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

Key information:

  • You must set this property to a point-in-time in the future. You cannot schedule a playlist so that it starts in the past.
  • You may only set this start time to an available time slot. Our service returns a 400 Bad Request when attempting to set a start time during a time slot that is already taken by a previously scheduled entry. This occurs regardless of the conflict_resolution property.
  • Missing content slate occurs when there is a gap between scheduled entries.

    Set the start time to the previous entry's end time to prevent missing content slate.

Authentication

Pass a digital signature based off of msg.

Learn more.

Response

The response for a successful request contains the following properties:

Name

Data Type

Description

@id

String

Indicates the relative path to the requested endpoint.

@type

String

Returns Collection.

items

List of dictionaries

Contains a list of the schedule entries that were created.

total_items

Integer

Indicates the total number of recently created schedule entries.

items List

The items list describes each schedule entry through the following properties:

Name

Data Type

Description

@id

String

Indicates the relative path to an endpoint that returns this schedule entry.

@type

String

Returns Schedule.

ad_breaks

List of integers

Indicates the duration for each ad break associated with the asset.

content_id

String

content_type: asset

Identifies an asset by its system-defined ID.

content_type

String

Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are:

ad | asset | slicer | replay_source

created

String

Indicates the timestamp (UTC) at which the schedule entry was created.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

desc

String

Indicates the schedule entry's description. If the schedule entry does not have a description, then this property's value varies by the type of schedule entry.

  • Asset: Indicates the name assigned to the asset.
  • Ad Break: Returns Ad Break.

Schedule entries created through the CMS are not assigned a description.

dur

Integer

Indicates the schedule entry's duration in milliseconds.

end

String

Indicates the schedule entry's end time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

external_id

String

Indicates a schedule entry's custom ID.

id

String

Identifies a schedule entry by its system-defined ID.

lastmod

String

Indicates the timestamp (UTC) at which the schedule entry was last modified.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

offset

Integer

Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past.

Example:

An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000.

owner

String

Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry.

replaced_by

String

Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry.

replay_source String

content_type only

Specifies the time frame of the content that should be played.

Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end.

replay_source_end String

content_type: replay_source only

Specifies the time (UTC) the content should stop playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ
replay_source_start String

content_type: replay_source only

Specifies the time (UTC) the content should begin playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

source

Dictionary

Identifies the playlist from which this schedule entry was created.

start

String

Indicates the schedule entry's start time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

source Dictionary

The source dictionary identifies the playlist from which this schedule entry was created.

Name

Data Type

Description

id

String

Indicates the system-defined ID for the playlist from which this schedule entry was created.

type

String

Returns playlist.

 

Sample Request/Response

Call the add_schedule_entries_by_playlist module (Python 3) to create schedule entries from the assets and ad breaks associated with a playlist. 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.
playlist_id = 'gh35hs89274748j2ab459ne7ud4f6cl3' # Replace with the ID for the desired playlist.

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 ScheduleEntries:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Create mulitple schedule entries.
        """
        self._create_schedule_entries_by_playlist()

    def _create_schedule_entries_by_playlist(self):
        url = "{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedule-playlist")

        start = int((time.time() + 3600) * 1000.0) # 1 hour from now
        start = convert_ts(start)

        payload = {
            'playlist_id': playlist_id,            
            'start': start
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.post(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

ScheduleEntries().run()

Response:

{
	'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules?start=now&end=now+240m',
	'@type': 'TimeSeries',
	'start': '2022-12-19T19:48:24.000Z',
	'end': '2022-12-19T23:48:24.000Z',
	'items': [{
			'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/631c7c0accbb4bc999ea5536aa81ce91',
			'@type': 'Schedule',
			'id': '631c7c0accbb4bc999ea5536aa81ce91',
			'content_id': '5574ff5e41c04bdd9ed5ed485c6a3211',
			'content_type': 'asset',
			'deleted': '',
			'desc': 'marketing-conference-2022-green-room-morning',
			'dur': 227968,
			'end': '2022-12-19T20:35:30.474Z',
			'external_id': '',
			'owner': '1234567890abcdefghijklmnopqrstu',
			'source': {
				'id': '18495b21df6c410a968f89da32a025ff',
				'type': 'playlist'
			},
			'start': '2022-12-19T20:31:42.506Z',
			'ad_breaks': [],
			'lastmod': '2022-12-19T19:31:43.065Z',
			'created': '2022-12-19T19:31:43.065Z'
		}, {
			'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/05a882f291434e788fe09b413a83e8b4',
			'@type': 'Schedule',
			'id': '05a882f291434e788fe09b413a83e8b4',
			'content_id': 'fb19109d3cf6470a806e85307c70842e',
			'content_type': 'asset',
			'deleted': '',
			'desc': 'marketing-conference-2022-red-room-morning',
			'dur': 9856,
			'end': '2022-12-19T20:44:01.217Z',
			'external_id': '',
			'owner': '1234567890abcdefghijklmnopqrstu',
			'source': {
				'id': '18495b21df6c410a968f89da32a025ff',
				'type': 'playlist'
			},
			'start': '2022-12-19T20:43:51.361Z',
			'ad_breaks': [],
			'lastmod': '2022-12-19T19:43:51.709Z',
			'created': '2022-12-19T19:43:51.709Z'
		}, {
			'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2be08e891c544312a984361614b7ae35',
			'@type': 'Schedule',
			'id': '2be08e891c544312a984361614b7ae35',
			'content_id': 'a404b63430a7437a99995d3285a48be6',
			'content_type': 'asset',
			'deleted': '',
			'desc': 'marketing-conference-2022-blue-room-morning',
			'dur': 24493,
			'end': '2022-12-19T20:44:25.710Z',
			'external_id': '',
			'owner': '1234567890abcdefghijklmnopqrstu',
			'source': {
				'id': '18495b21df6c410a968f89da32a025ff',
				'type': 'playlist'
			},
			'start': '2022-12-19T20:44:01.217Z',
			'ad_breaks': [],
			'lastmod': '2022-12-19T19:43:51.709Z',
			'created': '2022-12-19T19:43:51.709Z'
		}
	]
}

Delete Multiple Schedule Entries

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.

Authentication

Pass a digital signature based off of msg.

Learn more.

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:

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'
}

Delete Schedule Entry / Linked Schedule Entries

Deletes:

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 (single schedule entry):

DELETE /channels/Live Channel ID/schedules/Schedule Entry ID

Request syntax (schedule entry and linked schedule entries):

DELETE /channels/Live Channel ID/schedules/Schedule Entry ID?include_linked=true

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.

Schedule Entry ID

Required

Identifies a schedule entry by its system-defined ID.

Use the Get Multiple Schedule Entries endpoint to retrieve schedule entries and their system-defined IDs.

Authentication

Pass a digital signature based off of msg.

Learn more.

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 Deleted when the specified draft has been successfully deleted.

If a schedule entry cannot be deleted, then the response will have one of the following status codes:

Sample Request/Response

Call the delete_schedule_entry module (Python 3) to delete a schedule entry. This module imports names from the api_auth module.

import json, requests
from api_auth import APICredentials, APIParams
channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel.
schedule_id = '2158c7452b7841158972e019a5bd5f12'  # Replace with the ID for the desired schedule entry.

class DeleteScheduleEntry:
    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):
        url = "{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules/", schedule_id)
 
        response = requests.delete(
            url, params=APIParams(APICredentials()).get_params({})
        )

        print(response.json())

DeleteScheduleEntry().run()

Response:

{
	'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12',
	'@type': 'Schedule',
	'message': 'Deleted'
}

Get Multiple Schedule Entries

Retrieves either: 

Information describing a scheduled entry is retained for 30 days after its end time.

Request

Request syntax (time period):

Request syntax (recently updated schedule entries):

GET /channels/Live Channel ID/schedules?after=Last Modified Time

Define the following URL segment when submitting one of the above requests:

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.

Define the following optional query string parameters when submitting one of the above requests:

Parameter

Description

start=Start Time

Time Period Only

Identifies the start of the time period for which schedule entries will be retrieved. Specify a timestamp (ISO 8601 - milliseconds; UTC).

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=End Time

Time Period Only

Identifies the end of the time period for which schedule entries will be retrieved. 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.

include_deleted=1

Time Period Only

Pass include_deleted=1 to include deleted schedule entries in the response. The deleted response property is included for deleted schedule entries. Omit it to exclude this information.

include_empty=1

Time Period Only

Pass include_empty=1 to include a placeholder schedule entry for each gap within your schedule for the requested time period.

A placeholder schedule entry is limited to the following response properties:

@id | @type | id | desc | dur | end | start | type

The type property for placeholder schedule entries is set to Empty.

slicer_assets=1

Time Period Only

Pass slicer_assets=1 to include information that describes assets played within a live channel as a result of a Live Slicer. Omit it to exclude this information.

after=Last Modified Time

Recently Updated Only

Identifies a point-in-time for retrieving recently updated schedule entries. The response will only include schedule entries that were updated after this point-in-time. Specify a timestamp (ISO 8601 - milliseconds; UTC).

The specified point-in-time may not exceed 10 minutes into the past. If you specify a point-in-time that is older than 10 minutes, then we will only return schedule entries that have been updated within the last 10 minutes.

The after query string parameter takes precedence over the start and end parameters.

Syntax:

YYYY-MM-DDThh:mm:ss.sssZ

Example:

after=2023-01-08T20:31:11.510Z

Default value: 

The default value is 10 minutes.

Authentication

Pass a digital signature based off of msg.

Learn more.

Response

The response for a successful request contains the following properties:

Name

Data Type

Description

@id

String

Indicates the relative path to the requested endpoint.

@type

String

This property's value varies according to whether you requested data by:

  • Time Period: If you requested to retrieve schedule entries by time period through the start and end parameters, then this property returns TimeSeries.
  • Recently Updated Schedule Entries: if you requested to retrieve recently updated schedule entries through the after parameter, then this property returns Collection.

start

String

Indicates the timestamp (ISO 8601 - milliseconds; UTC) that identifies the start of the time period for which schedule entries were retrieved.

Syntax:

YYYY-MM-DDThh:mm:ss.sssZ

end

String

Indicates the timestamp (ISO 8601 - milliseconds; UTC) that identifies the end of the time period for which schedule entries were retrieved.

We restrict the number of schedule entries that may be retrieved through this endpoint to 500. If the number of schedule entries in the requested time period exceeds this limit, then we will return the results for a shorter time period. Your script should check whether the requested end time (i.e., &end=End Time) matches the timestamp returned by the end response property. If there is a mismatch, then your script should submit another request with the start time set to the timestamp returned by the end response property and the end time set to the original requested end time.

Syntax:

YYYY-MM-DDThh:mm:ss.sssZ

items

List of dictionaries

Contains a list of schedule entries.

@included

List of dictionaries

slicer_assets=1 Only

Contains a list of assets that were played within a live channel as a result of a Live Slicer. This list is restricted to the assets that were played during the time period defined by the start and end response parameter.

@links

Dictionary

slicer_assets=1 Only

Contains the assets dictionary. The assets dictionary contains the following property:

  • href: A string value that indicates the relative path to an endpoint through which you may retrieve more information about assets.

total_items

Integer

after={Last Modified Time} Only

Indicates the total number of recently updated schedule entries.

items List

The items list describes each schedule entry through the following properties:

Name

Data Type

Description

@id

String

Indicates the relative path to an endpoint that returns this schedule entry.

You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-.

@type

String

Returns Schedule.

ad_breaks

List of integers

Indicates the duration for each ad break associated with the asset.

content_id

String

content_type: asset or slicer

Identifies an asset by its system-defined ID or a Live Slicer by the ID defined within the SlicerID setting of its Live Slicer configuration file.

content_owner

String

content_type: slicer Only

Identifies the user that owns the scheduled Live Slicer by its system-defined ID.

This property is only returned for Live Slicers that belong to another user.

content_type

String

Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are:

ad | asset | slicer | replay_source

created

String

Indicates the timestamp (UTC) at which the schedule entry was created.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

deleted

String

include_deleted=1 Only

Indicates the timestamp (UTC) at which the schedule entry was deleted.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

desc

String

Indicates the schedule entry's description. If the schedule entry does not have a description, then this property's value varies by the type of schedule entry.

  • Asset: Indicates the name assigned to the asset.
  • Ad Break: Returns Ad Break.
  • Slicer: Returns an empty string.

Schedule entries created through the CMS are not assigned a description.

dur

Integer

Indicates the schedule entry's duration in milliseconds.

end

String

Indicates the schedule entry's end time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

external_id

String

Indicates a schedule entry's custom ID.

id

String

Identifies a schedule entry by its system-defined ID.

lastmod

String

Indicates the timestamp (UTC) at which the schedule entry was last modified.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

offset

Integer

Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past.

Example:

An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000.

owner

String

Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry.

replaced_by

String

Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry.

replay_source String

content_type only

Specifies the time frame of the content that should be played.

Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end.

replay_source_end String

content_type: replay_source only

Specifies the time (UTC) the content should stop playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ
replay_source_start String

content_type: replay_source only

Specifies the time (UTC) the content should begin playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

source

Dictionary

Identifies the playlist from which this schedule entry was created.

start

String

Indicates the schedule entry's start time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

type

String

Indicates the type of schedule entry. Valid values are:

  • Time: Identifies an actual schedule entry.
  • Empty: Identifies a placeholder schedule entry that identifies a gap in the schedule.

source Dictionary

The source dictionary identifies the playlist from which this schedule entry was created.

Name

Data Type

Description

id

String

Indicates the system-defined ID for the playlist from which this schedule entry was created.

type

String

Returns playlist.

@included List

The @included list describes each asset played within a live channel as a result of a Live Slicer through the following properties:

Name

Data Type

Description

id

String

Reserved for future use.

slicer_id

String

Indicates the ID for the Live Slicer that sliced the asset.

A Live Slicer's ID is determined by the SlicerID setting within the Live Slicer's configuration file.

channel

String

Indicates the system-defined ID for the live channel on which the asset was played.

content_id

String

Indicates the asset's system-defined ID (i.e., asset ID).

content_type

slicer-asset

Returns slicer-asset.

created

String

Indicates the timestamp (UTC) at which the asset was created.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

desc

String

Indicates the asset's name as determined by the description setting in the Live Slicer's configuration file

lastmod

String

Indicates the timestamp (UTC) at which the asset was last modified.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

dur

Integer

Indicates the number of milliseconds from the asset that were included in the live channel.

Example:

A Live Slicer starts slicing an asset an hour before it is scheduled start time. If the Live Slicer's schedule entry is 30 minutes and it does not contain ads, then this property returns 1800000. if the Live Slicer is stopped or starts slicing a new asset immediately after the scheduled entry ends, then the actual_dur property returns 5400000.

actual_dur

Integer

Indicates the asset's duration in milliseconds.

end

String

Indicates the timestamp (UTC) at which the Live Slicer stopping sending a feed that contains this asset.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

external_id

String

Indicates the asset's external ID.

owner

String

Indicates the system-defined ID (i.e., user ID) assigned to the user that owns the asset.

start

String

Indicates the timestamp (UTC) at which the Live Slicer started sending a feed that contains this asset.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

from_schedule

Boolean

Indicates whether the asset was included in the live channel as a result of a schedule entry. Valid values are:

  • True: The asset was included in the live channel as a result of a scheduled Live Slicer.
  • False: The asset was included in the live channel for a time period during which an entry was not scheduled. This means that the asset's content was provided by the live channel's Live Slicer.

Sample Request/Response

Call the get_multiple_schedule_entries module (Python 3) to retrieve up to 500 entries scheduled within the next two hours. This module imports names from the api_auth module.

import 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 ScheduleEntry:   
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        self._get_multiple_schedule_entries()

    def _get_multiple_schedule_entries(self):
        start = int(time.time() * 1000.0) # Now
        end = start + (120 * 60 * 1000)  # 120 minutes later
        start = convert_ts(start)
        end = convert_ts(end)
        url = "{}{}{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules?start=", start, "&end=", end)

        headers = {'Content-Type': 'application/json'}

        response = requests.get(
            url, params=APIParams(APICredentials()).get_params({}), headers=headers
        )
  
        print(response.json())
  
ScheduleEntry().run()

Response:

{
	'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules?start=2021-02-15T22:58:10.835Z&end=2021-02-16T00:58:10.835Z',
	'@type': 'TimeSeries',
	'start': '2021-02-15T22:58:10.835Z',
	'end': '2021-02-16T00:58:10.835Z',
	'items': [{
			'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12',
			'@type': 'Schedule',
			'created': '2021-02-16T00:57:10.402Z',
			'lastmod': '2021-02-16T00:57:10.402Z',
			'id': '2158c7452b7841158972e019a5bd5f12',
			'owner': 'ab533864a92b46a1a286cdd49b0a9bd3',
			'content_id': 'ae071e89574248c2ab179fe73d436c3e',
			'content_type': 'asset',
			'desc': 'Sports Segment',
			'dur': 2343598,
			'external_id': '',
			'start': '2021-02-16T00:57:10.402Z',
			'end': '2021-02-16T01:36:14.000Z',
			'type': 'Time',
			'ad_breaks': []
		}
	]
}

Get Schedule Entry

Retrieves a specific schedule entry.

Information describing a scheduled entry is retained for 30 days after its end time.

You may not use this endpoint to retrieve placeholder schedule entries.

Request

Request syntax:

GET /channels/Live Channel ID/schedules/ID

Request syntax for a deleted schedule entry:

GET /channels/Live Channel ID/schedules/ID?include_deleted=1

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.

ID

Required

Identifies a schedule entry by either its system-defined or external ID.

Use the Get Multiple Schedule Entries endpoint to retrieve schedule entries and their IDs.

By default, attempting to retrieve a deleted schedule entry returns a 404 Not Found. Pass include_deleted=1 to retrieve data for a deleted schedule entry. The deleted response property is included for deleted schedule entries.

Authentication

Pass a digital signature based off of msg.

Learn more.

Response

The response for a successful request contains the following properties:

Name

Data Type

Description

@id

String

Indicates the relative path to an endpoint that returns this schedule entry.

You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-.

@type

String

Returns Schedule.

ad_breaks

List of integers

Indicates the duration for each ad break associated with the asset.

content_id

String

content_type: asset or slicer

Identifies an asset by its system-defined ID or a Live Slicer by the ID defined within the SlicerID setting of its Live Slicer configuration file.

content_owner

String

content_type: slicer Only

Identifies the user that owns the scheduled Live Slicer by its system-defined ID.

This property is only returned for Live Slicers that belong to another user.

content_type

String

Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are:

ad | asset | slicer | replay_source

created

String

Indicates the timestamp (UTC) at which the schedule entry was created.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

deleted

String

include_deleted=1 Only

Indicates the timestamp (UTC) at which the schedule entry was deleted.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

desc

String

Indicates the schedule entry's description. If the schedule entry does not have a description, then this property's value varies by the type of schedule entry.

  • Asset: Indicates the name assigned to the asset.
  • Ad Break: Returns Ad Break.
  • Slicer: Returns an empty string.

Schedule entries created through the CMS are not assigned a description.

dur

Integer

Indicates the schedule entry's duration in milliseconds.

end

String

Indicates the schedule entry's end time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

external_id

String

Indicates a schedule entry's custom ID.

id

String

Identifies a schedule entry by its system-defined ID.

lastmod

String

Indicates the timestamp (UTC) at which the schedule entry was last modified.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

offset

Integer

Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past.

Example:

An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000.

owner

String

Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry.

replaced_by

String

Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry.

replay_source String

content_type only

Specifies the time frame of the content that should be played.

Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end.

replay_source_end String

content_type: replay_source only

Specifies the time (UTC) the content should stop playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ
replay_source_start String

content_type: replay_source only

Specifies the time (UTC) the content should begin playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

start

String

Indicates the schedule entry's start time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

type

String

Indicates the type of schedule entry. Valid values are:

  • Time: Identifies an actual schedule entry.
  • Empty: Identifies a placeholder schedule entry that identifies a gap in the schedule.

Sample Request/Response

Call the get_schedule_entry module (Python 3) to retrieve a specific schedule entry. This module imports names from the api_auth module.

import requests
from api_auth import APICredentials, APIParams
channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel.
schedule_id = '2158c7452b7841158972e019a5bd5f12'  # Replace with the ID for the desired schedule entry.

class ScheduleEntry:   
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        self._get_schedule_entry()

    def _get_schedule_entry(self):
        url = "{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules/", schedule_id)

        headers = {'Content-Type': 'application/json'}

        response = requests.get(
            url, params=APIParams(APICredentials()).get_params({}), headers=headers
        )
  
        print(response.json())
  
ScheduleEntry().run()

Response:

{
	'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12',
	'@type': 'Schedule',
	'created': '2021-02-16T00:57:10.402Z',
	'lastmod': '2021-02-16T00:57:10.402Z',
	'id': '2158c7452b7841158972e019a5bd5f12',
	'owner': 'ab533864a92b46a1a286cdd49b0a9bd3',
	'content_id': 'ae071e89574248c2ab179fe73d436c3e',
	'content_type': 'asset',
	'desc': 'Sports Segment',
	'dur': 2343598,
	'external_id': '',
	'start': '2021-02-16T00:57:10.402Z',
	'end': '2021-02-16T01:36:14.000Z',
	'type': 'Time',
	'ad_breaks': []
}

Update Schedule Entry

Updates a specific schedule entry.

You may only update schedule entries that occur in the future. Current or past schedule entries may not be modified.

Request

Request syntax:

PATCH /channels/Live Channel ID/schedules/Schedule Entry ID

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.

Schedule Entry ID

Required

Identifies a schedule entry by its system-defined ID.

Use the Get Multiple Schedule Entries endpoint to retrieve schedule entries and their system-defined IDs.

Request body:

Define a schedule entry through the following properties:

Name

Data Type

Description

ad_breaks

List of integers

Determines the duration for each ad break associated with the asset.

Key information:

  • Define ad break duration in the order in which ad breaks appear in the asset.

    Example:

    The following configuration indicates that the asset contains four ad breaks. It sets the duration of the first and third ad break to 90 seconds and the second and fourth ad break to 120 seconds:

    'ad_breaks': [90, 120, 90, 120],
  • Specify a duration for each ad break associated with the asset.

    This endpoint returns an error when the number of ad breaks associated with the asset do not match the number of ad breaks defined in this list. An exception to this rule occurs if you are skipping all ad breaks by setting this property to an empty list.

  • Skip an ad break by setting its duration to 0.

    Example:

    The following configuration sets the duration of the first and last ad break to 90 seconds and skips the second ad break:

    'ad_breaks': [90, 0, 90],
  • Skip all ad breaks by omitting this property or setting it to an empty list.

conflict_resolution

String

Determines how scheduling conflicts are handled. Valid values are:

  • replace: Overwrite previously scheduled entries with the new entry being scheduled.

    Overwriting a schedule entry that is currently being streamed truncates it at the point-in-time defined by the new schedule entry's start time.

  • trim-start: Trim the beginning of the asset to fit within the current scheduling gap.

  • trim-end: Trim from the end of the asset to fit within the current scheduling gap.

Prevent previously scheduled entries from being overwritten by excluding this property from the request. Omitting this property causes our service to respond with a 409 Conflict when a scheduling conflict arises.

Trimming an asset can affect the number of ads served. Specifically, we will not serve ads for an ad break positioned within a portion of the asset that is trimmed.

content_id

String

content_type: asset or slicer

Identifies an asset by its system-defined ID or a Live Slicer by the ID defined within the SlicerID setting of its Live Slicer configuration file.

You may only schedule another user's Live Slicer if it is streaming to a library shared with your account.

content_owner

String

content_type: slicer Only

Identifies the user that owns the scheduled Live Slicer by its system-defined ID.

content_type

String

Determines whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are:

ad | asset | slicer | replay_source

desc

String

Defines the schedule entry's description.

dur

Integer

Determines the schedule entry's duration in milliseconds.

Key information:

  • This property is always required for scheduled ad breaks and Live Slicers.
  • A schedule entry's duration cannot exceed 12 hours.
  • content_type: asset Only

    • This property is required for scheduled assets when the ad_breaks property has been defined.
    • If the ad_breaks property has not been defined, then the default value for this property is the asset's duration.
    • Set a scheduled asset's duration to a value that is equal to or less than the sum of the asset's duration and all of its ad breaks. Ad break duration is determined by the ad_breaks property.

      Setting a duration that exceeds the sum of the asset's duration and all of its ad breaks generates an error.

      Example:

      The following payload indicates that the asset contains three 90 second ad breaks.

      'content_type': 'asset',

      'ad_breaks': [90, 90, 90],

      ...

      If the asset's duration is 25 minutes, then you should set dur to 1500270.

      (25 * 60 * 1000) + 90 + 90 + 90 = 1500270

external_id

String

Defines a schedule entry's custom ID.

overwrite

Deprecated

String

Determines how scheduling conflicts are handled.

The conflict_resolution property takes precedence over this deprecated property.

replaced_by

String

Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry.

replay_source String

content_type only

Specifies the time frame of the content that should be played.

Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end.

replay_source_end String

content_type: replay_source only

Specifies the time (UTC) the content should stop playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ
replay_source_start String

content_type: replay_source only

Specifies the time (UTC) the content should begin playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

start

String

Determines the schedule entry's start time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

Key information:

  • Missing content slate occurs when there is a gap between scheduled entries.

    Set a schedule entry's start time to the previous entry's end time to prevent missing content slate.

  • content_type: asset only

    A schedule entry's start time determines the point-in-time at which the asset will start streaming. If a schedule entry's start time is in the past, then the system behaves as if the asset had been streaming since the specified start time. This means that the portion of the video that occurred in the past is excluded from your live channel's feed.

    You may not schedule an asset so that it ends in the past. Ensure that an asset's duration is sufficient to extend into the future when scheduling in the past.

    Example:

    If you schedule an asset 45 seconds into the past, then your live channel's feed will start streaming 45 seconds into the asset. If the asset's duration is 30 minutes, then only 29 minutes and 15 seconds of that asset's content will be included in your live channel's feed. On the other hand, if the asset's duration is 30 seconds, then this endpoint returns an error indicating that a schedule entry cannot end in the past.

Authentication

Pass a digital signature based off of msg.

Learn more.

Response

The response for a successful request contains the following properties:

Name

Data Type

Description

@id

String

Indicates the relative path to an endpoint that returns this schedule entry.

You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-.

@type

String

Returns Schedule.

ad_breaks

List of integers

Indicates the duration for each ad break associated with the asset.

content_id

String

content_type: asset or slicer

Identifies an asset by its system-defined ID or a Live Slicer by the ID defined within the SlicerID setting of its Live Slicer configuration file.

content_owner

String

content_type: slicer Only

Identifies the user that owns the scheduled Live Slicer by its system-defined ID.

This property is only returned for Live Slicers that belong to another user.

content_type

String

Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are:

ad | asset | slicer | replay_source

created

String

Indicates the timestamp (UTC) at which the schedule entry was created.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

deleted

String

include_deleted=1 Only

Indicates the timestamp (UTC) at which the schedule entry was deleted.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

desc

String

Indicates the schedule entry's description. If the schedule entry does not have a description, then this property's value varies by the type of schedule entry.

  • Asset: Indicates the name assigned to the asset.
  • Ad Break: Returns Ad Break.
  • Slicer: Returns an empty string.

Schedule entries created through the CMS are not assigned a description.

dur

Integer

Indicates the schedule entry's duration in milliseconds.

end

String

Indicates the schedule entry's end time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

external_id

String

Indicates a schedule entry's custom ID.

id

String

Identifies a schedule entry by its system-defined ID.

lastmod

String

Indicates the timestamp (UTC) at which the schedule entry was last modified.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

offset

Integer

Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past.

Example:

An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000.

owner

String

Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry.

replaced_by

String

Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry.

replay_source String

content_type only

Specifies the time frame of the content that should be played.

Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end.

replay_source_end String

content_type: replay_source only

Specifies the time (UTC) the content should stop playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ
replay_source_start String

content_type: replay_source only

Specifies the time (UTC) the content should begin playing.

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

start

String

Indicates the schedule entry's start time (UTC).

Syntax (ISO 8601):

YYYY-MM-DDThh:mm:ss.sssZ

type

String

Indicates the type of schedule entry. Valid values are:

  • Time: Identifies an actual schedule entry.
  • Empty: Identifies a placeholder schedule entry that identifies a gap in the schedule.

 

Sample Request/Response

Call the update_schedule_entry module (Python 3) to update a schedule entry. 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.
schedule_id = '2158c7452b7841158972e019a5bd5f12'  # Replace with the ID for the desired schedule entry.

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 ScheduleEntry:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Update a schedule entry.
        """
        self._update_schedule_entry()

    def _update_schedule_entry(self):
        url = "{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules/", schedule_id)

        start = int((time.time() + 7200) * 1000.0) # 2 hours from now
        start = convert_ts(start)

        payload = {            
            'start': start
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.patch(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

ScheduleEntry().run()

Response:

{
	'@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12',
	'@type': 'Schedule',
	'created': '2021-02-16T00:57:10.402Z',
	'lastmod': '2021-02-16T00:57:10.402Z',
	'id': '2158c7452b7841158972e019a5bd5f12',
	'owner': 'ab533864a92b46a1a286cdd49b0a9bd3',
	'content_id': 'ae071e89574248c2ab179fe73d436c3e',
	'content_type': 'asset',
	'desc': 'Sports Segment',
	'dur': 2343598,
	'external_id': '',
	'start': '2021-02-16T00:57:10.402Z',
	'end': '2021-02-16T01:36:14.000Z',
	'type': 'Time',
	'ad_breaks': []
}