> ## Documentation Index > Fetch the complete documentation index at: https://www.canva.dev/docs/apps/llms.txt > Use this file to discover all available pages before exploring further. # prepareContentPublisher API reference for the prepareContentPublisher method. NOTE: **This API is a preview**. Preview APIs are unstable and may change without warning. You can't release public apps using this API until it's stable. Prepares a Content Publisher Intent. ## Usage ```tsx import { prepareContentPublisher } from "@canva/intents/content"; prepareContentPublisher({ getPublishConfiguration: async (params) => { // Implement the logic to get the publish configuration }, renderSettingsUi: (params) => { // Implement the UI for settings view }, renderPreviewUi: (params) => { // Implement the UI for preview view }, publishContent: async (params) => { // Implement the logic to publish the content }, }); ``` ## Parameters Main interface for implementing the ContentPublisher intent. Implementing the ContentPublisher intent enables apps to publish contents to external platforms. This allows users to configure publish settings, preview their designs, and share with others. The publishing flow follows this process: 1. User initiates publish action 2. Your app provides publish configuration via `getPublishConfiguration` 3. User selects an output type 4. Your app renders settings UI via `renderSettingsUi` 5. Your app renders preview UI via `renderPreviewUi` 6. User reviews settings and preview 7. Your app publishes the content via `publishContent` Properties of implementation}> Provides the configuration for the publishing platform. This action is called when the user initiates the publish flow and needs to select an output type for the target platform. Use this to define different publishing configurations for your platform, such as social media posts, videos, or other output types. **Example: Defining publish configuration for a social media platform** ```ts import type { GetPublishConfigurationResponse } from '@canva/intents/content'; async function getPublishConfiguration(): Promise { return { status: 'completed', outputTypes: [ { id: 'instagram_post', displayName: 'Instagram Post', mediaSlots: [ { id: 'main_image', displayName: 'Post Image', fileCount: { min: 1, max: 10 }, accepts: { image: { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 } } } } ] } ] }; } ``` **Returns** A promise resolving to the publish configuration or an error. This is a `Promise` that resolves with the following object: Successful response from getting publish configuration. The only valid value is `"completed"`. Array of available output types for your platform. Define different output types for various content formats that your platform supports (e.g., posts, stories, videos). Properties of outputTypes}> Unique identifier for this output type. Use descriptive IDs like `"instagram_post"` or `"youtube_video"`. User-facing name for this output type. This is displayed to users when selecting where to publish. Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`. Array of media slots defining what content is needed. Each slot represents a piece of media required for publishing, such as a main image, thumbnail, or video. Configuration for a media slot within an output type. Defines what type of media is accepted, requirements, and constraints. **Example: Image slot with aspect ratio requirements** ```ts const thumbnailSlot: MediaSlot = { id: 'thumbnail', displayName: 'Video Thumbnail', fileCount: { exact: 1 }, accepts: { image: { format: 'jpg', aspectRatio: { exact: 16/9 }, } } }; ``` Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. File type requirements for this slot. Note the following behavior: * Provide at least one of the valid types * If multiple types are provided, files for this slot may be any of the accepted types; each file must satisfy the corresponding requirement for its media type * To restrict the slot to a single media type, provide only that requirement * `fileCount` applies across all files accepted by the slot regardless of media type * Document output types will show image previews (PNG thumbnail) in preview UI Properties of accepts}> Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` Properties of image}> File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Properties of video}> Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Properties of document}> Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email output types will show a single html file (canva hosted assets) preview in preview UI Properties of email}> File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * undefined: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Leaves Canva's own default selection in place, which it already does for a slot that omits this field. To pre-select multiple inputs in a slot, use MediaSlotWithAutoSelect. The default autoSelect behavior is informed by the `accepts` and `fileCount` fields. * If a single media type is accepted, Canva will pre-select the first valid input as a file for that type. * If multiple media types are accepted, Canva may infer a preferred media type from the current editor state. * If `fileCount` is not provided, no auto-selection will occur. The only valid value is `"default"`. Configuration for a media slot within an output type. Defines what type of media is accepted, requirements, and constraints. Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * `{ min: 0 }`: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` File type requirements for this slot. Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email file requirements for a media slot, currently only supports HTML bundle format. Note: Email output types use html\_standalone previews in the preview UI. The actual email file is only generated for the final output in OutputMedia. **Example: Email bundle requirements** ```ts const emailReq: EmailRequirement = { format: 'html_bundle', }; ``` File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Canva will pre-select all valid inputs as files for this slot when the publish panel first opens. **Example: Image slot with all valid inputs as files auto-selected** ```ts const thumbnailSlot: MediaSlotWithAutoSelect = { id: 'thumbnail', displayName: 'Video Thumbnail', fileCount: { exact: 1 }, accepts: { format: 'jpg', aspectRatio: { exact: 16 / 9 }, }, autoSelect: 'all_valid_inputs_as_files', }; ``` The only valid value is `"all_valid_inputs_as_files"`. The type of content being published. When set, Canva uses this to tailor and improve the publish experience. When omitted, defaults to `'content'` (generic behavior). **Available values**: * `"email"` * `"post"` * `"schedule"` * `"asset"` * `"draft"` * `"publication"` * `"content"` * `"content_export"` GetPublishConfigurationError error indicating a custom error occurred. The only valid value is `"app_error"`. (required) The raw error message, for logging purposes. It will not display in the UI. To display custom error messages in the UI use `localizedMessageId`. This should typically be the javascript error.message or a REST JSON error message body passed without modification. WARNING: Do not include personally identifiable information (PII) in this message, such as names, emails, usernames, etc. (optional) Message ID of the translated error message that will be displayed to the user. The message ID should be present and uploaded in your translation file. If omitted, Canva will display a generic error message. HTTP status code, if applicable Used only by app developer. Canva does not use this value. Use this to pass additional information like JSON to your settings frame. (optional) Source of the error if it relates to a component on the Canva UI. When present, the error may render near a relevant Canva component. When omitted, the cause is considered unspecified or "generic". **Available values**: * `"invalid_selection"` * `"invalid_format"` Renders a user interface for configuring publish settings. This action is called after the user selects an output type. Your UI should allow users to configure platform-specific settings such as captions, tags, privacy settings, or publishing destinations. Use the `updatePublishSettings` callback to save user settings and validate them. Settings are stored in the `publishRef` string (maximum 32KB). **Example: Rendering a settings UI with publish configuration** ```ts import { createRoot } from 'react-dom/client'; import type { RenderSettingsUiRequest } from '@canva/intents/content'; function renderSettingsUi(request: RenderSettingsUiRequest): void { const SettingsUiApp = () => ( ); createRoot().render() } ``` **Parameters** Configuration and callbacks for the publish settings UI. Properties of request}> The initial settings and context provided when the settings UI is rendered. Contains any previously saved publish settings and information about the current output type being configured. Use this to restore the UI to its previous state or initialise it with appropriate defaults. Properties of invocationContext}> Initial settings and context provided when the settings UI is rendered. The only valid value is `"publish"`. Current publish reference to populate the UI, if any exist Information about the current output type being configured Properties of outputType}> Unique identifier for this output type. Use descriptive IDs like `"instagram_post"` or `"youtube_video"`. User-facing name for this output type. This is displayed to users when selecting where to publish. Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`. Array of media slots defining what content is needed. Each slot represents a piece of media required for publishing, such as a main image, thumbnail, or video. Properties of mediaSlots}> Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. File type requirements for this slot. Note the following behavior: * Provide at least one of the valid types * If multiple types are provided, files for this slot may be any of the accepted types; each file must satisfy the corresponding requirement for its media type * To restrict the slot to a single media type, provide only that requirement * `fileCount` applies across all files accepted by the slot regardless of media type * Document output types will show image previews (PNG thumbnail) in preview UI Properties of accepts}> Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` Properties of image}> File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Properties of video}> Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Properties of document}> Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email output types will show a single html file (canva hosted assets) preview in preview UI Properties of email}> File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * undefined: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Leaves Canva's own default selection in place, which it already does for a slot that omits this field. To pre-select multiple inputs in a slot, use MediaSlotWithAutoSelect. The default autoSelect behavior is informed by the `accepts` and `fileCount` fields. * If a single media type is accepted, Canva will pre-select the first valid input as a file for that type. * If multiple media types are accepted, Canva may infer a preferred media type from the current editor state. * If `fileCount` is not provided, no auto-selection will occur. The only valid value is `"default"`. Current selection for this slot. Selection metadata for an image media item. The only valid value is `"image"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a video media item. The only valid value is `"video"`. Duration of the selected video in milliseconds. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a document media item. The only valid value is `"document"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for an email media item. The only valid value is `"email"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The type of content being published. When set, Canva uses this to tailor and improve the publish experience. When omitted, defaults to `'content'` (generic behavior). **Available values**: * `"email"` * `"post"` * `"schedule"` * `"asset"` * `"draft"` * `"publication"` * `"content"` * `"content_export"` Callback to save and validate the user's publish settings. Call this function whenever the user modifies their settings to: * Save the settings for later use in `publishContent` * Validate that required fields are filled * Enable or disable the publish button based on validity Store all necessary publishing information in the `publishRef` string. This will be provided to your `publishContent` method when the user publishes. **Throws** Will throw `CanvaError('bad_request')` if PublishSettings.publishRef exceeds 32KB. **Example: Updating settings as user types** ```ts // As user fills in form fields, update settings function handleCaptionChange(caption: string) { const settings = { caption, tags: currentTags }; const publishRef = JSON.stringify(settings); updatePublishSettings({ publishRef, validityState: caption ? 'valid' : 'invalid_missing_required_fields' }); } ``` **Parameters** Configuration for publish settings. Contains the user's settings and their validation state. Use this to control whether the publish button is enabled. Properties of publishSettings}> Validation state of the publish settings. Controls whether the publish button is enabled: * `"valid"`: Settings are complete and valid, publish button is enabled * `"invalid_missing_required_fields"`: Required settings are missing, publish button is disabled * `"invalid_authentication_required"`: User must authenticate before publishing can proceed **Available values**: * `"valid"` * `"invalid_missing_required_fields"` * `"invalid_authentication_required"` Serialized platform-specific settings for publishing. Store all information your app needs to publish the content in this string. This might include: * Captions or descriptions * Tags or hashtags * Privacy settings * Publishing destination (account, page, etc.) * Scheduling information This reference will be provided to your `publishContent` method when publishing. Maximum size: 32KB **Example: Serializing settings** ```ts const settings = { caption: 'Check out my design!', tags: ['design', 'creative'], privacy: 'public' }; const publishRef = JSON.stringify(settings); ``` **Returns** A promise that resolves when the settings are successfully saved. This is a `Promise` that resolves with the following object: The only valid value is `"completed"`. Registers a callback to be invoked when the settings UI context changes. This callback is triggered when: * the user changes the output type in the publish flow. * an error occurs in the publish flow. Use this to respond to Canva changes and update your settings UI accordingly. **Example: Adapting UI for different output types** ```ts registerOnContextChange({ onContextChange: (ctx) => { if (ctx.reason === 'publish_settings') { if (ctx.outputType.id === 'instagram_post') { showHashtagField(); } } if (ctx.reason === 'publish_error') { setError(ctx.error); } } }); ``` **Parameters** The options for registering a callback. Properties of opts}> **Parameters** Context information for the publish settings UI. Provides information about the current state of the settings UI to help you adapt the interface based on the selected output type. The only valid value is `"publish_settings"`. The currently selected output type. Use this to customize your settings UI based on the requirements of different output types. Properties of outputType}> Unique identifier for this output type. Use descriptive IDs like `"instagram_post"` or `"youtube_video"`. User-facing name for this output type. This is displayed to users when selecting where to publish. Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`. Array of media slots defining what content is needed. Each slot represents a piece of media required for publishing, such as a main image, thumbnail, or video. Properties of mediaSlots}> Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. File type requirements for this slot. Note the following behavior: * Provide at least one of the valid types * If multiple types are provided, files for this slot may be any of the accepted types; each file must satisfy the corresponding requirement for its media type * To restrict the slot to a single media type, provide only that requirement * `fileCount` applies across all files accepted by the slot regardless of media type * Document output types will show image previews (PNG thumbnail) in preview UI Properties of accepts}> Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` Properties of image}> File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Properties of video}> Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Properties of document}> Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email output types will show a single html file (canva hosted assets) preview in preview UI Properties of email}> File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * undefined: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Leaves Canva's own default selection in place, which it already does for a slot that omits this field. To pre-select multiple inputs in a slot, use MediaSlotWithAutoSelect. The default autoSelect behavior is informed by the `accepts` and `fileCount` fields. * If a single media type is accepted, Canva will pre-select the first valid input as a file for that type. * If multiple media types are accepted, Canva may infer a preferred media type from the current editor state. * If `fileCount` is not provided, no auto-selection will occur. The only valid value is `"default"`. Current selection for this slot. Selection metadata for an image media item. The only valid value is `"image"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a video media item. The only valid value is `"video"`. Duration of the selected video in milliseconds. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a document media item. The only valid value is `"document"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for an email media item. The only valid value is `"email"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The type of content being published. When set, Canva uses this to tailor and improve the publish experience. When omitted, defaults to `'content'` (generic behavior). **Available values**: * `"email"` * `"post"` * `"schedule"` * `"asset"` * `"draft"` * `"publication"` * `"content"` * `"content_export"` Provides information about an error that occurred in publishContent. The only valid value is `"publish_error"`. The error that occurred. Undefined means no error occurred or the previous error was cleared by Canva. Properties of error}> Signals that the publish error was cleared. The only valid value is `"publish_error_cleared"`. **Returns** `void` **Returns** A disposer function that cleans up the registered callback. () => `void` Function to trigger a request for AI content. Use this function to trigger a request for AI content. **Param: request** The request for AI content. **Example: Requesting AI content** ```ts async function onGenerateCaption() { const result = await requestAiContent({ type: 'social_caption', currentValue: settings.caption, fieldLabel: 'Caption', hints: { maxLength: 2200, }, }); if (result.status !== 'completed') { return; } const nextSettings = { ...settings, caption: result.value }; // ... set local state await updatePublishSettings({ publishRef: JSON.stringify(nextSettings), validityState: 'valid', }); } ``` **Parameters** All possible AI content request types. Properties of request}> The label chosen by the app developer for the field. It will be used in the UI to customize the copy. Required since it is essential context for the AI to generate the content. The only valid value is `"social_caption"`. If a current value exists in the field, the AI content generation will be an edit-first experience. i.e. When the user has already entered a value in the field, the AI will generate a new value using the existing value as a starting point. Hints for how the AI should generate the caption. Properties of hints}> The maximum length of the caption. **Returns** All possible AI content response types. This is a `Promise` that resolves with the following object: }> Completed response for AI content generation. The value is the AI content generated for the app. The only valid value is `"completed"`. }> Cancelled response where the generation was not completed. We use only 'cancelled' since we don't expect app developers to handle any statuses further (e.g. blocked, failed). These will be handled on Canva's AI generation surface. The only valid value is `"cancelled"`. **Returns** `void` Renders a user interface for previewing the content. This action is called after the settings UI is rendered. Your UI should display a preview of how the content will appear on the target platform. Previews update dynamically as users modify their content or settings. For videos, start with lightweight thumbnails and use `requestPreviewUpgrade` to load full video previews on demand to optimize performance. **Example: Rendering a preview UI with video optimization** ```ts import { createRoot } from 'react-dom/client'; import type { RenderPreviewUiRequest } from '@canva/intents/content'; function renderPreviewUi(request: RenderPreviewUiRequest): void { const PreviewUiApp = () => ( ); createRoot().render() } ``` **Parameters** Configuration and callbacks for the preview UI. Properties of request}> The initial preview data and context provided when the preview UI is rendered. Contains the initial preview media, output type information, and any existing publish settings needed to properly display the preview interface. Properties of invocationContext}> Initial preview data and context provided when the preview UI is rendered. The only valid value is `"publish"`. Initial preview media to display This will only be used for scheduling and not caching Properties of previewMedia}> ID of the media slot this preview belongs to. Matches a media slot ID from your output type definition. Array of preview items for this media slot. May contain multiple previews if the media slot accepts multiple files. Image preview in various states. Image preview that is currently being generated. Display a loading state until the preview transitions to `"ready"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"image"`. Current state of the preview. The only valid value is `"loading"`. Width of the preview in pixels. Height of the preview in pixels. Image preview that is ready to display. Contains the URL to the preview image. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"image"`. Current state of the preview. The only valid value is `"ready"`. Image format of the preview. **Available values**: * `"png"` * `"jpg"` URL to the preview image. Use this URL to display the preview to users. Width of the preview in pixels. Height of the preview in pixels. Image preview that failed to generate. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"image"`. Current state of the preview. The only valid value is `"error"`. The error message to display to the user. Width of the preview in pixels. Height of the preview in pixels. Video preview in various states. Videos transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`. Start with thumbnails for better performance, then upgrade to full video using `requestPreviewUpgrade`. Video preview that is currently being generated. Display a loading state until the preview transitions to `"thumbnail"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"loading"`. Video duration in milliseconds. Video preview with lightweight thumbnail available. This is the initial state for video previews. Show the thumbnail image and call `requestPreviewUpgrade` when the user needs the full video. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"thumbnail"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the thumbnail image. Display this lightweight image until full video is needed. Video duration in milliseconds. Video preview that is being upgraded from thumbnail to full video. Display the thumbnail with a loading indicator until the video is ready. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"upgrading"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the thumbnail image. Continue showing the thumbnail while the full video loads. Video duration in milliseconds. Video preview with full video ready to play. Contains URLs for both the video and thumbnail. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"ready"`. Video format. The only valid value is `"mp4"`. URL to the full video. Use this URL in a video player. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the thumbnail image. Can be used as a poster image for the video player. Video duration in milliseconds. Video preview that failed to generate. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"error"`. The error message to display to the user. Document preview in various states. Documents transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`. Start with a lightweight thumbnail of the first page, then upgrade to full multi-page preview using `requestPreviewUpgrade`. Document preview that is currently being generated. Display a loading state until the preview transitions to `"thumbnail"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"loading"`. Width of the preview in pixels. Height of the preview in pixels. Document preview with first page thumbnail available. This is the initial state for document previews. Show the thumbnail image of the first page to give users a quick preview of the document. Call `requestPreviewUpgrade` to load all page thumbnails. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"thumbnail"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the first page thumbnail. Display this lightweight image to preview the document content. Width of the preview in pixels. Height of the preview in pixels. Intermediate state while multi-page document thumbnails are being fetched via requestPreviewUpgrade. The single-page thumbnail remains available for display during the upgrade. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"upgrading"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the first page thumbnail. Continue showing this while the upgrade loads. Width of the preview in pixels. Height of the preview in pixels. Final state after a document preview has been upgraded. Contains thumbnail URLs for every selected page in the document. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"ready"`. Format of the per-page thumbnails. **Available values**: * `"png"` * `"jpg"` Thumbnail pages for each page. Index corresponds to the page number. Properties of pages}> URL to the page thumbnail image. Width of the page thumbnail in pixels. Height of the page thumbnail in pixels. Document preview that failed to generate. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"error"`. The error message to display to the user. Width of the preview in pixels. Height of the preview in pixels. Email preview in various states. Display a loading state until the preview transitions to `"ready"` or `"error"`. Email preview in a loading state. Display a loading spinner until the preview transitions to `"ready"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"email"`. Current state of the preview. The only valid value is `"loading"`. Email preview in a ready state. Display the email preview. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"email"`. Current state of the preview. The only valid value is `"ready"`. URL to the single html file that represents the email. Email preview in an error state. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"email"`. Current state of the preview. The only valid value is `"error"`. Information about the current output type being previewed Properties of outputType}> Unique identifier for this output type. Use descriptive IDs like `"instagram_post"` or `"youtube_video"`. User-facing name for this output type. This is displayed to users when selecting where to publish. Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`. Array of media slots defining what content is needed. Each slot represents a piece of media required for publishing, such as a main image, thumbnail, or video. Properties of mediaSlots}> Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. File type requirements for this slot. Note the following behavior: * Provide at least one of the valid types * If multiple types are provided, files for this slot may be any of the accepted types; each file must satisfy the corresponding requirement for its media type * To restrict the slot to a single media type, provide only that requirement * `fileCount` applies across all files accepted by the slot regardless of media type * Document output types will show image previews (PNG thumbnail) in preview UI Properties of accepts}> Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` Properties of image}> File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Properties of video}> Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Properties of document}> Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email output types will show a single html file (canva hosted assets) preview in preview UI Properties of email}> File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * undefined: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Leaves Canva's own default selection in place, which it already does for a slot that omits this field. To pre-select multiple inputs in a slot, use MediaSlotWithAutoSelect. The default autoSelect behavior is informed by the `accepts` and `fileCount` fields. * If a single media type is accepted, Canva will pre-select the first valid input as a file for that type. * If multiple media types are accepted, Canva may infer a preferred media type from the current editor state. * If `fileCount` is not provided, no auto-selection will occur. The only valid value is `"default"`. Current selection for this slot. Selection metadata for an image media item. The only valid value is `"image"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a video media item. The only valid value is `"video"`. Duration of the selected video in milliseconds. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a document media item. The only valid value is `"document"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for an email media item. The only valid value is `"email"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The type of content being published. When set, Canva uses this to tailor and improve the publish experience. When omitted, defaults to `'content'` (generic behavior). **Available values**: * `"email"` * `"post"` * `"schedule"` * `"asset"` * `"draft"` * `"publication"` * `"content"` * `"content_export"` Current publish reference, if available Callback to upgrade thumbnail previews to full media. Call this function when you need full video or multi-page document previews instead of lightweight thumbnails. This helps optimize performance by deferring full media loading until needed. Upgrades may complete asynchronously; listen to `registerOnPreviewChange` for updates to receive the upgraded previews. **Example: Upgrading previews on user interaction** ```ts // When user clicks on a thumbnail, upgrade to full preview if (preview.status === 'thumbnail') { requestPreviewUpgrade([preview.id]); } ``` **Parameters** Array of preview IDs to upgrade from thumbnail to full media **Returns** `void` Registers a callback to be invoked when preview data changes. This callback is triggered when: * The design content changes * The output type changes * Preview media is upgraded from thumbnail to full video * Export settings are modified Use this to update your preview UI in real-time as users modify their design. **Example: Handling preview updates** ```ts const disposer = registerOnPreviewChange(({ previewMedia, outputType, publishRef }) => { // Update your preview UI with the new preview media previewMedia.forEach((media) => { media.previews.forEach((preview) => { if (preview.status === 'ready') { displayPreview(preview); } }); }); }); // Clean up when preview UI is unmounted onUnmount(() => disposer()); ``` **Parameters** The callback invoked when preview data is updated **Parameters** Properties of opts}> Preview media for a specific media slot. Contains preview URLs and metadata for images or videos in the design. Properties of previewMedia}> ID of the media slot this preview belongs to. Matches a media slot ID from your output type definition. Array of preview items for this media slot. May contain multiple previews if the media slot accepts multiple files. Image preview in various states. Image preview that is currently being generated. Display a loading state until the preview transitions to `"ready"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"image"`. Current state of the preview. The only valid value is `"loading"`. Width of the preview in pixels. Height of the preview in pixels. Image preview that is ready to display. Contains the URL to the preview image. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"image"`. Current state of the preview. The only valid value is `"ready"`. Image format of the preview. **Available values**: * `"png"` * `"jpg"` URL to the preview image. Use this URL to display the preview to users. Width of the preview in pixels. Height of the preview in pixels. Image preview that failed to generate. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"image"`. Current state of the preview. The only valid value is `"error"`. The error message to display to the user. Width of the preview in pixels. Height of the preview in pixels. Video preview in various states. Videos transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`. Start with thumbnails for better performance, then upgrade to full video using `requestPreviewUpgrade`. Video preview that is currently being generated. Display a loading state until the preview transitions to `"thumbnail"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"loading"`. Video duration in milliseconds. Video preview with lightweight thumbnail available. This is the initial state for video previews. Show the thumbnail image and call `requestPreviewUpgrade` when the user needs the full video. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"thumbnail"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the thumbnail image. Display this lightweight image until full video is needed. Video duration in milliseconds. Video preview that is being upgraded from thumbnail to full video. Display the thumbnail with a loading indicator until the video is ready. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"upgrading"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the thumbnail image. Continue showing the thumbnail while the full video loads. Video duration in milliseconds. Video preview with full video ready to play. Contains URLs for both the video and thumbnail. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"ready"`. Video format. The only valid value is `"mp4"`. URL to the full video. Use this URL in a video player. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the thumbnail image. Can be used as a poster image for the video player. Video duration in milliseconds. Video preview that failed to generate. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Width of the preview in pixels. Height of the preview in pixels. Type of media in this preview. The only valid value is `"video"`. Current state of the preview. The only valid value is `"error"`. The error message to display to the user. Document preview in various states. Documents transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`. Start with a lightweight thumbnail of the first page, then upgrade to full multi-page preview using `requestPreviewUpgrade`. Document preview that is currently being generated. Display a loading state until the preview transitions to `"thumbnail"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"loading"`. Width of the preview in pixels. Height of the preview in pixels. Document preview with first page thumbnail available. This is the initial state for document previews. Show the thumbnail image of the first page to give users a quick preview of the document. Call `requestPreviewUpgrade` to load all page thumbnails. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"thumbnail"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the first page thumbnail. Display this lightweight image to preview the document content. Width of the preview in pixels. Height of the preview in pixels. Intermediate state while multi-page document thumbnails are being fetched via requestPreviewUpgrade. The single-page thumbnail remains available for display during the upgrade. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"upgrading"`. Format of the thumbnail image. **Available values**: * `"png"` * `"jpg"` URL to the first page thumbnail. Continue showing this while the upgrade loads. Width of the preview in pixels. Height of the preview in pixels. Final state after a document preview has been upgraded. Contains thumbnail URLs for every selected page in the document. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"ready"`. Format of the per-page thumbnails. **Available values**: * `"png"` * `"jpg"` Thumbnail pages for each page. Index corresponds to the page number. Properties of pages}> URL to the page thumbnail image. Width of the page thumbnail in pixels. Height of the page thumbnail in pixels. Document preview that failed to generate. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"document"`. Current state of the preview. The only valid value is `"error"`. The error message to display to the user. Width of the preview in pixels. Height of the preview in pixels. Email preview in various states. Display a loading state until the preview transitions to `"ready"` or `"error"`. Email preview in a loading state. Display a loading spinner until the preview transitions to `"ready"` or `"error"`. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"email"`. Current state of the preview. The only valid value is `"loading"`. Email preview in a ready state. Display the email preview. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"email"`. Current state of the preview. The only valid value is `"ready"`. URL to the single html file that represents the email. Email preview in an error state. Display an error state to the user. Unique identifier for this preview. Use this ID with `requestPreviewUpgrade` to upgrade thumbnails to full previews. Type of media in this preview. The only valid value is `"email"`. Current state of the preview. The only valid value is `"error"`. The output type that the preview data is for Properties of outputType}> Unique identifier for this output type. Use descriptive IDs like `"instagram_post"` or `"youtube_video"`. User-facing name for this output type. This is displayed to users when selecting where to publish. Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`. Array of media slots defining what content is needed. Each slot represents a piece of media required for publishing, such as a main image, thumbnail, or video. Properties of mediaSlots}> Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. File type requirements for this slot. Note the following behavior: * Provide at least one of the valid types * If multiple types are provided, files for this slot may be any of the accepted types; each file must satisfy the corresponding requirement for its media type * To restrict the slot to a single media type, provide only that requirement * `fileCount` applies across all files accepted by the slot regardless of media type * Document output types will show image previews (PNG thumbnail) in preview UI Properties of accepts}> Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` Properties of image}> File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Properties of video}> Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Properties of document}> Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email output types will show a single html file (canva hosted assets) preview in preview UI Properties of email}> File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * undefined: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Leaves Canva's own default selection in place, which it already does for a slot that omits this field. To pre-select multiple inputs in a slot, use MediaSlotWithAutoSelect. The default autoSelect behavior is informed by the `accepts` and `fileCount` fields. * If a single media type is accepted, Canva will pre-select the first valid input as a file for that type. * If multiple media types are accepted, Canva may infer a preferred media type from the current editor state. * If `fileCount` is not provided, no auto-selection will occur. The only valid value is `"default"`. Current selection for this slot. Selection metadata for an image media item. The only valid value is `"image"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a video media item. The only valid value is `"video"`. Duration of the selected video in milliseconds. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a document media item. The only valid value is `"document"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for an email media item. The only valid value is `"email"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The type of content being published. When set, Canva uses this to tailor and improve the publish experience. When omitted, defaults to `'content'` (generic behavior). **Available values**: * `"email"` * `"post"` * `"schedule"` * `"asset"` * `"draft"` * `"publication"` * `"content"` * `"content_export"` The current publish settings reference, if available **Returns** `void` **Returns** A disposer function that cleans up the registered callback. () => `void` **Returns** `void` Publishes the content to the external platform. This action is called when the user confirms the publish action after reviewing settings and preview. Your implementation should send the exported files to your platform's API. The `outputMedia` contains production-ready files that match the requirements specified in your output types. The `publishRef` contains the user's settings from the settings UI. **Example: Publishing content to an external platform** ```ts import type { PublishContentRequest, PublishContentResponse } from '@canva/intents/content'; async function publishContent(request: PublishContentRequest): Promise { const { publishRef, outputType, outputMedia } = request; try { // Parse settings from publishRef const settings = publishRef ? JSON.parse(publishRef) : {}; // Upload files to your platform const uploadedFiles = await Promise.all( outputMedia.flatMap(media => media.files.map(file => uploadFile(file.url)) ) ); // Create post on your platform const result = await createPost({ files: uploadedFiles, caption: settings.caption }); return { status: 'completed', externalId: result.id, externalUrl: result.url }; } catch (error) { return { status: 'remote_request_failed' }; } } ``` **Parameters** Parameters for the publish operation. Properties of request}> The output type selected by the user for this publish operation. This matches one of the output types you provided in `getPublishConfiguration`. Properties of outputType}> Unique identifier for this output type. Use descriptive IDs like `"instagram_post"` or `"youtube_video"`. User-facing name for this output type. This is displayed to users when selecting where to publish. Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`. Array of media slots defining what content is needed. Each slot represents a piece of media required for publishing, such as a main image, thumbnail, or video. Configuration for a media slot within an output type. Defines what type of media is accepted, requirements, and constraints. **Example: Image slot with aspect ratio requirements** ```ts const thumbnailSlot: MediaSlot = { id: 'thumbnail', displayName: 'Video Thumbnail', fileCount: { exact: 1 }, accepts: { image: { format: 'jpg', aspectRatio: { exact: 16/9 }, } } }; ``` Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. File type requirements for this slot. Note the following behavior: * Provide at least one of the valid types * If multiple types are provided, files for this slot may be any of the accepted types; each file must satisfy the corresponding requirement for its media type * To restrict the slot to a single media type, provide only that requirement * `fileCount` applies across all files accepted by the slot regardless of media type * Document output types will show image previews (PNG thumbnail) in preview UI Properties of accepts}> Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` Properties of image}> File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Properties of video}> Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Properties of document}> Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email output types will show a single html file (canva hosted assets) preview in preview UI Properties of email}> File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * undefined: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Leaves Canva's own default selection in place, which it already does for a slot that omits this field. To pre-select multiple inputs in a slot, use MediaSlotWithAutoSelect. The default autoSelect behavior is informed by the `accepts` and `fileCount` fields. * If a single media type is accepted, Canva will pre-select the first valid input as a file for that type. * If multiple media types are accepted, Canva may infer a preferred media type from the current editor state. * If `fileCount` is not provided, no auto-selection will occur. The only valid value is `"default"`. Configuration for a media slot within an output type. Defines what type of media is accepted, requirements, and constraints. Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * `{ min: 0 }`: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` File type requirements for this slot. Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email file requirements for a media slot, currently only supports HTML bundle format. Note: Email output types use html\_standalone previews in the preview UI. The actual email file is only generated for the final output in OutputMedia. **Example: Email bundle requirements** ```ts const emailReq: EmailRequirement = { format: 'html_bundle', }; ``` File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Canva will pre-select all valid inputs as files for this slot when the publish panel first opens. **Example: Image slot with all valid inputs as files auto-selected** ```ts const thumbnailSlot: MediaSlotWithAutoSelect = { id: 'thumbnail', displayName: 'Video Thumbnail', fileCount: { exact: 1 }, accepts: { format: 'jpg', aspectRatio: { exact: 16 / 9 }, }, autoSelect: 'all_valid_inputs_as_files', }; ``` The only valid value is `"all_valid_inputs_as_files"`. The type of content being published. When set, Canva uses this to tailor and improve the publish experience. When omitted, defaults to `'content'` (generic behavior). **Available values**: * `"email"` * `"post"` * `"schedule"` * `"asset"` * `"draft"` * `"publication"` * `"content"` * `"content_export"` Production-ready exported files matching the requirements from your output type. These files are ready to upload to your platform and match the format, size, and aspect ratio requirements specified in your media slots. Properties of outputMedia}> ID of the media slot these files belong to. Matches a media slot ID from your output type definition. Array of exported files for this media slot. Files match the requirements specified in your media slot configuration. Exported image file ready for publishing. File format. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` URL to download the exported file. Your app should download from this URL and upload to your platform. Metadata about the source content used to create this exported file. Properties of contentMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The pages that make up the exported metadata Properties of pages}> The unique identifier for the page. The position of the page within the design, starting from 1 for the first page. Width of the image in pixels. Height of the image in pixels. Exported video file ready for publishing. File format. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` URL to download the exported file. Your app should download from this URL and upload to your platform. Metadata about the source content used to create this exported file. Properties of contentMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The pages that make up the exported metadata Properties of pages}> The unique identifier for the page. The position of the page within the design, starting from 1 for the first page. Width of the video in pixels. Height of the video in pixels. Exported PDF file ready for publishing. Contains the final PDF document that should be uploaded to your platform. The document format is `pdf_standard` and the file is ready to use. File format. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` URL to download the exported file. Your app should download from this URL and upload to your platform. Metadata about the source content used to create this exported file. Properties of contentMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The pages that make up the exported metadata Properties of pages}> The unique identifier for the page. The position of the page within the design, starting from 1 for the first page. Platform-specific settings reference containing user configurations. This is the same reference you saved via `updatePublishSettings` in the settings UI. Parse this string to retrieve the user's publish settings (e.g., captions, tags, privacy). Maximum size: 32KB **Returns** A promise resolving to either a successful result with the published content details or an error. This is a `Promise` that resolves with the following object: Successful response from publishing a content. **Examples** **Basic successful publish** ```ts return { status: 'completed', externalId: 'post_12345', externalUrl: 'https://example.com/posts/12345' }; ``` **Successful publish with redirect** ```ts return { status: 'completed', externalId: 'video_67890', externalUrl: 'https://example.com/videos/67890', postPublishAction: { type: 'redirect', url: 'https://example.com/videos/67890/edit' } }; ``` The only valid value is `"completed"`. Unique identifier returned from your external platform. You can use this for: * Tracking published content * Fetching insights data for the published content * Linking back to the content in future operations Direct URL to the published content on your platform. Users can visit this URL to view their published content. This may be displayed to users or used for sharing. Optional action to perform after publishing completes. Currently supports redirecting users to a specific URL after publishing. Properties of postPublishAction}> The only valid value is `"redirect"`. The URL to redirect the user to after publishing. Error response from publishing a content. Return the appropriate error type based on the failure: * `"remote_request_failed"`: Network or API errors with your platform * `"app_error"`: Custom application errors with optional message PublishContentError indicating failure of the remote request to the external platform. Return this error for: * Network connectivity issues * API endpoint failures * HTTP errors from your platform * Timeout errors **Example: Handling network errors** ```ts try { await uploadToExternalPlatform(file); } catch (error) { return { status: 'remote_request_failed' }; } ``` The only valid value is `"remote_request_failed"`. PublishContentError indicating a custom error occurred in your app's implementation. Return this for application-specific errors such as: * Validation failures * Authentication errors * Rate limiting * Platform-specific restrictions **Example: Returning custom error with message** ```ts if (userQuotaExceeded) { return { status: 'app_error', message: 'You have reached your monthly publish limit. Please upgrade your plan.' }; } ``` The only valid value is `"app_error"`. (required) The raw error message, for logging purposes. It will not display in the UI. To display custom error messages in the UI use `localizedMessageId`. This should typically be the javascript error.message or a REST JSON error message body passed without modification. WARNING: Do not include personally identifiable information (PII) in this message, such as names, emails, usernames, etc. (optional) Message ID of the translated error message that will be displayed to the user. The message ID should be present and uploaded in your translation file. If omitted, Canva will display a generic error message. HTTP status code, if applicable Used only by app developer. Canva does not use this value. Use this to pass additional information like JSON to your settings frame. (optional) Source of the error if it relates to a component on the Canva UI. When present, the error may render near a relevant Canva component. When omitted, the cause is considered unspecified or "generic". **Available values**: * `"invalid_selection"` * `"invalid_format"` Extracts a structured summary of the post's content for historical display. Called at `createPost` / `updatePost` time while the app is loaded. The returned snapshot is stored with the post and used to render historical post views in the content planner (calendar, list views, insights) without re-invoking the app. The snapshot is frozen at write time — it reflects what was published, not the app's current rendering logic. If the app's payload shape or output types change later, historical views remain accurate. **Parameters** The `publishRef` and `outputType` for the post being published. Properties of request}> The output type selected for this publish operation. Use `id` to distinguish between output types. Properties of outputType}> Unique identifier for this output type. Use descriptive IDs like `"instagram_post"` or `"youtube_video"`. User-facing name for this output type. This is displayed to users when selecting where to publish. Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`. Array of media slots defining what content is needed. Each slot represents a piece of media required for publishing, such as a main image, thumbnail, or video. Properties of mediaSlots}> Unique identifier for this media slot within the output type. User-facing name for this media slot. Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`. File type requirements for this slot. Note the following behavior: * Provide at least one of the valid types * If multiple types are provided, files for this slot may be any of the accepted types; each file must satisfy the corresponding requirement for its media type * To restrict the slot to a single media type, provide only that requirement * `fileCount` applies across all files accepted by the slot regardless of media type * Document output types will show image previews (PNG thumbnail) in preview UI Properties of accepts}> Image file requirements for a media slot. Specifies format, aspect ratio, and size constraints for images. **Example: Image requirements for social media post** ```ts const imageReq: ImageRequirement = { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 }, }; ``` Properties of image}> File format for this requirement. **Available values**: * `"png"` * `"jpg"` * `"mp4"` * `"pdf_standard"` * `"html_bundle"` * `"html_standalone"` Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen (16:9) * `{ min: 0.8, max: 1.91 }`: Instagram range Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` **Available values**: * `"jpg"` * `"png"` Controls transparent-background support for PNG exports. * Only applies when `format` is `'png'` * If omitted or `false`, Canva exports a standard opaque PNG * If `true`, Canva shows a `Transparent background` toggle in the publish flow * Users without the required Canva entitlement may be prompted to upgrade before a transparent export is produced **Default value**: `false` Video file requirements for a media slot. Specifies format, aspect ratio, duration, and size constraints for videos. **Example: Video requirements for YouTube** ```ts const videoReq: VideoRequirement = { format: 'mp4', aspectRatio: { exact: 16/9 }, durationMs: { min: 1000, max: 600000 }, }; ``` Properties of video}> Supported video format. The only valid value is `"mp4"`. Aspect ratio constraint (width / height). Examples: * `{ exact: 16/9 }`: Widescreen * `{ exact: 9/16 }`: Vertical/Story format Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Duration constraint in milliseconds. Examples: * `{ max: 60000 }`: Maximum 60 seconds * `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Document file requirements for a media slot. Note: Document output types use image previews (PNG thumbnails) in the preview UI. The actual document file is only generated for the final output in OutputMedia. **Example: Document requirements** ```ts const documentReq: DocumentRequirement = { format: 'pdf_standard', size: 'a4', }; ``` Properties of document}> Supported document export format. Currently supports PDF standard format. The only valid value is `"pdf_standard"`. The document size of the export file. **Available values**: * `"a4"` * `"a3"` * `"letter"` * `"legal"` Email output types will show a single html file (canva hosted assets) preview in preview UI Properties of email}> File format for this requirement. **Available values**: * `"html_bundle"` * `"html_standalone"` Number of files accepted in this slot. Use this to specify single or multiple file requirements. Examples: * `{ exact: 1 }`: Exactly one file * `{ min: 1, max: 10 }`: Between 1 and 10 files * undefined: Any number of files Exact value range constraint. **Example: Exact value range** ```ts const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1 ``` Minimum value range constraint. **Example: Minimum value range** ```ts const minValue: ValueRange = { min: 3 }; // At least 3 ``` Maximum value range constraint. **Example: Maximum value range** ```ts const maxValue: ValueRange = { max: 10 }; // At most 10 ``` Minimum and maximum value range constraint. Ranges are inclusive `(min ≤ value ≤ max)`. **Example: Minimum and maximum value range** ```ts const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10 ``` Leaves Canva's own default selection in place, which it already does for a slot that omits this field. To pre-select multiple inputs in a slot, use MediaSlotWithAutoSelect. The default autoSelect behavior is informed by the `accepts` and `fileCount` fields. * If a single media type is accepted, Canva will pre-select the first valid input as a file for that type. * If multiple media types are accepted, Canva may infer a preferred media type from the current editor state. * If `fileCount` is not provided, no auto-selection will occur. The only valid value is `"default"`. Current selection for this slot. Selection metadata for an image media item. The only valid value is `"image"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a video media item. The only valid value is `"video"`. Duration of the selected video in milliseconds. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for a document media item. The only valid value is `"document"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design Selection metadata for an email media item. The only valid value is `"email"`. Metadata about the source content represented by this selection. Properties of selectionMetadata}> The only valid value is `"design"`. A signed JWT token containing the design id The user given title of the design The type of content being published. When set, Canva uses this to tailor and improve the publish experience. When omitted, defaults to `'content'` (generic behavior). **Available values**: * `"email"` * `"post"` * `"schedule"` * `"asset"` * `"draft"` * `"publication"` * `"content"` * `"content_export"` The user's saved publish settings. Parse to retrieve app-specific state. **Returns** A promise resolving to the `ContentSummary`, or an error. This is a `Promise` that resolves with the following object: }> Successful response from getContentSummary. The only valid value is `"completed"`. A structured snapshot of a post's content for historical display. Discriminated by `type`. }> Content summary for social media posts (e.g. Instagram, Facebook, LinkedIn, YouTube). The account, page, or list this post was published to. For example, a Facebook Page, a mailing list, or a personal profile. Use the connected account's display name and icon when there is no distinct destination. Properties of destination}> User-facing name (e.g. "Bob's Cool Page", "Product Newsletter"). Avatar or icon URL for the destination. The only valid value is `"post"`. Post heading (e.g. YouTube title, LinkedIn article headline). Post caption or body text. Hashtags without the leading `#` (e.g. `["fashion", "design"]`). }> Content summary for email sends. The account, page, or list this post was published to. For example, a Facebook Page, a mailing list, or a personal profile. Use the connected account's display name and icon when there is no distinct destination. Properties of destination}> User-facing name (e.g. "Bob's Cool Page", "Product Newsletter"). Avatar or icon URL for the destination. The only valid value is `"email"`. Subject line. Email body preview or preheader. }> Content summary for file-destination apps (e.g. Google Drive, Dropbox). The account, page, or list this post was published to. For example, a Facebook Page, a mailing list, or a personal profile. Use the connected account's display name and icon when there is no distinct destination. Properties of destination}> User-facing name (e.g. "Bob's Cool Page", "Product Newsletter"). Avatar or icon URL for the destination. The only valid value is `"asset"`. Asset title or filename. Folder path (e.g. "/My Projects/Designs"). }> Generic content summary for apps that don't fit a more specific type. The account, page, or list this post was published to. For example, a Facebook Page, a mailing list, or a personal profile. Use the connected account's display name and icon when there is no distinct destination. Properties of destination}> User-facing name (e.g. "Bob's Cool Page", "Product Newsletter"). Avatar or icon URL for the destination. The only valid value is `"content"`. Title or headline. Body text or description. }> Error response from getContentSummary. The only valid value is `"app_error"`. (required) The raw error message, for logging purposes. It will not display in the UI. To display custom error messages in the UI use `localizedMessageId`. This should typically be the javascript error.message or a REST JSON error message body passed without modification. WARNING: Do not include personally identifiable information (PII) in this message, such as names, emails, usernames, etc. (optional) Message ID of the translated error message that will be displayed to the user. The message ID should be present and uploaded in your translation file. If omitted, Canva will display a generic error message. HTTP status code, if applicable Used only by app developer. Canva does not use this value. Use this to pass additional information like JSON to your settings frame. (optional) Source of the error if it relates to a component on the Canva UI. When present, the error may render near a relevant Canva component. When omitted, the cause is considered unspecified or "generic". **Available values**: * `"invalid_selection"` * `"invalid_format"` ## Returns `void`