

# Working with the schedule (AWS CLI)
<a name="schedule-using-cli"></a>

You can use the AWS CLI to work with the schedule programmatically. The sections later in this chapter describe how to enter the appropriate commands. These sections assume that you are familiar with the basics of using the AWS CLI. For information about the basics, see the [AWS CLI Command Reference](https://docs.aws.amazon.com/cli/latest/reference/). 

The following sections describe each command and provide this additional information:
+ A description of the AWS CLI command syntax.
+ A description of the schema for the request or response JSON payload. This payload is shown using the syntax for the AWS CLI. 
+ An example of the request or response JSON payload. This payload is also shown using the syntax for the AWS CLI.

For details on the JSON contents, we recommend that you read the [AWS Elemental MediaLive API Reference](https://docs.aws.amazon.com/medialive/latest/apireference/). This guide is easy to use because it includes links from elements in the JSON payload to tables that describe the element. But you must adjust the syntax of the elements in the JSON code because the AWS CLI uses one form of capitalization for elements (for example, `SubSegmentNum`) and the API uses another form (for example, `subSegmentNum`). 

**Topics**
+ [Creating and deleting using a batch command](about-batch-update-schedule.md)
+ [Submitting a batch update schedule command](submitting-batch-command.md)
+ [JSON payload for create actions](schedule-create-json.md)
+ [JSON payload for delete actions](cli-schedule-delete-json.md)
+ [JSON payload for combining create and delete](schedule-create-and-delete-json.md)
+ [Viewing the schedule (AWS CLI)](viewing-schedule-using-cli.md)

# Creating and deleting using a batch command
<a name="about-batch-update-schedule"></a>

To create and delete actions in the schedule for a channel, you use the batch update schedule command. This command lets you perform multiple actions in one request. There isn't one command for creating actions and another for deleting actions.

**Important**  
When working with a started and running channel, use the **batch-update-schedule** command to add or remove actions. Use the **delete-schedule** command only on idle channels. The **delete-schedule** command will delete all scheduled actions and could cause service interruptions if used on a live channel. 

You can use the command as follows:
+ Submit a *single* request such as a request to do the following:
  + Create one action.
  + Delete one action.
+ Submit a *batch* request such as one request to do the following:
  + Create several actions.
  + Delete several actions.
  + Create one or more actions and delete one or more actions.

**Important**  
In a command that combines create actions and delete actions, the delete actions are *always* performed before the create actions. This means that MediaLive removes the delete actions from the schedule before it adds the create actions to the schedule.

**Topics**
+ [How a batch request works](how-batch-schedule-requests-work.md)
+ [Batch command in different interfaces](batchupdatecommand-interfaces.md)
+ [JSON payload in different interfaces](batchupdatecommand-payloads.md)

# How a batch request works
<a name="how-batch-schedule-requests-work"></a>

The intention of batching is to pass or fail all the actions together. Therefore, AWS Elemental MediaLive validates batch actions together. MediaLive performs the following validation:
+ It ensures that each action that is created or deleted has an explicit or implied start time that is at least 15 seconds in the future. 
+ If an action refers to an existing action in the schedule, it ensures that the reference to the existing action is correct. For example, a follow input switch includes a reference to the action that it follows. That action must exist.

If the validation fails for any one action, it fails for all the actions in the batch.

If you don't want the actions to pass or fail together, don't submit a batch. Instead, create each action in its own batch update schedule command.

If the validation succeeds, MediaLive processes all the delete requests before the create requests, regardless of the start times of the actions.

**Example 1**  
An important use of batching is to perform several actions that must pass or fail together. For example, suppose that you want to remove the corporate logo and immediately insert a splice\$1insert (in order to go to an ad avail). To do that, you must create an action to remove the logo and another action to insert the splice\$1insert. However, you don't want MediaLive to insert the remove action if the splice\$1insert action fails, or vice versa. It's better if both actions fail because that allows you to fix the badly formed action, and then submit both actions again.

You therefore submit the two actions together, in one batch update schedule command. 

**Example 2**  
Another important use of batching is to fix an error in an action in the schedule. For example, you might want to fix an image overlay that hasn't started yet and that was created with the wrong start time. To do that, you submit one batch update schedule command with JSON that contains the following:
+ A payload to remove the original action to activate the image overlay. This action has the incorrect start time.
+ A payload to add a new action to activate the same image overlay. This action has the correct start time.

# Batch command in different interfaces
<a name="batchupdatecommand-interfaces"></a>

The batch update schedule command is represented differently in different interfaces: 
+ In the AWS CLI, the command is `batch-update-schedule`.
+ In the API, the command is represented by an `HTTP PUT` on `channels/channelId/schedule`.
+ In the AWS SDKs, the command is represented by constructs that are suitable to that SDK language.

# JSON payload in different interfaces
<a name="batchupdatecommand-payloads"></a>

The JSON payload for the command is different for the different interfaces:
+ In the AWS CLI, the contents of the payload depend on how you use the command:
  + You can enter a command with two parameters: `channel-id` and `--cli-input-json`. In this case, you create a file that repeats the channel ID and includes the JSON payload. 
  + You can enter a command with three parameters: one for the channel ID, one for the JSON payload for the create actions (if applicable), and one for the JSON payload for the delete actions (if applicable). You pass the payloads in the command. If both parameters are present, each parameter takes a separate payload. But the two payloads are validated and performed as a batch. 

  The payload for the AWS CLI is always pascal case (upper camel case). 
+ In the API, there is one payload with two sections, a `CREATES` section and a `DELETES` section. A request can contain one or both sections. 

  The payload for the API is always camel case for variable names and pascal case for classes.
+ In the AWS SDKs, the JSON payload is represented by constructs that are suitable to that SDK language. 

To get more familiar with individual actions, we recommend that you use the MediaLive console to create an action. After you create the action, use the [DescribeSchedule](viewing-schedule-using-cli.md) command in the appropriate interface (for example, the AWS CLI or an SDK) to obtain the raw JSON payload for the entire schedule. You can then copy individual actions and save them as models to use when working programmatically.

# Submitting a batch update schedule command
<a name="submitting-batch-command"></a>

The command for a batch update schedule command is identical for creating actions, deleting actions, or submitting a combination of create and delete actions. The command is identical. Only the contents of the JSON payload differ.

There are different ways to enter the command to create an action. We recommend that you follow this usage:
+ Enter the command with two parameters: `channel-id` and `--cli-input-json`. In this case, you create a file that repeats the channel ID and includes the JSON payload. 

The instructions and examples in this section illustrate this usage. 

The following general rules apply to batch update commands:
+ You can create actions when the channel is running or when it is idle. 
+ You can create any number of actions in one request, or any combination of types of actions in one request. For example, you can mix the creation of SCTE 35 message actions and image overlay actions. 
+ If you create several actions in one request and one of the create requests fails (usually because the start time isn't sufficiently in the future), then they all fail.

The following rules apply to delete actions:
+ You can delete an action when the channel is running or when it is idle. 
+ You can delete any number of actions in one request, or any combination of types of actions in one request. For example, you can mix the deletion of SCTE 35 message actions and image overlay actions. 
+ If you delete several actions in one request and one of the delete requests fails (usually because the start time isn't sufficiently in the future), then they all fail.

**To submit a batch command**

1. Before you add or delete actions, read [Creating actions in the schedule (console)](schedule-using-console-create.md) and [Deleting actions from the schedule (console)](schedule-using-console-delete.md).

1. Prepare a file that contains the channel ID and the appropriate JSON payload for the actions. For the structure and examples of the JSON payload for different actions, see the sections that follow. 

1. Give the file a suitable name with a `.txt` extension. For example, the file name for a payload that creates only actions might be `schedule-create-actions.txt`. 

1. Save the file to the folder where you are running the AWS CLI.

1. On the command line, enter this command:

   `AWS medialive batch-update-schedule --channel-id value --cli-input-json value`
   + In the value for `--channel-id`, enter the channel ID as a number.
   + In the value for `--cli-input-json`, enter the file name in this format:

     `file://filename.txt`

   For example: 

   `aws medialive batch-update-schedule --channel-id 999999 --cli-input-json schedule-create-actions.txt`

1. To submit the command, press **Enter**. The response appears on the screen. The response repeats the data from the request.

# JSON payload for create actions
<a name="schedule-create-json"></a>

The following sections show the structure of the payload and an example of the payload for every type of create action for a MediaLive schedule.

**Topics**
+ [Input switch action – payload](cli-schedule-fields-for-input-switch.md)
+ [Input prepare action – payload](cli-schedule-fields-for-input-prep.md)
+ [Activate global image action – payload](cli-schedule-fields-for-activate-image.md)
+ [Deactivate global overlay action – payload](cli-schedule-fields-for-deactivate-image.md)
+ [Activate per-outputs image action – payload](cli-schedule-fields-for-activate-image-per-output.md)
+ [Deactivate per-outputs overlay action – payload](cli-schedule-fields-for-deactivate-image-per-output.md)
+ [Activate motion graphic overlay – payload](cli-schedule-fields-activate-mgi.md)
+ [Deactivate motion graphic overlay – payload](cli-schedule-fields-deactivate-mgi.md)
+ [Splice\$1insert message – payload](cli-schedule-fields-for-splice-insert.md)
+ [Time\$1signal message – payload](cli-schedule-fields-for-time-signal.md)
+ [Return-to-network message – payload](cli-schedule-fields-for-return-network.md)
+ [ID3 metadata item – payload](cli-schedule-fields-for-id3.md)
+ [ID3 segment tag item – payload](cli-schedule-fields-id3-segment-tag.md)
+ [Pause pipeline action – payload](cli-schedule-fields-for-pause.md)
+ [Combination of create actions](cli-example-multiple-creates.md)

# Input switch action – payload
<a name="cli-schedule-fields-for-input-switch"></a>

The following sections show the payload for input switch actions. 

In this payload, the `ScheduleActionStartSettings` contains only one of `FixedModeScheduleActionStartSettings`, `ImmediateModeScheduleActionStartSettings`, or `FollowModeScheduleActionStartSettings`.

See the examples that follow for samples of each of these tags.

For information about the meaning and values for the fields in the following JSON, see [Fields for an input switch](schedule-fields-for-ips.md).

```
{
"ChannelId": "string",
"Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "FollowModeScheduleActionStartSettings": {
     "FollowPoint": "enum",
     "ReferenceActionName": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "InputSwitchSettings": {
     "InputAttachmentNameReference": "string",
     "InputClippingSettings": {
      "InputTimecodeSource": "enum",
      "StartTimecode": {
       "Timecode": "string"
      },
      "StopTimecode": {
       "LastFrameClippingBehavior": "enum",
       "Timecode": "string"
      }
     },
     "UrlPath": ["string", ...]
    }
   }
  ]
 }
}
```

## Example of a switch to a live input with fixed start time
<a name="json-switch-example-1"></a>

This example of a request is to switch to a live input at a fixed start time. The switch action is called `studio-feed` and it switches to the input that is connected to the input attachment called `live-studio-feed`. It switches to this input at the specified UTC time. 

```
{
  "ChannelId": "999999",
  "Creates": {
    "ScheduleActions": [
      {
       "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:19.000Z"
           }
          },
      "ActionName": "studio-feed",
      "ScheduleActionSettings": {
        "InputSwitchSettings": {
          "InputAttachmentNameReference": "live-studio-feed" 
     }
    }
   }
  ]
 }
}
```

## Example of a static file switch as a follow
<a name="json-switch-example"></a>

This example of a request is to switch to a static file input to follow the end of the previous input. The switch action is called `action-ad-003` and it switches to the input that is connected to the input attachment called `zel-cafe`. It switches to this input when the action called `action-ad-002` ends. The file for this action is clipped so that it ends after 30 seconds and 11 frames:

```
{
  "ChannelId": "999999",
  "Creates": {
      "ScheduleActions": [
          {
            "ScheduleActionStartSettings": {
              "FollowModeScheduleActionStartSettings": {
                "FollowPoint": "END",
                "ReferenceActionName": "action-ad-002"
              }
            },
            "ActionName": "action-ad-003",
              "ScheduleActionSettings": {
                 "InputSwitchSettings": {
                    "InputAttachmentNameReference": "zel-cafe",
                      "InputClippingSettings": {
                          "InputTimecodeSource": "ZEROBASED",
               "StopTimecode":{
                 "Timecode": "00:00:30:11",
                 "LastFrameClippingBehavior": "INCLUDE_LAST_FRAME"
       }
      }
     }
    }
   }
  ]
 }
}
```

## Example of a switch to a dynamic input with immediate start time
<a name="json-switch-example2"></a>

This example of a request is to switch to a dynamic file input immediately. The switch action is called `action-unscheduled-standby` and it switches to the input that is connected to the input attachment called `dynamic-unscheduled-standby`. For this usage of the dynamic input, the files to use are `oceanwaves.mp4`.

```
{
  "ChannelId": "999999",
  "Creates": {
    "ScheduleActions": [
      {
        "ScheduleActionStartSettings": 
          {
          "ImmediateModeScheduleActionStartSettings": {
          }
         },
       "ActionName": "action-unscheduled-slate",
        "ScheduleActionSettings": {
          "InputSwitchSettings": {
            "InputAttachmentNameReference": "slate",
            "UrlPath":[
              "main/oceanwaves.mp4",
              "redundant/oceanwaves.mp4"]
     }
    }
   }
  ]
 }
}
```

# Input prepare action – payload
<a name="cli-schedule-fields-for-input-prep"></a>

The following sections show the payload for input switch actions. 

In this payload, the `ScheduleActionStartSettings` contains only one of `FixedModeScheduleActionStartSettings`, `ImmediateModeScheduleActionStartSettings`, or `FollowModeScheduleActionStartSettings`.

See the examples that follow for samples of each of these tags.

For information about the meaning and values for the fields in the following JSON, see [Fields for an input switch](schedule-fields-for-ips.md).

```
{
"ChannelId": "string",
"Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "FollowModeScheduleActionStartSettings": {
     "FollowPoint": "enum",
     "ReferenceActionName": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "InputPrepareSettings": {
     "InputAttachmentNameReference": "string",
     "InputClippingSettings": {
      "InputTimecodeSource": "enum",
      "StartTimecode": {
       "Timecode": "string"
      },
      "StopTimecode": {
       "LastFrameClippingBehavior": "enum",
       "Timecode": "string"
      }
     },
     "UrlPath": ["string", ...]
     }
    }
   }
  ]
 }
}
```

## Example of an input prepare with a fixed start time
<a name="json-prep-example-1"></a>

This example of a request is to switch to a live input at a fixed start time. The switch action is called `studio-feed` and it switches to the input that is connected to the input attachment called `live-studio-feed`. It switches to this input at the specified UTC time. 

```
{
  "ChannelId": "999999",
  "Creates": {
    "ScheduleActions": [
      {
       "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:19.000Z"
           }
          },
      "ActionName": "studio-feed",
      "ScheduleActionSettings": {
        "InputSwitchSettings": {
          "InputAttachmentNameReference": "live-studio-feed"
     }
    }
   }
  ]
 }
}
```

## Example of an input prepare as a follow
<a name="json-prep-example-2"></a>

This example of a request is to switch to a static file input to follow the end of the previous input. The switch action is called `action-ad-003` and it switches to the input that is connected to the input attachment called `zel-cafe`. It switches to this input when the action called `action-ad-002` ends. The file for this action is clipped so that it ends after 30 seconds and 11 frames:

```
{
  "ChannelId": "999999",
  "Creates": {
      "ScheduleActions": [
          {
            "ScheduleActionStartSettings": {
              "FollowModeScheduleActionStartSettings": {
                "FollowPoint": "END",
                "ReferenceActionName": "action-ad-002"
              }
            },
            "ActionName": "action-ad-003",
              "ScheduleActionSettings": {
                 "InputSwitchSettings": {
                    "InputAttachmentNameReference": "zel-cafe",
                      "InputClippingSettings": {
                          "InputTimecodeSource": "ZEROBASED",
               "StopTimecode":{
                 "Timecode": "00:00:30:11",
                 "LastFrameClippingBehavior": "INCLUDE_LAST_FRAME"
              }
            }
          }
        }
      }
    ]
  }
}
```

# Activate global image action – payload
<a name="cli-schedule-fields-for-activate-image"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for activating a global image overlay](schedule-fields-for-activate-image.md).

```
{
"ChannelId": "string",
"Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "StaticImageActivateSettings": {
     "Duration": integer,
     "FadeIn": integer,
     "FadeOut": integer,
     "Height": integer,
     "Image": {
      "PasswordParam": "string",
      "Uri": "string",
      "Username": "string"
     },
     "ImageX": integer,
     "ImageY": integer,
     "Layer": integer,
     "Opacity": integer,
     "Width": integer
     }
    }
   }
  ]
 }
}
```

## Example
<a name="json-activate-image-example"></a>

This example of a request creates an image overlay to be inserted in every video output in every output group in the channel. The overlay uses a file that is stored in an Amazon S3 bucket. The request doesn't include a duration and therefore doesn't include a fadeout. Instead, the intention is to send a separate deactivate request at the appropriate time. All the times are in milliseconds, and all the positioning values are in pixels:

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        "FixedModeScheduleActionStartSettings": {
          "Time": "2018-05-21T20:42:19.000Z"
        }
      },
      "ActionName": "corporate-logo-030",
      "ScheduleActionSettings": {
        "StaticImageActivateSettings": {
          "Image": {
          "PasswordParam": "corplogo!2312",
          "Uri": "s3ssl://amzn-s3-demo-bucket/logos/corporate/high-res.bmp",
          "Username": "medialiveoperator"
          },
          "Layer": 1,
          "FadeIn": 1500,
          "Height": 900
          "Width": 800,
          "ImageX": 200,
          "ImageY": 300,
          "Opacity": 60,
          }
        }
      }
    ]
  }
}
```

# Deactivate global overlay action – payload
<a name="cli-schedule-fields-for-deactivate-image"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for deactivating a global image overlay](schedule-fields-for-deactivate-image.md).

```
{
 "ChannelId": "string",
 "Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "StaticImageDeactivateSettings": {
     "FadeOut": integer,
     "Layer": integer
    }
   }
  }
 ]
}
```

## Example
<a name="json-deactivate-image-example"></a>

This example of a request creates an action to remove an image overlay at 20:42:04.000 (UTC) with a 500-millisecond fadeout that is added onto the end time, which means that the overlay will be invisible at 20:42:04.500. 

The action removes the images overlay that is in the global layer 4. This means it removes the image *only if* it was inserted using the global action (StaticImageActivateSettings). It doesn't remove the overlay from the per-outputs layer 4. 

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        "FixedModeScheduleActionStartSettings": {
          "Time": "2018-05-21T20:42:04.000Z"
        }
      },
      "ActionName": "stop-overlay-029",
      "ScheduleActionSettings": {
        "StaticImageDeactivateSettings": {
          "FadeOut": 500,
          "Layer": 4
          }
        }
      }
    ]
  }
}
```

# Activate per-outputs image action – payload
<a name="cli-schedule-fields-for-activate-image-per-output"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for activating a per-outputs image overlay](schedule-fields-activate-image-per-output.md).

```
{
"ChannelId": "string",
"Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "StaticImageOutputActivateSettings": {
     "Duration": integer,
     "FadeIn": integer,
     "FadeOut": integer,
     "Height": integer,
     "Image": {
      "PasswordParam": "string",
      "Uri": "string",
      "Username": "string"
     },
     "ImageX": integer,
     "ImageY": integer,
     "Layer": integer,
     "Opacity": integer,
     "OutputNames": [
       {}
      ],
     "Width": integer
     }
    }
   }
  ]
 }
}
```

## Example
<a name="json-deactivate-image-per-output-example"></a>

This example of a request creates an image overlay to be inserted in specific outputs in the channel. The overlay uses a file that is stored in an Amazon S3 bucket. The request inserts the image in the outputs `hls-high-res` and `mss-high-res`. The image is sized appropriately for the video resolution in these outputs. 

The request is intended to be always present. Therefore, it is set up to start immediately (as soon as the channel starts). All the times are in milliseconds, and all the positioning values are in pixels:

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
        "ScheduleActionStartSettings": 
          {
          "ImmediateModeScheduleActionStartSettings": {
          }
         },
      },
      "ActionName": "logo-1280",
      "ScheduleActionSettings": {
        "StaticImageOutputActivateSettings": {
          "Image": {
          "PasswordParam": "corplogo!2312",
          "Uri": "s3ssl://amzn-s3-demo-bucket/logos/corporate/10percent-1280.bmp",
          "Username": "medialiveoperator"
          },
          "Layer": 0,
          "outputNames": [
            hls-high-res,mss-high-res
           ],
          "ImageX": 200,
          "ImageY": 300,
          "FadeIn": 1500,
          "Opacity": 60
          }
        }
      }
    ]
  }
}
```

# Deactivate per-outputs overlay action – payload
<a name="cli-schedule-fields-for-deactivate-image-per-output"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for deactivating a per-outputs image overlay](schedule-fields-deactivate-image-per-output.md).

```
{
 "ChannelId": "string",
 "Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "StaticImageOutputDeactivateSettings": {
     "FadeOut": integer,
     "Layer": integer,
     "OutputNames"
    }
   }
  }
 ]
}
```

## Example
<a name="cli-schedule-fields-for-deactivate-image-per-output-example"></a>

The deactivate action deactivates the image in the specified per-output layer, in the specified output or outputs.

In this example, which follows on from the activate example, the action removes all image overlays that are in per-outputs layer 4 in the output hls-high-res. 

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        "FixedModeScheduleActionStartSettings": {
          "Time": "2018-05-21T20:42:04.000Z"
        }
      },
      "ActionName": "stop-layer4-all-outputs",
      "ScheduleActionSettings": {
        "StaticImageOutputDeactivateSettings": {
          "outputNames": [
            hls-high-res
           ],
          "FadeOut": 500,
          "Layer": 4
          }
        }
      }
    ]
  }
}
```

# Activate motion graphic overlay – payload
<a name="cli-schedule-fields-activate-mgi"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for activating a motion graphics overlay](schedule-fields-for-mg.md).

```
{
 "ChannelId": "string",
 "Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "MotionGraphicsImageActivateSettings": {
     "Duration": integer
     "Url": "string"
     "Username": "string",
     "PasswordParam": "string"
    }
   }
  ]
 }
}
```

## Example
<a name="json-activate-mgi-example"></a>

This example of a request creates a motion graphics overlay action called mg\$1ticker\$1tape. The motion graphic asset is stored at http://example.com/ticker\$1tape.html. This server requires user credentials. The request doesn't include a duration. Instead, the intention is to send a separate deactivate request at the appropriate time. 

```
{
"ChannelId": "999999",
"Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "2018-05-21T20:42:04.000Z"
    }
   },
   "ActionName": "mg_ticker_tape",
   "ScheduleActionSettings": {
    "MotionGraphicsImageActivateSettings": {
     "Url": "https://example.com/ticker_tape.html"
     "Username": "medialiveoperator",
     "PasswordParam": "/medialive/12345"
    }
   }
  ]
 }
}
```

# Deactivate motion graphic overlay – payload
<a name="cli-schedule-fields-deactivate-mgi"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for deactivating a motion graphics overlay](schedule-fields-for-mg-deactivate.md).

```
{
"ChannelId": "string",
"Creates": {
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "MotionGraphicsImageDeactivateSettings": {
     }
    }
   }
  ]
 }
}
```

## Example
<a name="json-deactivate-mgi-example"></a>

This example of a request creates an action to end a motion graphic overlay at 23:59:00.000 (UTC). :

```
{
"ChannelId": "999999",
"Creates": {
 "ScheduleActions": [
  {
  "ScheduleActionStartSettings": {
   "FixedModeScheduleActionStartSettings": {
   "Time": "2018-05-21T23:59:00.000Z"
   },
   "ActionName": "deactivate-ticker-tape",
   "ScheduleActionSettings": {
    "MotionGraphicsImageDeactivateSettings": {
     }
    }
   }
  ]
 }
}
```

# Splice\$1insert message – payload
<a name="cli-schedule-fields-for-splice-insert"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for a splice\$1insert message](schedule-fields-for-splice_insert.md).

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "FollowModeScheduleActionStartSettings": {
     "FollowPoint": "enum",
     "ReferenceActionName": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "Scte35SpliceInsertSettings": {
     "Duration": integer,
     "SpliceEventId": integer
    }
   }
  }
 ]
}
```

## Example of a splice insert with a fixed start time
<a name="json-splice-insert-example"></a>

This example of a request creates an action for a splice\$1insert with a UTC start time of 20:42:04.000. It also has an `ActionName` that perhaps references an ad avail from your database, a unique integer for the splice event ID, and a duration of 1,350,000 kHz ticks (15 seconds).

```
{
  "ChannelId": "999999",
  "Creates": {
    "ScheduleActions": [
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:04.000Z"
          }
        },
      "ActionName": "adavail-3708",
      "ScheduleActionSettings": {
        "Scte35SpliceInsertSettings": {
          "SpliceEventId": 3708,
          "Duration": 1350000
          }
        }
      }
    ]
  }
}
```

## Example of a splice insert as a follow
<a name="json-splice-insert-example2"></a>

This example of a request creates an action for a splice\$1insert to be inserted after the input switch called nature-doco-003 ends. The action has an `ActionName` that perhaps references an ad avail from your database, a unique integer for the splice event ID, and a duration of 1,350,000 kHz ticks (15 seconds).

Follow mode for a SCTE 35 message is useful when you want an ad avail to occur as soon as an input finishes, but you don't know when that will happen. 

```
{
  "ChannelId": "999999",
  "Creates": {
    "ScheduleActions": [
      {
        "ScheduleActionStartSettings": {
         "FollowModeScheduleActionStartSettings": {
                "FollowPoint": "END",
                "ReferenceActionName": "nature-doco-003"
        }
      },
      "ActionName": "adavail-3708",
      "ScheduleActionSettings": {
        "Scte35SpliceInsertSettings": {
          "SpliceEventId": 3708,
          "Duration": 1350000
          }
        }
      }
    ]
  }
}
```

# Time\$1signal message – payload
<a name="cli-schedule-fields-for-time-signal"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for a time\$1signal message](schedule-fields-for-time-signal.md).

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "FollowModeScheduleActionStartSettings": {
     "FollowPoint": "enum",
     "ReferenceActionName": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "Scte35TimeSignalSettings": {
     "Scte35Descriptors": [
      {
       "Scte35DescriptorSettings": {
        "SegmentationDescriptorScte35DescriptorSettings": {
         "DeliveryRestrictions": {
          "ArchiveAllowedFlag": "enum",
          "DeviceRestrictions": "enum",
          "NoRegionalBlackoutFlag": "enum",
          "WebDeliveryAllowedFlag": "enum"
         },
         "SegmentNum": integer,
         "SegmentationCancelIndicator": "enum",
         "SegmentationDuration": integer,
         "SegmentationEventId": integer,
         "SegmentationTypeId": integer,
         "SegmentationUpid": "string",
         "SegmentationUpidType": integer,
         "SegmentsExpected": integer,
         "SubSegmentNum": integer,
         "SubSegmentsExpected": integer
        }
       }
      }
     ]
    }
   }
  }
 ]
}
```

## Example
<a name="json-time-signal-example"></a>

This example of a request creates an action for a time\$1signal with a UTC start time of 20:42:04.000 and with a unique integer for `SegmentationEventId`. For the restrictions fields, `NoRegionalBlackoutFlag` has a restriction set (regional blackouts are in place).

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        "FixedModeScheduleActionStartSettings": {
          "Time": "2018-05-21T20:42:04.000Z"
        }
      },
      "ActionName": "adavail-3708",
      "ScheduleActionSettings": {
        "Scte35TimeSignalSettings": {
          "Scte35Descriptors": [
          {
            "Scte35DescriptorSettings": {
              "SegmentationDescriptorScte35DescriptorSettings": {
                "SubSegmentsExpected": 0,
                "SegmentationEventId": 7054,
                "SegmentationDuration": 1350000,
                "SegmentationCancelIndicator": 0,
                "SubSegmentNum": 0,
                "SegmentationUpidType": 12,
                "SegmentNum": 0,
                "SegmentationCancelIndicator": "SEGMENTATION_EVENT_NOT_CANCELED",
                "DeliveryRestrictions": {
                  "DeviceRestrictions": "NONE",
                  "WebDeliveryAllowedFlag": "WEB_DELIVERY_ALLOWED",
                  "NoRegionalBlackoutFlag": "REGIONAL_BLACKOUT",
                  "ArchiveAllowedFlag": "ARCHIVE_ALLOWED"
                },
                "SegmentationUpid": "4a414e3136494e4155303031",
                "SegmentationTypeId": 52,
                "SegmentsExpected": 0
                  }
                }
              }
            ]
          }
        }
      }
    ]
  }
}
```

# Return-to-network message – payload
<a name="cli-schedule-fields-for-return-network"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for a return-to-network message](schedule-fields-for-return-to-network.md).

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "FollowModeScheduleActionStartSettings": {
     "FollowPoint": "enum",
     "ReferenceActionName": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "Scte35ReturnToNetworkSettings": {
     "SpliceEventId": integer                
    }
   }
  }
 ]
}
```

## Example
<a name="json-return-network-example"></a>

This example of a request creates a return-to-network with a UTC start time of 20:42:19.

```
{
  "ChannelId": "999999",
  "Creates": {
    "ScheduleActions": [
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:19.000Z"
          }
      },
      "ActionName": "end-adavail-3708",
      "ScheduleActionSettings": {
        "Scte35ReturnToNetworkSettings": {
          }
        }
      }
    ]
  }
}
```

# ID3 metadata item – payload
<a name="cli-schedule-fields-for-id3"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for ID3 metadata](schedule-fields-for-id3-userdata.md).

**Payload for the HlsTimedMetadataSettings action**

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
     "HlsTimedMetadataSettings": {
     "Id3": "string"
    }
   }
  }
 ]
}
```

**Payload for the TimedMetadataSettings action**

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
     "TimedMetadataSettings": {
     "Id3": "string"
    }
   }
  }
 ]
}
```

## Example
<a name="json-id3-example"></a>

This example of a request uses the `HlsTimedMetadataSettings` action. It creates ID3 metadata to be inserted in a appropriate output groups at 13:35:59 UTC.

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        "FixedModeScheduleActionStartSettings": {
          "Time": "2019-01-02T13:35:59Z"
        }
      },
      "ActionName": "id3-metadata.2019-01-02T13:35:59Z",
      "ScheduleActionSettings": {
        "HlsTimedMetadataSettings": {
          "Id3": "SUQzBAAAAAAAF1RJVDIAAAANAAADSGVsbG8gV29ybGQA"
          }
        }
      }
    ]
  }
}
```

# ID3 segment tag item – payload
<a name="cli-schedule-fields-id3-segment-tag"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for ID3 segment tags](schedule-fields-for-id3-segment-tags.md).

**Payload for the HlsId3SegmentTaggingSettings action**

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
	"HlsId3SegmentTaggingSettings": {
         "Tag": "string"
         "Id3": "string"
    }
   }
  }
 ]
}
```

**Payload for the Id3SegmentTaggingSettings action**

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
	"Id3SegmentTaggingSettings": {
         "Tag": "string"
         "Id3": "string"
    }
   }
  }
 ]
}
```

## Example using the tag property
<a name="json-id3-segment-example"></a>

This example of a request uses the `HlsId3SegmentTaggingSettings` action. It creates an ID3 segment tag to be inserted starting at 13:35:59 UTC. This example uses the `Tag` property , which means that you specify only the content of the `value` for the `TXXX` field. In this example, the content is the date, time, and number of the segment. 

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        "FixedModeScheduleActionStartSettings": {
          "Time": "2020-01-02T13:35:59Z"
        }
      },
      "ActionName": "id3-datetime-and-segment",
      "ScheduleActionSettings": {
        "HlsId3SegmentTaggingSettings": {
          "Tag": "$dt$-$sn$"
          }
        }
      }
    ]
  }
}
```

## Example using the Id3 property
<a name="json-ide-segment-id3-example"></a>

This example of a request creates an ID3 segment tag to be inserted immediately. This example uses the `Id3` property, which means that the content is encoded as base64.

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        ImmediateModeScheduleActionStartSettings
       }
      },
      "ActionName": "id3-song309",
      "ScheduleActionSettings": {
        "HlsId3SegmentTaggingSettings": {
          "Id3": "SUQzBAAAAAAAF1RJVDIAAAANAAADSGVsbG8gV29ybGQA"
          }
        }
      }
    ]
  }
}
```

# Pause pipeline action – payload
<a name="cli-schedule-fields-for-pause"></a>

For information about the meaning and values for the fields in the following JSON, see [Fields for pause](schedule-fields-for-pause.md).

```
{
 "ScheduleActions": [
  {
   "ScheduleActionStartSettings": {
    "FixedModeScheduleActionStartSettings": {
     "Time": "string"
    },
    "ImmediateModeScheduleActionStartSettings": {
    }
   },
   "ActionName": "string",
   "ScheduleActionSettings": {
    "PauseStateSettings": {
     "Pipelines": [
      {
       "PipelineId": "enum"
      }
     ]
    }
   }
  }
 ]
}
```

## Example: Pausing one pipeline
<a name="json-pause-example"></a>

This example of a request pauses pipeline 0 at 20:42:19 UTC. MediaLive always reads the command as:*set the specified pipeline or pipelines to pause and set all other pipelines to unpaused.*

```
{
  "ChannelId": "999999",
  "Creates": {
    "ScheduleActions": [
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:19Z"
          }
        },
        "ActionName": "pause-pipeline-0-now",
        "ScheduleActionSettings": {
          "PauseStateSettings": {
            "Pipelines": [
              {
                "PipelineId": "PIPELINE_0"
              }
            ]
          }
        }
      }
    ]
  }
}
```

## Example: Unpausing both pipelines
<a name="json-unpause-example"></a>

This example of a request unpauses all pipelines that are currently paused. 

**Note**  
MediaLive always reads the command as:*set the specified pipeline or pipelines to pause and set all other pipelines to unpaused.* In this example, the `Pipelines` array is empty. MediaLive interprets this empty array as: *set all pipelines to unpaused*.

```
{
 "ChannelId": "999999",
 "Creates": {
     "ScheduleActions": [
      {
       "ScheduleActionStartSettings": {
         "ImmediateModeScheduleActionStartSettings": {}
      },
     "ActionName": "unpause-pipeline-0",
     "ScheduleActionSettings": {
       "PauseStateSettings": {
         "Pipelines": [
       {}
      ]
     }
    }
   }
  ]
 }
}
```

# Combination of create actions
<a name="cli-example-multiple-creates"></a>

Here is an example of a JSON body to pass into the `--creates` parameter of the `batch-update-schedule` AWS CLI command. It contains two actions to create. In this example, both actions are splice\$1inserts, but in fact you can combine any number and any type of create actions.

```
{
    "ScheduleActions": [
      {
        "ScheduleActionSettings": {
          "Scte35SpliceInsertSettings": {
            "Duration": 1350000,
            "SpliceEventId": 3
          }
        },
        "ActionName": "SpliceInsert-01",
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-11-05T16:10:30.000Z"
          }
        }
      },
      {
        "ScheduleActionSettings": {
          "Scte35SpliceInsertSettings": {
            "Duration": 2700000,
            "SpliceEventId": 3
          }
        },
        "ActionName": "SpliceInsert-02",
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-11-05T16:30:45.000Z"
          }
        }
      }
    ]
  }
```

# JSON payload for delete actions
<a name="cli-schedule-delete-json"></a>

 In the `Deletes` section, include the list of actions to delete by entering an array of `ActionNames`. The array contains one or more action names. You can obtain these action names using the `DescribeChannel` command (see [Viewing the schedule (AWS CLI)](viewing-schedule-using-cli.md).

```
{
  "ChannelId": "string",
  "Deletes": {
      "ActionNames": [
          ""
    ]
  }
}
```

## Example
<a name="cli-schedule-delete-json-example"></a>

This example of a request deletes the three actions identified by `ActionNames` that were assigned when you created the actions.

```
{
  "ChannelId": "999999",
  "Deletes": {
      "ActionNames": [
          "stop-overlay-33",
          "adavail-3711",
          "end-adavail-3711"
      ]
  }
}
```

# JSON payload for combining create and delete
<a name="schedule-create-and-delete-json"></a>

To combine a batch of creates and deletes, include both a `Creates` section and a `Deletes` section in the JSON payload. 

In this example, the payload in the `Deletes` section removes an action to activate an image overlay because it has an incorrect start time. The action is named `overlay-21`. The payload in the `Creates` section inserts that action again, this time with the correct start time.

Even though the `Creates` section appears first in the JSON payload, MediaLive always performs the delete actions first. 

In this action, the delete action and the create action have the same `ActionName`. The name is being reused because the batch is a "delete and replace." But you could assign a different name to the create action.

```
{
  "ChannelId": "999999",
  "Creates": {
  "ScheduleActions": [
    {
      "ScheduleActionStartSettings": {
        "FixedModeScheduleActionStartSettings": {
          "Time": "2018-05-21T20:42:19.000Z"
        }
      },
      "ActionName": "overlay-21",
      "ScheduleActionSettings": {
        "StaticImageActivateSettings": {
          "Image": {
          "PasswordParam": "imagespassword",
          "Uri": "s3ssl://amzn-s3-demo-bucket/banner-A/high-res.bmp",
          "Username": "medialiveoperator"
          },
          "ImageY": 300,
          "FadeIn": 1500,
          "ImageX": 200,
          "Width": 800,
          "Opacity": 60,
          "Layer": 1,
          "Height": 900
          }
        }
      }
    ]
  },
  "Deletes": {
       "ActionNames": [
          "overlay-21"
        ]
    }
}
```

# Viewing the schedule (AWS CLI)
<a name="viewing-schedule-using-cli"></a>

You can use the AWS CLI to view a list of the actions that are currently in the schedule for one channel:
+ Actions that have not yet been performed in the channel
+ Actions that have previously been performed 

To view the schedule, use the `DescribeSchedule` command. This command is represented differently in different interfaces:
+ In the AWS CLI, the command is `describe-schedule`.
+ In the API, the command is represented by an `HTTP GET` on `channels/channelId/schedule`.
+ In the AWS SDKs, the command is represented by constructs that are suitable to that SDK language. 

**To view actions (AWS CLI)**

1. Enter this command:

   **aws medialive describe-schedule --channel-id *value* --max-results value**

1. To submit the command, press **Enter**. The response appears on the screen. 

1. If you used the `-max-results` option and the response included `NextToken`, enter the **DescribeChannel** command and pass the value of `NextToken` in `--next-token`. For example:

   **aws medialive describe-schedule --channel-id *value* --next-token 3jhrprd0**

1. To submit the command, press **Enter**. The response appears on the screen. 

## Example
<a name="viewing-schedule-using-cli-example"></a>

The JSON body of the command *response* is similar to that of the `BatchUpdateSchedule` command *request*.

This example of a response shows the following actions:
+ An action with the `ActionName` **corporate-logo-029** to activate an image overlay in layer 1 at 20:30:00 UTC
+ An action with the `ActionName` **stop-overlay-029** to deactivate the overlay in layer 1 at 20:42:04 UTC
+ An action with the `ActionName` **adavail-3708** to insert a splice\$1insert at the same time as the deactivate action
+ An action with the `ActionName` **end-adavail-3708** to return-to-network 15 seconds later, at 20:42:19 UTC
+ An action with the `ActionName` **corporate-logo-030** to reactivate the same overlay in layer 1 at the same time as the return

This schedule describes a workflow where you generally show your corporate logo, but you remove it at the start of each ad avail and then display it again at the end of the ad avail.

```
 {
  "NextToken": "3jhrprd0",
      "ScheduleActions": [
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:30:00.000Z"
          }
        },
        "ActionName": "corporate-logo-029",
        "ScheduleActionSettings": {
          "StaticImageActivateSettings": {
            "Image": {
            "PasswordParam": "corplogo!2312",
            "Uri": "s3ssl://amzn-s3-demo-bucket/logos/corporate/high-res.bmp",
            "Username": "medialiveoperator"
            },
            "ImageY": 300,
            "FadeIn": 1500,
            "ImageX": 200,
            "Width": 800,
            "Opacity": 60,
            "Layer": 1,
            "Height": 900
          }
        }
      },
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:04.000Z"
          }
        },
        "ActionName": " stop-overlay-029",
        "ScheduleActionSettings": {
          "StaticImageDeactivateSettings": {
            "FadeOut": 1500,
            "Layer": 1
          }
        }
      },
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:04.000Z"
          }
        },
        "ActionName": "adavail-3708",
        "ScheduleActionSettings": {
          "Scte35SpliceInsertSettings": {
            "SpliceEventId": 3708,
            "Duration": 1350000
          }
        }
      },
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:19.000Z"
          }
        },
        "ActionName": "end-adavail-3708",
        "ScheduleActionSettings": {
          "Scte35ReturnToNetworkSettings": {
            "SpliceEventId": 3708
          }
        }
      },
      {
        "ScheduleActionStartSettings": {
          "FixedModeScheduleActionStartSettings": {
            "Time": "2018-05-21T20:42:19.000Z"
          }
        },
        "ActionName": "corporate-logo-030",
        "ScheduleActionSettings": {
          "StaticImageActivateSettings": {
            "Image": {
            "PasswordParam": "corplogo!2312",
            "Uri": "s3ssl://amzn-s3-demo-bucket/logos/corporate/high-res.bmp",
            "Username": "medialiveoperator"
            },
            "ImageY": 300,
            "FadeIn": 1500,
            "ImageX": 200,
            "Width": 800,
            "Opacity": 60,
            "Layer": 1,
            "Height": 900
          }
        }
      }
    ]   
  }
```