iframe Events

The iframe emits events to enable flow customizations in combination with our API.

General Event Mechanism

When users perform certain actions within the iframe, the iframe posts a message to the parent window using postMessage(). The event payload contains context about the action the user performed and their current session. You can use the event context to communicate with our API to customize the user flow.

Download Event

When a user clicks the download button in the mastering widget, the iframe posts the following event to the parent window.

source: 'masterchannelai',
type: 'iframe:request_master_download',
payload: {
    job: {...}
}

If you want to build your own payment flow, this is the moment you present the user with different payment options. After the user has completed their purchase, perform these steps:

  1. Use the job object contained in the event payload as the body for a request to the PUT /jobs endpoint.
  2. Wait for the job to complete, either via webhook or polling. This should happen within 20 seconds since a preview job already exists from the user session.
  3. Extract the file_id of the "type": "master" object from the output field of the finished job.
  4. Make a request to the GET /files/{file_id} endpoint to retrieve the public download URL of the master file.

Please note that download URLs are only valid for a certain time period, and jobs and files are not stored forever. Follow our API best practices and copy the master file to your system for later retrieval, or at least regenerate the public download URL as required so users can still access their purchased master later.