To deliver content using the API, you must first configure the following:
{"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"}]}
First, we must check if a batch with the same name already exists:
query batches($filters: BatchFilters!) {batches(filters: $filters) {edges {node {idname}}}}
{"filters": {"name": {"eq": "PlatformExample_2023-03-01"}}}
{"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.
To check if the job with the same name exists inside the batch, use the following query:
query jobs($filters: JobFilters!) {jobs(filters: $filters) {edges {node {idname}}}}
{"filters": {"name": {"eq": "MyMovie_PlatformExample"},"batchId": {"eq": "2d7645ea-7a87-4003-a995-4d538b9ceed6"}}}
{"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:
The job name is set using the Batch naming convention.
mutation createJobs($input: [JobInput!]!) {createJobs(input: $input) {idnamestatus}}
{"input": [{"titleId": "4b1e9c03-6bce-4f05-9b2e-4b3edec45b18","batchId": "2d7645ea-7a87-4003-a995-4d538b9ceed6","packageTemplateId": "345dc998-b028-4da3-9a9d-334b09e70ca3","deliveryTargetDate": "2023-03-01"}]}
{"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:
mutation createBatch($input: BatchInput!) {createBatch(input: $input) {idnamestatus}}
{"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}}"}}
{"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.
The job name is set using the Batch naming convention.
mutation startBatch($id: ID!) {bulkStartBatch(id: $id) {idnamestatus}}
{"id": "2d7645ea-7a87-4003-a995-4d538b9ceed6"}
{"data": {"createBatch": {"id": "2d7645ea-7a87-4003-a995-4d538b9ceed6","name": "PlatformExample_2023-03-01","status": "Upcoming"}}}
query jobs($filters: JobFilters!) {jobs(filters: $filters) {edges {node {idnamestatusdeliverables{namedeliveryMode}}}}}
{"filters": {"name": {"eq": "MyMovie_PlatformExample"},"batchId": {"eq": "2d7645ea-7a87-4003-a995-4d538b9ceed6"}}}
{"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:
mutation QcApprovePackage($id: ID!) {qcApprovePackage(id: $id) {idjob {idnarrativeStatusstatus}}}
{"id": "07fe9167-baba-4132-9bfc-8837bb196f87"}
{"data": {"qcApprovePackage": {"id": "07fe9167-baba-4132-9bfc-8837bb196f87","job": {"id": "fde79b69-6d1b-40ee-b2de-75eff7d6c4c2","narrativeStatus": "Waiting for Delivery.","status": "waiting_for_delivery"}}}}
mutation DeliverJob($id: ID!) {deliverJob(id: $id) {idstatus}}
{"id": "fde79b69-6d1b-40ee-b2de-75eff7d6c4c2"}
{"data": {"deliverJob": {"id": "fde79b69-6d1b-40ee-b2de-75eff7d6c4c2","status": "delivering"}}}