M2A Workflows API (v1)

Download OpenAPI specification:

This is API specification of the M2A Workflows API

Workflows

Workflows handle the orchestration of live stream resources of a scheduled event.

Workflows use Templates to define how a workflow will be executed. A Template specifies the resources, configuration desired states and order that resources are to be utilized.

You can create many workflow instances from 1 workflow template. The macros in the workflow templates will allow you to have different configuration per workflow instance:

Currently, only programmatic access via the API endpoints is available. The API requests and responses use the JSON:API specification https://jsonapi.org/.

Workflow Instance

A workflow instance represents a collection of media processing resources and their configuration that needs to be managed to achieve the video processing objectives.

Workflow instance is enrolled to an M2A scheduled event, and the system will update a workflow instance when completing a workflow for an event.

Info for a specific workflow instance

Gets a workflow instance by ID

Authorizations:
http_security_schema
path Parameters
instance-id
required
string <uuid> (Resource identifier)
Example: c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the workflow instance to retrieve

query Parameters
owner
required
string <uuid> (Resource identifier)
Example: owner=c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the target account

fields[instance]
string
Example: fields[instance]=metadata

Return only a subset of the instances data attributes. Attributes is a comma delimited list of strings. Valid fields are:

  • target-account-id
  • metadata
  • nodes
  • signals-received
  • event-handlers
header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Responses

Response samples

Content type
application/vnd.api+json
{
  • "data": {
    }
}

Create a workflow instance from a specific workflow template

Create a Workflow Instance that will track the state of a workflow execution. If the specified Workflow Template requires input parameters, these will have to be supplied in the request. Note that in order to execute the workflow, the instance will need to be associated with a Schedule Event after the instance has been created.

Authorizations:
http_security_schema
query Parameters
fields[instance]
string
Example: fields[instance]=metadata

Return only a subset of the instances data attributes. Attributes is a comma delimited list of strings. Valid fields are:

  • target-account-id
  • metadata
  • nodes
  • signals-received
  • event-handlers
header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Request Body schema: application/vnd.api+json
required

The workflow instance payload

required
object

Responses

Request samples

Content type
application/vnd.api+json
{
  • "data": {
    }
}

Response samples

Content type
application/vnd.api+json
{
  • "data": {
    }
}

Webhooks

M2A sends HTTP POST notifications to a URL of your choice as each sequence step executes. Configure a webhook on a Workflow Template by setting workflow-settings.webhook.

Sequence node notification Webhook

M2A sends this notification to the webhook URL configured on a Workflow Template each time a sequence step starts, succeeds, or fails. Three calls are made per node: one for workflow-sequence-start, one for workflow-sequence-success or workflow-sequence-failed.

Your endpoint must return 2xx. 5xx responses are retried up to 3 times with exponential backoff (1 s, 2 s, 4 s). 4xx responses are not retried.

Request Body schema: application/json
required
organisation-id
required
string <uuid> (Organisation ID)

UUID of the organisation that owns this workflow.

target-account-id
required
string <uuid> (Target account ID)

UUID of the target account the workflow is running under.

event-id
required
string <uuid> (Schedule event ID)

UUID of the M2A schedule event this workflow instance is enrolled to.

workflow-instance-id
required
string <uuid> (Workflow instance ID)

UUID of the workflow instance that triggered this notification.

event
required
string (Schedule event)

The broadcast lifecycle event that triggered this sequence (e.g. PRE-TX, TX, POST-TX).

node-name
required
string (Node name)

The name of the workflow node that this sequence step acted on.

sequence-node-id
required
string <uuid> (Sequence node ID)

UUID of the sequence node (step) within the event-handler.

action-type
required
string (Action type)
Enum: "workflow-sequence-start" "workflow-sequence-success" "workflow-sequence-failed"

Indicates the outcome of the sequence step:

  • workflow-sequence-start — the step has begun executing
  • workflow-sequence-success — the step completed successfully
  • workflow-sequence-failed — the step failed
timestamp
required
integer (Timestamp)

Unix epoch timestamp in milliseconds when the webhook message was dispatched.

Responses

Request samples

Content type
application/json
Example
{
  • "organisation-id": "65337911-49f4-4e1a-b32c-ee351bfb0c27",
  • "target-account-id": "b1155af6-b8f3-46a7-af3c-3e4e372ba81b",
  • "event-id": "bcb1988f-1cb2-48bd-9ee6-26f7f53dfa4c",
  • "workflow-instance-id": "5113b398-4095-4ee7-8b2d-969afe8a472c",
  • "event": "PRE-TX",
  • "node-name": "Primary-Encoder",
  • "sequence-node-id": "e8f12e33-5eb5-43ba-8253-57b673f0fe8b",
  • "action-type": "workflow-sequence-start",
  • "timestamp": 1664882060713
}

Workflow Template

Internal use only

Defines the resources and the video flows between them to fulfil a customer’s live video workflow.

A Workflow Template is a reusable blueprint. You create many Workflow Instances from one Template. The Template declares nodes — each node represents a media resource (encoder, packager, connect source, etc.) — and event-handlers that describe what should happen at each point in the broadcast lifecycle (e.g. PRE-TX, ON-AIR, POST-TX).

Macros

Any string value in a Template can include a macro using double-brace syntax: {{ variable_name }}. Macros are resolved immediately at instance creation time, using the config dictionary supplied in the Instance POST payload. Once the instance is created, all macro values are fixed.

Example — parameterising the encoder region:

Template node:

{
  "name": "Primary-Encoder",
  "node-type": "encoder_v4",
  "input-values": {
    "region": "{{ region }}",
    "medialive-input-role-arn": "{{ medialive_arn }}"
  }
}

Instance POST payload:

{
  "data": {
    "attributes": {
      "config": {
        "region": "eu-west-1",
        "medialive_arn": "arn:aws:iam::123456789:role/MediaLiveRole"
      }
    }
  }
}

Every occurrence of {{ region }} is replaced with "eu-west-1" and {{ medialive_arn }} with the supplied ARN at the moment the instance is created. This lets a single Template serve many events across different regions or accounts.

m2a.expand

Some fields require a JSON array rather than a plain string (for example subnet-ids and security-group-ids on private-network encoder inputs). The standard {{ variable }} macro always produces a string. When you need a macro to expand into a list, use m2a.expand:

{{m2a.expand(variable_name)}}

Like standard macros, m2a.expand is rendered immediately at instance creation time.

Example:

Template:

{
  "subnet-ids": "{{m2a.expand(subnet_ids)}}",
  "security-group-ids": "{{m2a.expand(security_group_ids)}}"
}

Instance config:

{
  "subnet_ids": ["subnet-aaa", "subnet-bbb"],
  "security_group_ids": ["sg-111", "sg-222"]
}

{{m2a.expand(subnet_ids)}} is replaced with the full list ["subnet-aaa", "subnet-bbb"] rather than a string representation of it, at the moment the instance is created.

Referencing nodes by name

Each node in a Template is identified by its name field, which must be unique within the Template. To wire one node’s output into another node’s input, use the nodes.<NodeName>.<field> macro syntax:

{{ nodes.NodeName.field }}

Unlike standard macros, node references are not resolved at instance creation time. They are resolved at event time, once the referenced node has actually run and produced its output. This means the encoder will always receive the live, real values from the packager — even though those values did not exist when the instance was created.

Example — encoder referencing a packager’s output:

{
  "nodes": [
    {
      "name": "MediaPackage1",
      "node-type": "packager",
      "input-values": { ... }
    },
    {
      "name": "Primary-Encoder",
      "node-type": "encoder_v4",
      "input-values": {
        "settings": {
          "destinations": [
            {
              "output-group-type": "MEDIA_PACKAGE",
              "packager-id": "{{ nodes.MediaPackage1.packager-id }}"
            }
          ]
        }
      }
    }
  ]
}

When the event fires, MediaPackage1 runs first. Once it is up, {{ nodes.MediaPackage1.packager-id }} resolves to the live packager ID and the encoder is started with the correct destination.

Referencing nodes in a sequence

Event-handlers contain sequences that control the order in which nodes are started and stopped. Each step in a sequence references a node by its name using the node-name field. The name field on the sequence step itself is a human-readable label for the step. Neither name nor node-name may be a macro — both must be static strings.

Example — sequence step that starts the encoder on PRE-TX:

{
  "nodes": [
    {
      "name": "Primary-Encoder",
      "node-type": "encoder_v4",
      "input-values": { ... }
    }
  ],
  "event-handlers": [
    {
      "events": ["PRE-TX"],
      "sequence": [
        {
          "nodes": [
            {
              "name": "Start primary encoder",
              "node-name": "Primary-Encoder",
              "desired-state": "RUNNING"
            }
          ]
        }
      ]
    }
  ]
}

node-name must match the name of an existing node in the Template exactly. Because node names are the sole identifier within a Template, they must be unique — duplicate names are not permitted.

Create a Workflow Template

POST a workflow template

Authorizations:
http_security_schema
header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Request Body schema: application/vnd.api+json
required

The template payload

required
object

Responses

Request samples

Content type
application/vnd.api+json
{
  • "data": {
    }
}

Response samples

Content type
application/vnd.api+json
{
  • "data": {
    }
}

Get List of workflow templates

Gets a list of workflow templates for a target account. The workflow template list is paginated. Each page contains up to 50 templates. The following structure is used for the response where data contains a list of event objects and next contains an url of the next page of events:

{
  'data': [ ... ],
  'links': {
    'next': ...
  }
}
Authorizations:
http_security_schema
query Parameters
owner
required
string <uuid> (Resource identifier)
Example: owner=c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the target account

fields[template]
string
Example: fields[template]=metadata

Return only a subset of the template's data attributes. Attributes is a comma delimited list of strings. Valid fields are:

  • target-account-id
  • metadata
  • resource-name
  • state
  • nodes
  • event-handlers
  • input-parameters
  • ui-layout
header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Responses

Response samples

Content type
application/vnd.api+json
{
  • "links": {
    },
  • "data": [
    ]
}

Get specific workflow Template by `Template ID`

Retrieves a workflow template using Template ID.

Authorizations:
http_security_schema
path Parameters
template-id
required
string <uuid> (Resource identifier)
Example: c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the workflow template id to retrieve

query Parameters
owner
required
string <uuid> (Resource identifier)
Example: owner=c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the target account

fields[template]
string
Example: fields[template]=metadata

Return only a subset of the template's data attributes. Attributes is a comma delimited list of strings. Valid fields are:

  • target-account-id
  • metadata
  • resource-name
  • state
  • nodes
  • event-handlers
  • input-parameters
  • ui-layout
header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Responses

Response samples

Content type
application/vnd.api+json
{
  • "data": {
    }
}

Delete specific workflow Template by `Template ID`

Deletes a workflow template using Template ID.

Authorizations:
http_security_schema
path Parameters
template-id
required
string <uuid> (Resource identifier)
Example: c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the workflow template id to retrieve

query Parameters
owner
required
string <uuid> (Resource identifier)
Example: owner=c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the target account

header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Responses

Response samples

Content type
application/vnd.api+json
{
  • "errors": [
    ]
}

Get specific workflow Template by `resource-name`

Retrieves a workflow template using the specified resource-name.

Authorizations:
http_security_schema
path Parameters
resource-name
required
string <string> (Resource name)
Example: my template

The name of the workflow template

query Parameters
owner
required
string <uuid> (Resource identifier)
Example: owner=c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the target account

fields[template]
string
Example: fields[template]=metadata

Return only a subset of the template's data attributes. Attributes is a comma delimited list of strings. Valid fields are:

  • target-account-id
  • metadata
  • resource-name
  • state
  • nodes
  • event-handlers
  • input-parameters
  • ui-layout
header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Responses

Response samples

Content type
application/vnd.api+json
{
  • "data": {
    }
}

Delete specific workflow Template by `resource-name`

Deletes a workflow template using the specified resource-name.

Authorizations:
http_security_schema
path Parameters
resource-name
required
string <string> (Resource name)
Example: my template

The name of the workflow template

query Parameters
owner
required
string <uuid> (Resource identifier)
Example: owner=c49c499b-4e7e-4acb-ae83-f528b6ed194d

The id of the target account

header Parameters
Accept
string (JSON API)
Value: "application/vnd.api+json"

Content type (expressed as MIME types) the client is able to understand.

Content-Type
string (JSON API)
Value: "application/vnd.api+json"

The original media type of the resource.

Responses

Response samples

Content type
application/vnd.api+json
{
  • "errors": [
    ]
}