An organization
Bucket(s)
One or more video files
All GraphQL queries and mutations related to ad breaks require the internal ID of the file(s) being operated on.
You must first obtain the internal file IDs with a query such as filesByLocators
, including the File id
in the response.
query filesByLocators($locators: [FileLocatorInput!]!) {filesByLocators(locators: $locators) {id}}
{"locators": [{"type": "S3FileLocator","bucket": "my-bucket","key": "example/path/my-file.mov"},{"type": "S3FileLocator","bucket": "my-bucket","key": "example/path/my-other-file.mov"}]}
{"data": {"filesByLocators": [{"id": "f63a3849-3cf3-4835-be33-6743af08747c"},{"id": "6ff1ee7d-d1e6-429b-81cd-0d07ea42bc9b"}]}}
After obtaining the internal file IDs, you can insert ad breaks one at a time by using the createAdBreak
mutation.
mutation CreateAdBreak($input: AdBreakInput!) {createAdBreak(input: $input) {idfileIdtimecodedescription}}
{"input": {"fileId": "f63a3849-3cf3-4835-be33-6743af08747c","timecode": "00:01:20:15","description": "Ad break 1"}}
{"data": {"createAdBreak": {"id": "3e137ef5-e64a-46ce-9fb8-6d3d6f850a0a","fileId": "f63a3849-3cf3-4835-be33-6743af08747c","timecode": "00:01:20:15","description": "Ad break 1"},}}
To insert or update multiple ad breaks in bulk, you can use the bulkUpsertAdBreaks
mutation to either insert or update multiple ad breaks for each file.
mutation BulkUpsertAdBreaks($input: [AdBreakInput!]!) {bulkUpsertAdBreaks(data: $input) {idfileIdtimecodedescription}}
{"input": [{"fileId": "f63a3849-3cf3-4835-be33-6743af08747c","timecode": "00:01:20:15","description": "Ad break 1"},{"fileId": "f63a3849-3cf3-4835-be33-6743af08747c","timecode": "00:05:15:00","description": "Ad break 2"},{"fileId": "6ff1ee7d-d1e6-429b-81cd-0d07ea42bc9b","timecode": "00:02:06:20","description": "Ad break 1"}]}
{"data": {"bulkUpsertAdBreaks": [{"id": "3e137ef5-e64a-46ce-9fb8-6d3d6f850a0a","fileId": "f63a3849-3cf3-4835-be33-6743af08747c","timecode": "00:01:20:15","description": "Ad break 1"},{"id": "ed033cb2-7ac4-465e-b5f1-067fe473f29e","fileId": "f63a3849-3cf3-4835-be33-6743af08747c","timecode": "00:05:15:00","description": "Ad break 2"},{"id": "b24e5c7d-e9de-419f-8aea-2e3be4018c75","fileId": "6ff1ee7d-d1e6-429b-81cd-0d07ea42bc9b","timecode": "00:02:06:20","description": "Ad break 1"}]}}
You can list the ad breaks for a specific file using the adBreaks
query.
query AdBreaks($filters: AdBreakFilters) {adBreaks(filters: $filters) {edges {node {idfileIdtimecodedescription}}}}
{"filters": {"fileId": {"eq": "f63a3849-3cf3-4835-be33-6743af08747c"}}}
{"data": {"adBreaks": {"edges": [{"node": {"id": "3e137ef5-e64a-46ce-9fb8-6d3d6f850a0a","fileId": "f63a3849-3cf3-4835-be33-6743af08747c","timecode": "00:01:20:15","description": "Ad break 1"}}]}}}
You can update the time code or description of an existing ad break using the updateAdBreak
mutation.
mutation UpdateAdBreak($id: ID!, $input: AdBreakInput!) {updateAdBreak(id: $id, input: $input) {idtimecodedescription}}
{"id": "3e137ef5-e64a-46ce-9fb8-6d3d6f850a0a","input": {"description": "New description"}}
{"data": {"updateAdBreak": {"id": "3e137ef5-e64a-46ce-9fb8-6d3d6f850a0a","timecode": "00:01:20:15","description": "New description"}}}
To delete an ad break, you can use the deleteAdBreak
mutation.
mutation DeleteAdBreak($id: ID!) {deleteAdBreak(id: $id) {id}}
{"id": "3e137ef5-e64a-46ce-9fb8-6d3d6f850a0a"}
{"data": {"deleteAdBreak": null}}
To delete multiple ad breaks at once, you can use the deleteAdBreaks
mutation.
mutation DeleteAdBreaks($ids: [ID!]!) {deleteAdBreaks(ids: $ids) {id}}
{"ids": ["3e137ef5-e64a-46ce-9fb8-6d3d6f850a0a","ed033cb2-7ac4-465e-b5f1-067fe473f29e"]}
{"data": {"deleteAdBreaks": null}}