Skip to content

GraphQL

The Mux plugin supports accessing muxAsset element object via GraphQL. Be sure to read about Craft's GraphQL support.

Available Queries

1. muxAssets

Query for multiple Mux assets with filtering and pagination options.

Type: [MuxAssetInterface] (Array of Mux Asset objects)

2. muxAsset

Query for a single Mux asset.

Type: MuxAssetInterface (Single Mux Asset object)

3. muxAssetCount

Get the count of Mux assets matching the query criteria.

Type: Int! (Non-null integer)

Query Parameters

Core Mux Asset Parameters

ParameterTypeDescription
id[QueryArgument]Narrows the query results based on the mux asset's ID
asset_id[QueryArgument]Narrows the query results based on the mux asset's asset_id
asset_status[String]Narrows the query results based on the mux asset's status
aspect_ratio[String]Narrows the query results based on the mux asset's aspect ratio
duration[QueryArgument]Narrows the query results based on the mux asset's duration
is_live[Boolean]Narrows the query results based on whether the asset is live
upload_id[QueryArgument]Narrows the query results based on the upload ID
playback_ids[QueryArgument]Narrows the query results based on playback IDs
tracks[QueryArgument]Narrows the query results based on tracks
passthrough[QueryArgument]Narrows the query results based on passthrough data
meta[QueryArgument]Narrows the query results based on meta data
folderId[QueryArgument]Narrows the query results based on the folder ID
volumeId[QueryArgument]Narrows the query results based on the volume ID

Inherited Element Parameters

ParameterTypeDescription
uid[String]Narrows the query results based on the elements' UIDs
site[String]Determines which site(s) the elements should be queried in
uniqueBooleanDetermines whether only elements with unique IDs should be returned
preferSites[QueryArgument]Determines which site should be selected for multi-site elements
title[String]Narrows the query results based on the elements' titles
slug[String]Narrows the query results based on the elements' slugs
uri[String]Narrows the query results based on the elements' URIs
searchStringNarrows the query results to elements that match a search query
searchTermOptionsSearchTermOptionsDefines default options for search terms
relatedTo[QueryArgument]Narrows results to elements that relate to provided element IDs
notRelatedTo[QueryArgument]Narrows results to elements that do not relate to provided element IDs
relatedToAssets[AssetRelation]Narrows results to elements that relate to an asset list
relatedToEntries[EntryRelation]Narrows results to elements that relate to an entry list
relatedToUsers[UserRelation]Narrows results to elements that relate to a user list
relatedToCategories[CategoryRelation]Narrows results to elements that relate to a category list
relatedToTags[TagRelation]Narrows results to elements that relate to a tag list
relatedToAll[QueryArgument]Narrows results to elements that relate to ALL provided element IDs
ref[String]Narrows the query results based on a reference string
fixedOrderBooleanCauses results to be returned in the order specified by the id argument
inReverseBooleanCauses results to be returned in reverse order
dateCreated[String]Narrows results based on the elements' creation dates
dateUpdated[String]Narrows results based on the elements' last-updated dates
offsetIntSets the offset for paginated results
language[String]Determines which site(s) to query based on language
limitIntSets the limit for paginated results
orderByStringSets the field the returned elements should be ordered by
siteSettingsId[QueryArgument]Narrows results based on unique identifier for element-site relation

Status Parameters (if permissions allow)

ParameterTypeDescription
status[String]Narrows results based on the elements' statuses
archivedBooleanNarrows results to only archived elements
trashedBooleanNarrows results to only soft-deleted elements

Draft Parameters (if permissions allow)

ParameterTypeDescription
draftsBooleanWhether draft elements should be returned
draftOfQueryArgumentNarrows results to only drafts of a given element
draftIdIntThe ID of the draft to return
draftCreatorIntThe drafts' creator ID
provisionalDraftsBooleanWhether provisional drafts should be returned
withProvisionalDraftsBooleanWhether canonical elements should be replaced with provisional drafts

Revision Parameters (if permissions allow)

ParameterTypeDescription
revisionsBooleanWhether revision elements should be returned
revisionOfQueryArgumentThe source element ID that revisions should be returned for
revisionIdIntThe ID of the revision to return
revisionCreatorIntThe revisions' creator ID

Response Structure

MuxAssetInterface Fields

FieldTypeDescription
idIDElement ID
asset_idStringID of the mux asset
volumeIdIDVolume ID
folderIdIDFolder ID
created_atStringCreation time of the object
asset_statusStringStatus of the mux asset
durationStringDuration of the object
max_stored_resolutionStringMax stored resolution of the object
max_stored_frame_rateStringMax stored frame rate of the object
resolution_tierStringResolution tier of the object
max_resolution_tierStringMax resolution tier of the object
encoding_tierStringEncoding tier of the object
aspect_ratioStringAspect ratio of the object
playback_ids[PlaybackID]Playback IDs of the object
tracks[Track]Tracks of the object
errorsStringErrors of the object
per_title_encodeStringPer-title encode of the object
upload_idStringUpload ID of the object
is_liveStringIndicates whether the object is live or not
passthroughStringPassthrough of the object
live_stream_idStringLive stream ID of the object
masterStringMaster of the object
master_accessStringMaster access
mp4_supportStringMP4 support (depreciated)
source_asset_idStringSource Asset Id
nomralize_audioStringNormalize Audio
static_renditionsStringStatic Renditions
recording_timesStringRecording Times
non_standard_input_reasonsStringNon Standard Input Reasons
testStringTest flag
ingest_typeStringIngest type
metaMetaMeta data of the object

PlaybackID Type

FieldTypeDescription
idStringID of the playback
policyStringPolicy of the playback

Track Type

FieldTypeDescription
idStringTrack ID
typeStringTrack type
text_sourceStringText source
text_typeStringText type
language_codeStringLanguage code
nameStringTrack name
closed_captionsStringClosed captions
durationFloatThe duration of the track in seconds
max_widthIntThe maximum width of the track
max_heightIntThe maximum height of the track
max_frame_rateIntThe maximum frame rate of the track

Meta Type

FieldTypeDescription
titleStringTitle of the asset
external_idStringExternal ID of the asset
creator_idStringCreator ID of the asset

Example Queries

Basic Query - Get All Mux Assets

graphql
query {
  muxAssets {
    id
    asset_id
    asset_status
    duration
    aspect_ratio
    created_at
    playback_ids {
      id
      policy
    }
    tracks {
      id
      type
      duration
      max_width
      max_height
      language_code
    }
    meta {
      title
      external_id
      creator_id
    }
  }
}
json
{
  "data": {
    "muxAssets": [
      {
        "id": "123",
        "asset_id": "abc123def456",
        "asset_status": "ready",
        "duration": "120.5",
        "aspect_ratio": "16:9",
        "created_at": "2023-12-01T10:30:00Z",
        "playback_ids": [
          {
            "id": "playback_123",
            "policy": "public"
          }
        ],
        "tracks": [
          {
            "id": "track_123",
            "type": "video",
            "duration": 120.5,
            "max_width": 1920,
            "max_height": 1080,
            "max_frame_rate": 30,
            "language_code": "en"
          },
          {
            "id": "track_124",
            "type": "audio",
            "duration": 120.5,
            "language_code": "en"
          }
        ],
        "meta": {
          "title": "Sample Video",
          "external_id": "ext_123",
          "creator_id": "user_456"
        }
      }
    ]
  }
}

Filtered Query - Get Live Assets with Specific Status

graphql
query {
  muxAssets(
    asset_status: ["ready"]
    is_live: [true]
    limit: 10
    orderBy: "created_at"
  ) {
    id
    asset_id
    asset_status
    is_live
    duration
    aspect_ratio
    playback_ids {
      id
      policy
    }
    tracks {
      id
      type
      duration
      max_width
      max_height
    }
    meta {
      title
      external_id
    }
  }
}

Single Asset Query

graphql
query {
  muxAsset(asset_id: ["your-asset-id-here"]) {
    id
    asset_id
    asset_status
    duration
    aspect_ratio
    max_stored_resolution
    max_stored_frame_rate
    resolution_tier
    encoding_tier
    playback_ids {
      id
      policy
    }
    tracks {
      id
      type
      text_type
      language_code
      name
      duration
      max_width
      max_height
      max_frame_rate
    }
    meta {
      title
      external_id
      creator_id
    }
    errors
    upload_id
    passthrough
    live_stream_id
    master
    master_access
    mp4_support
    source_asset_id
    static_renditions
    recording_times
    non_standard_input_reasons
    test
    ingest_type
  }
}
json
{
  "data": {
    "muxAsset": {
      "id": "123",
      "asset_id": "abc123def456ghi789",
      "asset_status": "ready",
      "duration": "120.5",
      "aspect_ratio": "16:9",
      "max_stored_resolution": "1920x1080",
      "max_stored_frame_rate": "30",
      "resolution_tier": "1080p",
      "encoding_tier": "smart",
      "playback_ids": [
        {
          "id": "playback_123456789",
          "policy": "public"
        },
        {
          "id": "playback_987654321",
          "policy": "signed"
        }
      ],
      "tracks": [
        {
          "id": "track_video_123",
          "type": "video",
          "text_type": null,
          "language_code": "en",
          "name": "Main Video Track",
          "duration": 120.5,
          "max_width": 1920,
          "max_height": 1080,
          "max_frame_rate": 30
        },
        {
          "id": "track_audio_124",
          "type": "audio",
          "text_type": null,
          "language_code": "en",
          "name": "Stereo Audio",
          "duration": 120.5,
          "max_width": null,
          "max_height": null,
          "max_frame_rate": null
        },
        {
          "id": "track_subtitles_125",
          "type": "text",
          "text_type": "subtitles",
          "language_code": "en",
          "name": "English Subtitles",
          "duration": 120.5,
          "max_width": null,
          "max_height": null,
          "max_frame_rate": null
        }
      ],
      "meta": {
        "title": "Sample Marketing Video",
        "external_id": "marketing_video_001",
        "creator_id": "user_456789"
      },
      "errors": null,
      "upload_id": "upload_abc123def456",
      "passthrough": "{\"project\":\"marketing\",\"campaign\":\"q4_2023\"}",
      "live_stream_id": null,
      "master": "{\"access\":\"public\",\"url\":\"https://stream.mux.com/abc123def456.m3u8\"}",
      "master_access": "public",
      "mp4_support": "standard",
      "source_asset_id": null,
      "static_renditions": "{\"files\":[{\"name\":\"track_video_123.mp4\",\"ext\":\"mp4\",\"height\":720,\"width\":1280}]}",
      "recording_times": null,
      "non_standard_input_reasons": null,
      "test": false,
      "ingest_type": "on_demand"
    }
  }
}

Notes

  • All queries require appropriate GraphQL permissions to be configured in Craft CMS
  • The QueryArgument type supports various comparison operators (equals, not equals, greater than, less than, etc.)
  • Date parameters accept various formats including ISO 8601 strings
  • The search parameter performs full-text search across searchable fields
  • Pagination is handled through limit and offset parameters
  • Results can be ordered using the orderBy parameter with field names