connect
search

API Based Deliveries

Setup

To deliver content using the API, you must first configure the following:

Prerequisites

  • A media JSON payload
JSON payload example
{
"details" :
{
"batchName" : "Roku | May 2023 deliveries",
"deliveryStart" : "15/03/2023",
"delieryEnd" : "15/04/2023",
"platform" : "Roku"
},
"items" :
[
{
"titleName" : "Big Buck Bunny",
"titleType" : "Movie",
"houseId" : "ATL0003"
},
{
"titleName" : "Dragnet S01E01",
"titleType" : "Episode",
"houseId" : "ATL00040101"
},
{
"titleName" : "Dragnet S01E02",
"titleType" : "Episode",
"houseId" : "ATL00040103"
},
{
"titleName" : "Dragnet S01E03",
"titleType" : "Episode",
"houseId" : "ATL00040103"
}
]
}

Workflow

First, we must check if a batch with the same name already exists:

Getting Batches

Query

query batches($filters: BatchFilters!) {
batches(filters: $filters) {
edges {
node {
id
name
}
}
}
}

Variables

{
"filters": {
"name": {
"eq": "PlatformExample_2023-03-01"
}
}
}

Response

{
"data": {
"batches": {
"edges": [
{
"node": {
"id": "2d7645ea-7a87-4003-a995-4d538b9ceed6",
"name": "PlatformExample_2023-03-01"
}
}
]
}
}
}

If the batch already exists, we must also check if the jobs contained in the batch exist.

Getting Jobs

To check if the job with the same name exists inside the batch, use the following query:

Query

query jobs($filters: JobFilters!) {
jobs(filters: $filters) {
edges {
node {
id
name
}
}
}
}

Variables

{
"filters": {
"name": {
"eq": "MyMovie_PlatformExample"
},
"batchId": {
"eq": "2d7645ea-7a87-4003-a995-4d538b9ceed6"
}
}
}

Response

{
"data": {
"jobs": {
"edges": [
{
"node": {
"id": "c5567ca9-fb68-467b-8786-3ae71ce5a462",
"name": "MyMovie_PlatformExample"
}
}
]
}
}
}

If the job already exists, we skip that one, and we create others using the following mutation:

Creating Jobs

Note

The job name is set using the Batch naming convention.

Mutation

mutation createJobs($input: [JobInput!]!) {
createJobs(input: $input) {
id
name
status
}
}

Variables

{
"input": [
{
"titleId": "4b1e9c03-6bce-4f05-9b2e-4b3edec45b18",
"batchId": "2d7645ea-7a87-4003-a995-4d538b9ceed6",
"packageTemplateId": "345dc998-b028-4da3-9a9d-334b09e70ca3",
"deliveryTargetDate": "2023-03-01"
}
]
}

Response

{
"data": {
"createJobs": [
{
"id": "c5567ca9-fb68-467b-8786-3ae71ce5a462",
"name": "MyMovie_PlatformExample",
"status": "draft"
}
]
}
}

If the batch does not exist already in Connect, we must create it using the following mutation:

Creating Batches

Mutation

mutation createBatch($input: BatchInput!) {
createBatch(input: $input) {
id
name
status
}
}

Variables

{
"input": {
"name": "PlatformExample_2023-03-01",
"deliveryStartDate": "2023-03-01",
"deliveryEndDate": "2023-03-01",
"platformId": "6003e9e9-1835-4ed2-a01c-b3caa1902de8",
"jobNameFormat": "{{title.name}}_{{platform_name}}"
}
}

Response

{
"data": {
"createBatch": {
"id": "2d7645ea-7a87-4003-a995-4d538b9ceed6",
"name": "PlatformExample_2023-03-01",
"status": "Upcoming"
}
}
}

With the createJobs mutation, you can add jobs from a JSON payload to the batch using the Title and Package Template items.

Note

The job name is set using the Batch naming convention.

Starting Batches

Mutation

mutation startBatch($id: ID!) {
bulkStartBatch(id: $id) {
id
name
status
}
}

Variables

{
"id": "2d7645ea-7a87-4003-a995-4d538b9ceed6"
}

Response

{
"data": {
"createBatch": {
"id": "2d7645ea-7a87-4003-a995-4d538b9ceed6",
"name": "PlatformExample_2023-03-01",
"status": "Upcoming"
}
}
}

Get Job Status

Query

query jobs($filters: JobFilters!) {
jobs(filters: $filters) {
edges {
node {
id
name
status
deliverables{
name
deliveryMode
}
}
}
}
}

Variables

{
"filters": {
"name": {
"eq": "MyMovie_PlatformExample"
},
"batchId": {
"eq": "2d7645ea-7a87-4003-a995-4d538b9ceed6"
}
}
}

Response

{
"data": {
"jobs": {
"edges": [
{
"node": {
"id": "fde79b69-6d1b-40ee-b2de-75eff7d6c4c2",
"name": "MyMovie_PlatformExample",
"status": "waiting_for_qc",
"deliverables": [
{
"name": "output.mov",
"deliveryMode": "copy"
},
{
"name": "metadata.xml",
"deliveryMode": "copy"
}
]
}
}
]
}
}
}

During the delivery process, the job can migrate to multiple statuses, some of which we will treat in a special manner:

  • if the job is in the Waiting for QC status:

Mutation

mutation QcApprovePackage($id: ID!) {
qcApprovePackage(id: $id) {
id
job {
id
narrativeStatus
status
}
}
}

Variables

{
"id": "07fe9167-baba-4132-9bfc-8837bb196f87"
}

Response

{
"data": {
"qcApprovePackage": {
"id": "07fe9167-baba-4132-9bfc-8837bb196f87",
"job": {
"id": "fde79b69-6d1b-40ee-b2de-75eff7d6c4c2",
"narrativeStatus": "Waiting for Delivery.",
"status": "waiting_for_delivery"
}
}
}
}
  • if the job is in the Waiting for Delivery status:

Mutation

mutation DeliverJob($id: ID!) {
deliverJob(id: $id) {
id
status
}
}

Variables

{
"id": "fde79b69-6d1b-40ee-b2de-75eff7d6c4c2"
}

Response

{
"data": {
"deliverJob": {
"id": "fde79b69-6d1b-40ee-b2de-75eff7d6c4c2",
"status": "delivering"
}
}
}
Ingest WorkflowSDK Implementation