### Install and Run Smee Client for Local Webhook Relay Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md Steps to set up a webhook relay using Smee.io and start the smee client to forward webhooks to a local Strapi instance. ```bash # Create a webhook relay at https://smee.io/ # Copy the unique URL # Start smee client npm install -g smee-client smee -u https://smee.io/abc123 -t http://localhost:1337/mux-video-uploader/webhook-handler ``` -------------------------------- ### Create Asset Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Example JSON response after successfully creating a new asset record. ```JSON { "id": 10, "title": "New Asset", "upload_id": "upload-123", "signed": false, "createdAt": "2024-01-15T11:00:00Z", "updatedAt": "2024-01-15T11:00:00Z" } ``` -------------------------------- ### Install and Run Ngrok for Local Webhook Tunneling Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md Instructions for installing ngrok on macOS and starting an HTTP tunnel to port 1337, commonly used for local Strapi development. ```bash # Install ngrok brew install ngrok # macOS # or download from https://ngrok.com # Start tunnel ngrok http 1337 # Use the provided URL in Mux webhook config # Example: https://abc123.ngrok.io/mux-video-uploader/webhook-handler ``` -------------------------------- ### Example: Download Subtitles Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-controller.md Example of how to download a subtitle file using curl. ```bash curl http://localhost:1337/mux-video-uploader/mux-text-tracks/track-123 > subtitles.vtt ``` -------------------------------- ### Install Dependencies Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README_INTERNAL.md Installs the project's development dependencies using Yarn. ```bash % yarn install ``` -------------------------------- ### Settings Check Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Example JSON response indicating the plugin's configuration status. Returns true if configured, false otherwise. ```JSON true ``` -------------------------------- ### Mux Thumbnail Request Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-controller.md Examples of how to request a thumbnail image for a Mux asset using its playback or asset ID. ```bash curl http://localhost:1337/mux-video-uploader/thumbnail/abc123 -o thumbnail.jpg ``` ```bash # With signed playback curl "http://localhost:1337/mux-video-uploader/thumbnail/abc123?token=eyJhbGc..." -o thumbnail.jpg ``` -------------------------------- ### Mux Storyboard Request Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-controller.md Example of how to request a storyboard (spritesheet) for a Mux asset using its playback or asset ID. ```bash curl http://localhost:1337/mux-video-uploader/storyboard/abc123 > storyboard.vtt ``` -------------------------------- ### Thumbnail Proxy Request Examples Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Examples of GET requests to the thumbnail proxy endpoint. The first shows a basic request using a playback ID, and the second includes an optional signed playback token for authenticated access. ```http GET /mux-video-uploader/thumbnail/abc123 GET /mux-video-uploader/thumbnail/abc123?token=eyJhbGc... ``` -------------------------------- ### Install Strapi Mux Video Uploader Plugin (Strapi v5) Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README.md Install the latest version of the plugin for Strapi v5 using npm or yarn. ```bash npm i strapi-plugin-mux-video-uploader@latest yarn add strapi-plugin-mux-video-uploader@latest ``` -------------------------------- ### Install Strapi Mux Video Uploader Plugin (Strapi v4) Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README.md Install version 2.0.0 of the plugin for Strapi v4 using npm or yarn. ```bash npm i strapi-plugin-mux-video-uploader@2.8.4 yarn add strapi-plugin-mux-video-uploader@2.8.4 ``` -------------------------------- ### Find Mux Assets Examples Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-asset-controller.md Examples of how to query the Mux Assets endpoint using curl. Demonstrates basic retrieval, pagination, sorting, and filtering. ```bash # Get first 10 assets, sorted by creation date curl http://localhost:1337/mux-video-uploader/mux-asset?limit=10&offset=0&sort=createdAt&order=desc # Filter by title curl http://localhost:1337/mux-video-uploader/mux-asset?filters[title]=my%20video # Content API - public read access curl http://localhost:1337/api/mux-asset ``` -------------------------------- ### Update Asset Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Example JSON response indicating a successful asset update. ```JSON { "ok": true } ``` -------------------------------- ### Count Mux Assets Examples Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-asset-controller.md Examples of how to count Mux Assets using curl. Demonstrates counting all assets and counting assets with specific filters. ```bash # Total count curl http://localhost:1337/mux-video-uploader/mux-asset/count # Count with filter curl http://localhost:1337/mux-video-uploader/mux-asset/count?filters[isReady]=true ``` -------------------------------- ### Single Asset Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Example JSON response for a single asset, including its metadata and Mux asset data. ```JSON { "id": 5, "title": "My Video", "asset_id": "asset-abc123", "playback_id": "playback-xyz", "signed": false, "isReady": true, "duration": 120.5, "aspect_ratio": "16:9", "asset_data": { "id": "asset-abc123", "status": "ready", "created_at": "2024-01-15T10:00:00Z", "tracks": [], "playback_ids": [ { "id": "playback-xyz", "policy": "public" } ] }, "createdAt": "2024-01-15T10:00:00Z", "updatedAt": "2024-01-15T10:30:00Z" } ``` -------------------------------- ### Asset List Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md This is an example of a successful (200 OK) response from the asset list endpoint. It returns a paginated list of Mux assets stored in Strapi, including metadata and total count. ```json { "items": [ { "id": 1, "title": "My Video", "asset_id": "asset-123", "playback_id": "playback-456", "isReady": true, "createdAt": "2024-01-15T10:00:00Z", "updatedAt": "2024-01-15T10:30:00Z" } ], "totalCount": 15 } ``` -------------------------------- ### Create Asset Request Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Example JSON request body for creating a new asset record, including title and upload ID. ```JSON { "body": { "title": "New Asset", "upload_id": "upload-123", "signed": false } } ``` -------------------------------- ### Sign Mux Playback ID Token Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-controller.md Examples for generating signed JWT tokens for secure Mux video playback or thumbnail access. ```bash # Get a video playback token (1 day expiry) curl http://localhost:1337/mux-video-uploader/sign/abc123?type=video ``` ```bash # Get a thumbnail token (1 minute expiry) curl http://localhost:1337/mux-video-uploader/sign/abc123?type=thumbnail ``` -------------------------------- ### Update Asset Request Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Example JSON request body for updating an asset, including title and custom text tracks. ```JSON { "title": "Updated Title", "custom_text_tracks": [ { "name": "English", "language_code": "en", "closed_captions": false, "file": { "contents": "WEBVTT\n\n00:00:00.000 --> 00:00:05.000\nHello", "type": "text/vtt", "name": "en.vtt", "size": 42 } } ] } ``` -------------------------------- ### Find One Mux Asset Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-asset-controller.md Example of how to retrieve a specific Mux Asset using its document ID via curl. ```bash curl http://localhost:1337/mux-video-uploader/mux-asset/5 ``` -------------------------------- ### Mux Webhook Handler Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md This is an example of a successful (200 OK) response from the webhook handler endpoint after processing a Mux event. It reflects the updated Strapi video entry with Mux asset details. ```json { "id": 5, "title": "My Video", "asset_id": "asset-abc123", "playback_id": "playback-xyz", "isReady": true, "duration": 120.5, "aspect_ratio": "16:9", "updatedAt": "2024-01-15T10:30:00Z" } ``` -------------------------------- ### Webhook Setup for Local Development Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md Use ngrok or Smee.io to expose your local Strapi instance to receive Mux webhooks during development. Configure the webhook URL in your Mux dashboard. ```bash ngrok http 1337 # Then configure webhook URL: https://abc123.ngrok.io/mux-video-uploader/webhook-handler ``` -------------------------------- ### Delete Asset Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Example JSON response after successfully deleting an asset record from Strapi. ```JSON { "id": 10, "title": "New Asset", "upload_id": "upload-123", "updatedAt": "2024-01-15T11:30:00Z" } ``` -------------------------------- ### Example cURL for Creating a Mux Asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-asset-controller.md Demonstrates how to create a Mux Asset using cURL, specifying the title and upload ID. ```bash curl -X POST http://localhost:1337/mux-video-uploader/mux-asset \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "body": { "title": "New Asset", "upload_id": "upload-123", "signed": false } }' ``` -------------------------------- ### Get Storyboard Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Retrieves a storyboard VTT file for a specific Mux asset. ```APIDOC ## GET /mux-video-uploader/storyboard/:documentId ### Description Proxy storyboard VTT files for a Mux asset. ### Method GET ### Endpoint /mux-video-uploader/storyboard/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the Mux asset. ### Purpose Proxy storyboard VTT ``` -------------------------------- ### Sign Playback ID Response Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md This is an example of a successful (200 OK) response from the sign playback ID endpoint. It returns a JWT token that can be used for secure playback of Mux video or thumbnail content. ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### Use Signing Key for Signed Playback in Config Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md Example of how to use Mux Signing Key ID and Private Key for signed playback within the plugin configuration, typically retrieved from environment variables. ```typescript playbackSigningId: env('MUX_SIGNING_KEY_ID'), playbackSigningSecret: env('MUX_SIGNING_KEY_PRIVATE_KEY'), ``` -------------------------------- ### Mux Webhook Handler Request Body Example Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md This is an example of the JSON payload received by the webhook handler endpoint when a Mux video asset is ready for playback. It contains essential data for updating the Strapi entry. ```json { "type": "video.asset.ready", "data": { "id": "asset-abc123", "playback_ids": [ {"id": "playback-xyz"} ], "duration": 120.5, "aspect_ratio": "16:9" } } ``` -------------------------------- ### Get Plugin Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/utility-functions.md Retrieves plugin configuration asynchronously. This is necessary for initializing Mux clients with credentials. ```typescript const getConfig = async (): Promise ``` ```typescript const config = await getConfig(); const muxClient = new Mux({ tokenId: config.accessTokenId, tokenSecret: config.secretKey, }); ``` -------------------------------- ### GET /mux-video-uploader/mux-asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Returns a paginated list of Mux assets. Supports filtering, sorting, and pagination parameters. ```APIDOC ## GET /mux-video-uploader/mux-asset ### Description Returns paginated list of assets. ### Method GET ### Endpoint /mux-video-uploader/mux-asset ### Parameters #### Query Parameters - **limit** (number) - Optional - Max records per page (default: 25). - **offset** (number) - Optional - Number of records to skip (default: 0). - **sort** (string) - Optional - Field to sort by (default: 'createdAt'). - **order** (string) - Optional - 'asc' or 'desc' (default: 'desc'). - **filters[title]** (string) - Optional - Filter by title substring. - **filters[asset_id]** (string) - Optional - Filter by Mux asset ID. ### Response #### Success Response (200 OK) - **items** (array) - List of assets. - **id** (number) - The Strapi entry ID. - **title** (string) - The video title. - **asset_id** (string) - The Mux asset ID. - **playback_id** (string) - The Mux playback ID. - **isReady** (boolean) - Indicates if the asset is ready. - **createdAt** (string) - The timestamp of creation. - **updatedAt** (string) - The timestamp of the last update. - **totalCount** (number) - The total number of assets. ``` -------------------------------- ### Mux Video Uploader Plugin Dependencies Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md These are the core dependencies included with the Mux Video Uploader plugin. No additional installation is required for these. ```json { "@mux/mux-node": "^12.8.0", "@mux/upchunk": "^3.5.0", "axios": "^1.7.7", "zod": "^3.22.4" } ``` -------------------------------- ### Use Mux API Credentials in Config Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md Example of how to use Mux API Access Token ID and Secret Key within the plugin configuration, typically retrieved from environment variables. ```typescript accessTokenId: env('MUX_ACCESS_TOKEN_ID'), secretKey: env('MUX_SECRET_KEY'), ``` -------------------------------- ### Example cURL for Updating Mux Asset Text Tracks Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-asset-controller.md Updates the text tracks for a Mux Asset using cURL, including adding a new subtitle file. ```bash # Update text tracks curl -X PUT http://localhost:1337/mux-video-uploader/mux-asset/5 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "custom_text_tracks": [{ "name": "English Subtitles", "language_code": "en", "closed_captions": false, "file": { "contents": "WEBVTT\n\n00:00:00.000 --> 00:00:05.000\nHello world", "type": "text/vtt", "name": "en.vtt", "size": 42 } }] }' ``` -------------------------------- ### Health Check for Mux Plugin Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-settings-controller.md This TypeScript example shows how to include the Mux plugin's configuration status in a health check. It fetches the status and can be used to report on the plugin's readiness. ```typescript const healthCheck = { database: 'ok', muxPluginConfigured: await fetch('/mux-video-uploader/mux-settings'), }; ``` -------------------------------- ### Configuration Options Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/MANIFEST.md Details on how to configure the Mux Video Uploader Strapi plugin, including plugin configuration options, environment variables, and content type schemas. ```APIDOC ## Configuration The Mux Video Uploader Strapi plugin can be configured through several mechanisms: ### Plugin Config Options - **Total**: 5 required/optional options. ### Environment Variables - **Recommended**: 8+ environment variables for advanced configuration. ### Content Types - **Mux Asset**: A content type with 8 attributes to manage Mux assets. - **Mux Text Track**: A content type with 4 attributes to manage text tracks for Mux assets. ### Permissions - **Actions**: 6 distinct permission actions available for controlling access. ### Webhook Events - **Types**: 4 different types of webhook events that can be received from Mux. ``` -------------------------------- ### Initialize Husky Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README_INTERNAL.md Initializes Husky to set up pre-commit hooks for local development. ```bash % yarn prepare ``` -------------------------------- ### Check Plugin Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md Verify the plugin's configuration status and check for required credentials. This endpoint helps ensure the plugin is set up correctly. ```bash GET /mux-video-uploader/mux-settings ``` -------------------------------- ### Check Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Verifies if the Mux Video Uploader plugin is correctly configured with necessary credentials. ```APIDOC ## GET /mux-video-uploader/mux-settings ### Description Check if the Mux Video Uploader plugin is configured. ### Method GET ### Endpoint /mux-video-uploader/mux-settings ### Purpose Check if configured ``` -------------------------------- ### Configure Mux Plugin with JavaScript Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README.md Configure the Mux video uploader plugin using Strapi's file-based configuration with JavaScript. Ensure environment variables are set for authentication and signing keys. ```javascript // Path: ./config/plugins.js module.exports = ({env}) => ({ // ... "mux-video-uploader": { enabled: true, config: { accessTokenId: env('ACCESS_TOKEN_ID'), secretKey: env('ACCESS_TOKEN_SECRET'), webhookSigningSecret: env('WEBHOOK_SIGNING_SECRET'), playbackSigningId: env('SIGNING_KEY_ID'), playbackSigningSecret: env('SIGNING_KEY_PRIVATE_KEY'), } } // ... }); ``` -------------------------------- ### Get Thumbnail Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Retrieves a thumbnail image for a specific Mux asset. ```APIDOC ## GET /mux-video-uploader/thumbnail/:documentId ### Description Proxy thumbnail images for a Mux asset. ### Method GET ### Endpoint /mux-video-uploader/thumbnail/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the Mux asset. ### Purpose Proxy thumbnail images ``` -------------------------------- ### Get Single Asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md Retrieves a single asset record by its Strapi ID. ```APIDOC ## GET /mux-video-uploader/mux-asset/:documentId ### Description Retrieves a single asset record by its Strapi ID. ### Method GET ### Endpoint /mux-video-uploader/mux-asset/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - The Strapi ID of the asset record to retrieve. ### Response #### Success Response (200) - Returns the asset object with details. - **id** (string) - The Strapi record ID. - **muxAssetId** (string) - The Mux Asset ID. - **uploadId** (string) - The Mux Upload ID. - **playbackId** (string) - The Mux Playback ID. - **status** (string) - The processing status of the asset. - **createdAt** (string) - The timestamp when the asset record was created. - **updatedAt** (string) - The timestamp when the asset record was last updated. #### Response Example ```json { "id": "strapi_id_123", "muxAssetId": "mux_asset_abc123", "uploadId": "upload_xyz789", "playbackId": "playback_def456", "status": "ready", "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:05:00Z" } ``` ``` -------------------------------- ### Get Single Asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Retrieves detailed information for a specific Mux asset by its ID. ```APIDOC ## GET /mux-video-uploader/mux-asset/:documentId ### Description Get detailed information for a single Mux asset. ### Method GET ### Endpoint /mux-video-uploader/mux-asset/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the Mux asset. ### Purpose Get single asset ``` -------------------------------- ### Configure Mux Plugin with TypeScript Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README.md Configure the Mux video uploader plugin using Strapi's file-based configuration with TypeScript. Ensure environment variables are set for authentication and signing keys. ```typescript // Path: ./config/plugins.ts export default ({env}) => ({ // ... "mux-video-uploader": { enabled: true, config: { accessTokenId: env('ACCESS_TOKEN_ID'), secretKey: env('ACCESS_TOKEN_SECRET'), webhookSigningSecret: env('WEBHOOK_SIGNING_SECRET'), playbackSigningId: env('SIGNING_KEY_ID'), playbackSigningSecret: env('SIGNING_KEY_PRIVATE_KEY'), } } // ... }); ``` -------------------------------- ### Content API Count Assets Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Publicly accessible endpoint to get the total count of assets. ```HTTP GET /api/mux-asset/count ``` -------------------------------- ### Build Project Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README_INTERNAL.md Compiles the TypeScript code into JavaScript output in the ./dist directory. ```bash % yarn build ``` -------------------------------- ### Get Asset Count Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Retrieves the total count of assets. Supports filtering by ready status. ```HTTP GET /mux-video-uploader/mux-asset/count ``` -------------------------------- ### Strapi Plugin Mux Video Uploader Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-settings-controller.md This configuration snippet shows how to set up the Mux Video Uploader plugin in Strapi, including required and optional Mux API credentials. Ensure MUX_ACCESS_TOKEN_ID, MUX_SECRET_KEY, and MUX_WEBHOOK_SIGNING_SECRET environment variables are set. ```bash # config/plugins.ts 'mux-video-uploader': { enabled: true, config: { accessTokenId: env('MUX_ACCESS_TOKEN_ID'), // Required secretKey: env('MUX_SECRET_KEY'), // Required webhookSigningSecret: env('MUX_WEBHOOK_SIGNING_SECRET'), // Required playbackSigningId: env('MUX_SIGNING_KEY_ID'), // Optional playbackSigningSecret: env('MUX_SIGNING_KEY_PRIVATE_KEY'), // Optional }, } ``` -------------------------------- ### JavaScript Plugin Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md Configure the Mux Video Uploader plugin using JavaScript in `config/plugins.js`. Ensure all required environment variables are set. ```javascript // config/plugins.js module.exports = ({ env }) => ({ 'mux-video-uploader': { enabled: true, config: { accessTokenId: env('MUX_ACCESS_TOKEN_ID'), secretKey: env('MUX_SECRET_KEY'), webhookSigningSecret: env('MUX_WEBHOOK_SIGNING_SECRET'), playbackSigningId: env('MUX_SIGNING_KEY_ID'), playbackSigningSecret: env('MUX_SIGNING_KEY_PRIVATE_KEY'), }, }, }); ``` -------------------------------- ### Example cURL for Updating Mux Asset Title Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-asset-controller.md Updates only the title of a Mux Asset using cURL. ```bash # Update title only curl -X PUT http://localhost:1337/mux-video-uploader/mux-asset/5 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "title": "Updated Title" }' ``` -------------------------------- ### Content API Get Single Asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Publicly accessible endpoint to retrieve a single asset by its ID. ```HTTP GET /api/mux-asset/:documentId ``` -------------------------------- ### Verify Plugin Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md Checks if the plugin is correctly configured with necessary credentials. ```APIDOC ## GET /mux-video-uploader/mux-settings ### Description Checks if the plugin is correctly configured with necessary credentials. ### Method GET ### Endpoint /mux-video-uploader/mux-settings ### Response #### Success Response (200) - **configured** (boolean) - True if the plugin is configured, false otherwise. - **message** (string) - A message indicating the configuration status. #### Response Example ```json { "configured": true, "message": "Mux plugin is configured correctly." } ``` ``` -------------------------------- ### Version and Tag Release Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README_INTERNAL.md Bumps the version in package.json and creates a Git tag for a new release. ```bash npm version patch -m "Bump for 3.1.2" ``` -------------------------------- ### Get Text Track Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Serves text track files (e.g., subtitles, captions) for a Mux asset. ```APIDOC ## GET /mux-video-uploader/mux-text-tracks/:documentId ### Description Serve text track files for a Mux asset. ### Method GET ### Endpoint /mux-video-uploader/mux-text-tracks/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the Mux asset. ### Purpose Serve text track files ``` -------------------------------- ### Create Signed Playback Token Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md Generate a signed playback token for secure video or thumbnail access. Specify the playback ID and the type (video or thumbnail) to create the token. ```bash GET /mux-video-uploader/sign/:playbackId?type=video ``` -------------------------------- ### Get Single Asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Retrieves a single asset by its Strapi document ID. Returns detailed asset information. ```HTTP GET /mux-video-uploader/mux-asset/:documentId ``` -------------------------------- ### Get Translation Utility Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/utility-functions.md Utility function for retrieving translation strings for admin UI internationalization. Handles multiple languages. ```typescript function getTranslation(key: string, defaultMessage?: string): string ``` -------------------------------- ### TypeScript Plugin Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md Configure the Mux Video Uploader plugin using TypeScript in `config/plugins.ts`. Ensure all required environment variables are set. ```typescript // config/plugins.ts export default ({ env }) => ({ 'mux-video-uploader': { enabled: true, config: { accessTokenId: env('MUX_ACCESS_TOKEN_ID'), secretKey: env('MUX_SECRET_KEY'), webhookSigningSecret: env('MUX_WEBHOOK_SIGNING_SECRET'), playbackSigningId: env('MUX_SIGNING_KEY_ID'), playbackSigningSecret: env('MUX_SIGNING_KEY_PRIVATE_KEY'), }, }, }); ``` -------------------------------- ### Get Plugin Service Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/utility-functions.md Retrieves a plugin service by name with full type safety. Use this to access Mux-specific functionalities. ```typescript const getService = ( name: ServiceName ): ServiceType ``` ```typescript // In controllers const muxService = getService('mux'); const asset = await muxService.getAssetById('asset-123'); // Type is automatically inferred as MuxService ``` -------------------------------- ### Minimum Plugin Configuration Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md This is the essential configuration required to enable the Mux Video Uploader plugin. It includes Mux API credentials and a webhook signing secret. ```typescript // config/plugins.ts 'mux-video-uploader': { enabled: true, config: { accessTokenId: env('MUX_ACCESS_TOKEN_ID'), secretKey: env('MUX_SECRET_KEY'), webhookSigningSecret: env('MUX_WEBHOOK_SIGNING_SECRET'), }, } ``` -------------------------------- ### Get Single Asset (Content API) Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Retrieves a single asset by its ID via the Content API. This endpoint is publicly accessible. ```APIDOC ## GET /api/mux-asset/:documentId ### Description Returns a single asset by ID. ### Method GET ### Endpoint /api/mux-asset/:documentId ### Auth Not required ### Parameters #### Path Parameters - **documentId** (string | number) - Required - Strapi document ID ``` -------------------------------- ### Create Asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Creates a new asset record in Strapi. ```APIDOC ## POST /mux-video-uploader/mux-asset ### Description Creates a new asset record. ### Method POST ### Endpoint /mux-video-uploader/mux-asset ### Request Body - **title** (string) - Required - The title of the new asset. - **upload_id** (string) - Required - The Mux Upload ID. - **signed** (boolean) - Optional - Indicates if the asset should be signed for playback. ### Request Example ```json { "title": "New Asset", "upload_id": "upload-123", "signed": false } ``` ### Response #### Success Response (201 Created) - **id** (integer) - The unique identifier of the newly created asset. - **title** (string) - The title of the asset. - **upload_id** (string) - The Mux Upload ID. - **signed** (boolean) - Indicates if the asset is signed for playback. - **createdAt** (string) - The timestamp when the asset was created. - **updatedAt** (string) - The timestamp when the asset was last updated. #### Response Example ```json { "id": 10, "title": "New Asset", "upload_id": "upload-123", "signed": false, "createdAt": "2024-01-15T11:00:00Z", "updatedAt": "2024-01-15T11:00:00Z" } ``` ``` -------------------------------- ### GET /mux-video-uploader/mux-text-tracks/:documentId Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Serves stored subtitle/caption files for Mux to download. Accepts a Strapi text track document ID. ```APIDOC ## GET /mux-video-uploader/mux-text-tracks/:documentId ### Description Serves stored subtitle/caption files for Mux to download. ### Method GET ### Endpoint /mux-video-uploader/mux-text-tracks/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - Strapi text track document ID. ### Response #### Success Response (200 OK) - Content-Type: File type (e.g., `text/vtt; charset=utf-8`) - Content-Disposition: `attachment; filename=track.vtt` - Body: VTT or SRT file contents #### Status Codes - `200 OK`: File returned - `404 Not Found`: Track doesn't exist ``` -------------------------------- ### Mux Video Uploader Plugin File Structure Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Overview of the server and admin source code directories and their primary files. This structure helps understand the plugin's organization and where specific functionalities reside. ```tree server/src/ ├── index.ts # Plugin entry point ├── bootstrap.ts # Plugin initialization ├── register.ts # Plugin registration (empty) ├── destroy.ts # Plugin teardown (empty) ├── config/ │ └── index.ts # Configuration schema & defaults ├── constants/ │ └── index.ts # PLUGIN_NAME, CONFIG_NAME ├── controllers/ │ ├── index.ts # Controller registry │ ├── mux.ts # Upload/webhook handlers (8 methods) │ ├── mux-asset.ts # Asset CRUD (6 methods) │ └── mux-settings.ts # Settings check (1 method) ├── content-types/ │ ├── index.ts # Content type registry │ ├── mux-asset/ │ │ ├── index.ts # Asset attributes │ │ └── types.d.ts # TypeScript types │ └── mux-text-track/ │ └── index.ts # Text track attributes ├── services/ │ ├── index.ts # Service registry │ └── mux.ts # Mux API wrapper (8 methods) ├── routes/ │ ├── index.ts # Route registry │ ├── admin.ts # Admin API routes (14) │ └── client.ts # Content API routes (3) ├── utils/ │ ├── index.ts # Utility exports │ ├── config.ts # getConfig() │ ├── types.ts # Type helpers, model names │ ├── parse-json-body.ts # parseRequest() │ ├── resolve-mux-asset.ts # resolveMuxAsset() │ ├── text-tracks.ts # Text track management │ ├── sync.ts # Asset synchronization │ └── rate-limit.ts # Rate limiting admin/src/ ├── index.ts # Admin plugin entry ├── pluginId.ts # PLUGIN_ID constant ├── types.ts # SearchField, SearchVector, SortVector ├── permissions.ts # Permission definitions ├── components/ │ ├── Initializer.tsx # Plugin initialization │ ├── PluginIcon.tsx # Menu icon │ └── [other UI components] ├── pages/ │ ├── App.tsx # Main plugin page │ └── HomePage.tsx # Home page ├── utils/ │ ├── getTranslation.ts # i18n helper │ ├── mux.ts # Mux client setup │ ├── url.ts # URL utilities │ └── [other helpers] └── translations/ # 18+ language files ``` -------------------------------- ### Example cURL for Deleting a Mux Asset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-asset-controller.md Deletes a Mux Asset record from Strapi using its document ID via a cURL request. ```bash curl -X DELETE http://localhost:1337/mux-video-uploader/mux-asset/5 \ -H "Authorization: Bearer " ``` -------------------------------- ### List Assets Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md Use this endpoint to retrieve a list of Mux assets with pagination and sorting options. Specify limit, offset, sort field, and order for customized results. ```bash GET /mux-video-uploader/mux-asset?limit=10&offset=0&sort=createdAt&order=desc ``` -------------------------------- ### Serve Text Track Files Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Stores text track files for Mux assets. ```APIDOC ## POST /api/text-tracks/store ### Description Stores text track files associated with a Mux asset. ### Method POST ### Endpoint /api/text-tracks/store ### Parameters #### Request Body - **assetId** (string) - Required - The Mux asset ID. - **tracks** (array) - Required - An array of text track objects. ### Response #### Success Response (200) - Confirmation of successful storage, potentially returning updated asset information. ### Response Example ```json { "message": "Text tracks stored successfully." } ``` ``` -------------------------------- ### Use Webhook Signing Secret in Config Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/configuration.md Example of how to use the Mux Webhook Signing Secret within the plugin configuration, typically retrieved from environment variables. ```typescript webhookSigningSecret: env('MUX_WEBHOOK_SIGNING_SECRET'), ``` -------------------------------- ### Resolve Mux Asset in Controller Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/resolve-mux-asset-utils.md Example of using `resolveMuxAsset` within a Strapi controller to retrieve a Mux asset based on the document ID from request parameters. ```typescript const update = async (ctx: Context) => { const { documentId } = ctx.params; const muxAsset = await resolveMuxAsset({ id: documentId }); // Now we have the asset with all fields console.log(muxAsset.asset_id, muxAsset.playback_id); }; ``` -------------------------------- ### Direct Upload Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/INDEX.md Initiates a direct upload process by obtaining a presigned URL for uploading video files. ```APIDOC ## POST /mux-video-uploader/direct-upload ### Description Get presigned upload URL for direct uploads. ### Method POST ### Endpoint /mux-video-uploader/direct-upload ### Purpose Get presigned upload URL ``` -------------------------------- ### Get Mux Asset by ID Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-service.md Retrieves a Mux asset using its unique asset ID. Useful for fetching asset details after creation or for existing assets. ```typescript async getAssetById(assetId: string): Promise ``` ```typescript const muxService = strapi.plugin('mux-video-uploader').service('mux'); const asset = await muxService.getAssetById('asset-123'); console.log(asset.playback_ids, asset.duration, asset.status); ``` -------------------------------- ### Implementation of resolveMuxAsset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/resolve-mux-asset-utils.md Shows the internal implementation of `resolveMuxAsset`, detailing how it queries the Strapi database using provided filters and handles different result scenarios. ```typescript const muxAssets = await strapi.db.query(ASSET_MODEL).findMany({ filters, }); const asset = muxAssets ? (Array.isArray(muxAssets) ? muxAssets[0] : muxAssets) : undefined; if (!asset) throw new Error('Unable to resolve mux-asset'); return asset; ``` -------------------------------- ### GET /mux-video-uploader/thumbnail/:documentId Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Proxies thumbnail images from the Mux Image API. It accepts a Mux playback ID or asset ID and an optional signed playback token. ```APIDOC ## GET /mux-video-uploader/thumbnail/:documentId ### Description Proxies thumbnail images from Mux Image API. ### Method GET ### Endpoint /mux-video-uploader/thumbnail/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - Mux playback ID or asset ID. #### Query Parameters - **token** (string) - Optional - Signed playback token. ### Response #### Success Response (200 OK) - Content-Type: `image/jpeg` - Body: JPEG image stream ``` -------------------------------- ### storyboard Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-controller.md Proxies storyboard (spritesheet) requests from the Mux Image API, returning WebP-formatted VTT storyboard files. ```APIDOC ## GET /mux-video-uploader/storyboard/:documentId ### Description Proxies storyboard (spritesheet) requests from Mux Image API. Returns WebP-formatted VTT storyboard files. ### Method GET ### Endpoint /mux-video-uploader/storyboard/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - Mux playback ID or asset ID #### Query Parameters - **token** (string) - Optional - Signed token for secured playback ### Response #### Success Response (200 OK) - **Content-Type**: `text/vtt` - **Body**: VTT storyboard format with WebP image references ``` -------------------------------- ### Get Direct Upload URL Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-service.md Creates a presigned URL for direct browser-based uploads to Mux. Allows configuration of video quality, text tracks, and MP4 support. ```typescript async getDirectUploadUrl(options: { config: ParsedUploadConfig; storedTextTracks?: StoredTextTrack[]; corsOrigin?: string; }): Promise ``` ```typescript const uploadUrl = await muxService.getDirectUploadUrl({ config: { mp4_support: 'standard', max_resolution_tier: '1080p', video_quality: 'plus', signed: false, }, storedTextTracks: [], corsOrigin: 'https://example.com', }); console.log(uploadUrl.url); // Presigned URL for client-side upload ``` -------------------------------- ### Troubleshooting: Plugin Not Showing in Admin Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/README.md If the plugin is not visible in the Strapi admin panel, try clearing the cache and rebuilding the project. ```bash rm -rf .cache build .strapi npm run build ``` -------------------------------- ### GET /mux-video-uploader/sign/:documentId Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Generates a signed JWT token for secure playback. Requires Super Admin authentication and accepts a Mux playback ID and a type parameter for expiry. ```APIDOC ## GET /mux-video-uploader/sign/:documentId ### Description Generates a signed JWT token for secure playback. ### Method GET ### Endpoint /mux-video-uploader/sign/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - Mux playback ID. #### Query Parameters - **type** (string) - Required - 'video' (1 day expiry) or 'thumbnail' (1 minute expiry). ### Response #### Success Response (200 OK) - **token** (string) - The generated JWT token. ``` -------------------------------- ### isConfigured Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/mux-settings-controller.md Checks if the Mux plugin has been properly configured with all required Mux API credentials. It returns a boolean indicating the configuration status. ```APIDOC ## GET /mux-video-uploader/mux-settings ### Description Checks if the plugin configuration is complete. Returns true only if all required credentials are set. ### Method GET ### Endpoint /mux-video-uploader/mux-settings ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200 OK) - **(boolean)** - Returns `true` if all required configuration fields (`accessTokenId`, `secretKey`, `webhookSigningSecret`) are set, otherwise returns `false`. ### Response Example ```json true ``` ```json false ``` ### Permissions Auth: Required (Super Admin) ``` -------------------------------- ### Clean Strapi Cache and Build Folders Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/README.md Use this command to remove temporary Strapi directories before rebuilding the instance. This is often necessary when the Strapi Admin UI does not display the plugin after installation. ```bash rm -rf ./.cache ./build ./.strapi ``` -------------------------------- ### Error Handling for resolveMuxAsset Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/resolve-mux-asset-utils.md Illustrates how to implement a try-catch block to handle the error thrown by `resolveMuxAsset` when a matching asset is not found in the database. ```typescript try { const asset = await resolveMuxAsset({ upload_id }); } catch (err) { console.error('Asset not found:', err.message); ctx.notFound('mux-asset.notFound'); } ``` -------------------------------- ### Resolve Mux Asset in Service for Text Track Updates Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/api-reference/resolve-mux-asset-utils.md Example of using `resolveMuxAsset` within a service function to retrieve a Mux asset by its ID before processing text track updates. ```typescript const updateTextTracks = async (assetId: string, newTracks: any[]) => { const muxAsset = await resolveMuxAsset({ id: assetId }); if (!muxAsset.asset_id || !muxAsset.playback_id) { throw new Error('Asset not ready for track updates'); } // Process track updates }; ``` -------------------------------- ### GET /mux-video-uploader/storyboard/:documentId Source: https://github.com/muxinc/strapi-plugin-mux-video-uploader/blob/master/_autodocs/endpoints.md Proxies storyboard (spritesheet) VTT files from the Mux Image API. It accepts a Mux playback ID or asset ID and an optional signed playback token. ```APIDOC ## GET /mux-video-uploader/storyboard/:documentId ### Description Proxies storyboard (spritesheet) VTT files from Mux Image API. ### Method GET ### Endpoint /mux-video-uploader/storyboard/:documentId ### Parameters #### Path Parameters - **documentId** (string) - Required - Mux playback ID or asset ID. #### Query Parameters - **token** (string) - Optional - Signed playback token. ### Response #### Success Response (200 OK) - Content-Type: `text/vtt` - Body: VTT format with WebP sprite references ```