On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

addNativeElement

API reference for the addNativeElement method.
This version of the API is in beta. Beta APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.

This API is deprecated, and is no longer recommended for use, and should be removed from your app.

Adds a native element to the user's design.

Parameters

elementobject
REQUIRED

The element to add to the user's design.

The type has been superseded by DesignElement.

An element that's natively supported by the Canva editor.

The type has been superseded by ImageElement.

An element that renders image content.

typestring
REQUIRED

The type of element.

This must be "image".

altTextAltText | undefined
REQUIRED

A description of the image content.

Properties of altText
textstring
REQUIRED

The text content.

decorativeboolean | undefined
REQUIRED

Indicates where the alternative text should be displayed.

  • If true, the alternative text will only be displayed in the editor.
  • If false, the alternative text will be displayed in the editor and in view-only mode.
dataUrlstring
OPTIONAL

A data URL that contains the image data.

refImageRef
OPTIONAL

A unique identifier that points to an image asset in Canva's backend.

The type has been superseded by VideoElement.

An element that renders video content.

typestring
REQUIRED

The type of element.

This must be "video".

refVideoRef
REQUIRED

A unique identifier that points to a video asset in Canva's backend.

altTextAltText | undefined
REQUIRED

A description of the video content.

Properties of altText
textstring
REQUIRED

The text content.

decorativeboolean | undefined
REQUIRED

Indicates where the alternative text should be displayed.

  • If true, the alternative text will only be displayed in the editor.
  • If false, the alternative text will be displayed in the editor and in view-only mode.

The type has been superseded by EmbedElement.

An element that renders rich media, such as a YouTube video.

typestring
REQUIRED

The type of element.

This must be "embed".

urlstring
REQUIRED

The URL of the rich media.

This URL must be supported by the Iframely API.

The type has been superseded by TextElement.

An element that renders text content.

typestring
REQUIRED

The type of element.

This must be "text".

childrenstring[]
REQUIRED

The text content.

Only the first element in this array is used.

fontSizenumber
OPTIONAL

The size of the text.

  • Minimum: 1
  • Maximum: 100

Default Value: 16

textAlignstring
OPTIONAL

The alignment of the text.

Default Value: "start"

The available options include:

  • "start"
  • "center"
  • "end"
  • "justify"
colorstring
OPTIONAL

The color of the text as a hex code.

The hex code must include all six characters and be prefixed with a # symbol.

Example

"#ff0099"
TS
fontRefFontRef
OPTIONAL

A unique identifier that points to a font asset in Canva's backend.

fontWeightFontWeight
OPTIONAL

The weight (thickness) of the font.

Default Value: "normal"

The available options include:

  • "normal"
  • "thin"
  • "extralight"
  • "light"
  • "medium"
  • "semibold"
  • "bold"
  • "ultrabold"
  • "heavy"
fontStylestring
OPTIONAL

The style of the font.

Default Value: "normal"

The available options include:

  • "normal"
  • "italic"
decorationstring
OPTIONAL

The decoration of the font.

Default Value: "none"

The available options include:

  • "none"
  • "underline"

The type has been superseded by ShapeElement.

An element that renders a vector shape.

typestring
REQUIRED

The type of element.

This must be "shape".

viewBoxShapeViewBox
REQUIRED

Options for configuring the scale and cropping of the shape.

Properties of viewBox
topnumber
REQUIRED

The distance of the shape from the top edge of the element, in pixels.

leftnumber
REQUIRED

The distance of the shape from the left edge of the element, in pixels.

widthnumber
REQUIRED

The width of the view box, in pixels.

heightnumber
REQUIRED

The height of the view box, in pixels.

pathsShapePath[]
REQUIRED

The paths that define the structure of the shape.

  • There must be between 1 and 30 paths (inclusive).
  • The maximum combined size of all paths must not exceed 2kb.
  • The maximum number of unique fill colors across all paths is 6.
Properties of paths
dstring
REQUIRED

The shape of the path.

This is similar to the d attribute of an SVG's path element, with some limitations:

  • The path must start with an M command.
  • The path must not have more than one M command.
  • The path must not use the Q command.
  • The path must be closed, either by:
    • Using a Z command at the end of the path
    • Having the last coordinate match the first coordinate
fillFill
REQUIRED

The appearance of the path's interior.

Properties of fill
dropTargetboolean
OPTIONAL

If true, users can replace a fill by dropping an image or video onto it.

colorstring
OPTIONAL

The color of the fill as a hex code.

The hex code must include all six characters and be prefixed with a # symbol.

Example

" #ff0099"
TS
assetobject
OPTIONAL

An image or video to use as the fill.

An image asset that fills a path's interior.

typestring
REQUIRED

The type of fill.

This must be "image".

refImageRef
REQUIRED

A unique identifier that points to an image asset in Canva's backend.

A video asset that fills a path's interior.

typestring
REQUIRED

The type of fill.

This must be "video".

refVideoRef
REQUIRED

A unique identifier that points to a video asset in Canva's backend.

strokePathStroke
OPTIONAL

The outline of the path.

Properties of stroke
weightnumber
REQUIRED

The weight (thickness) of the stroke.

  • Minimum: 0
  • Maximum: 100
colorstring
REQUIRED

The color of the stroke as a hex code.

The hex code must include all six characters and be prefixed with a # symbol.

Example

"#ff0099"
TS
strokeAlignstring
REQUIRED

The alignment of the stroke.

This must be "inset".

The type has been superseded by GroupElement.

An element that contains two or more elements.

typestring
REQUIRED

The type of element.

This must be "group".

childrenGroupContentAtPoint[]
REQUIRED

The elements to render within the group.

  • Each element within a group must have dimensions and a position.
  • The dimensions and positions are relative to the dimensions and positions of the group.

The type has been superseded by ElementAtPoint.

An element that's natively supported by the Canva editor and has positional properties.

The type has been superseded by ImageElementAtPoint.

An element that renders image content and has positional properties.

typestring
REQUIRED

The type of element.

This must be "image".

altTextAltText | undefined
REQUIRED

A description of the image content.

Properties of altText
textstring
REQUIRED

The text content.

decorativeboolean | undefined
REQUIRED

Indicates where the alternative text should be displayed.

  • If true, the alternative text will only be displayed in the editor.
  • If false, the alternative text will be displayed in the editor and in view-only mode.
topnumber
REQUIRED

The distance from the top edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
leftnumber
REQUIRED

The distance from the left edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
widthnumber
REQUIRED

A width, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
heightnumber
REQUIRED

A height, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
rotationnumber
OPTIONAL

A rotation, in degrees.

  • Minimum: -180
  • Maximum: 180
dataUrlstring
OPTIONAL

A data URL that contains the image data.

refImageRef
OPTIONAL

A unique identifier that points to an image asset in Canva's backend.

The type has been superseded by VideoElementAtPoint.

An element that renders video content and has positional properties.

typestring
REQUIRED

The type of element.

This must be "video".

refVideoRef
REQUIRED

A unique identifier that points to a video asset in Canva's backend.

altTextAltText | undefined
REQUIRED

A description of the video content.

Properties of altText
textstring
REQUIRED

The text content.

decorativeboolean | undefined
REQUIRED

Indicates where the alternative text should be displayed.

  • If true, the alternative text will only be displayed in the editor.
  • If false, the alternative text will be displayed in the editor and in view-only mode.
topnumber
REQUIRED

The distance from the top edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
leftnumber
REQUIRED

The distance from the left edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
widthnumber
REQUIRED

A width, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
heightnumber
REQUIRED

A height, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
rotationnumber
OPTIONAL

A rotation, in degrees.

  • Minimum: -180
  • Maximum: 180

The type has been superseded by EmbedElementAtPoint.

An element that renders rich media, such as a YouTube video, and has positional properties.

typestring
REQUIRED

The type of element.

This must be "embed".

urlstring
REQUIRED

The URL of the rich media.

This URL must be supported by the Iframely API.

topnumber
REQUIRED

The distance from the top edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
leftnumber
REQUIRED

The distance from the left edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
widthnumber
REQUIRED

A width, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
heightnumber
REQUIRED

A height, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
rotationnumber
OPTIONAL

A rotation, in degrees.

  • Minimum: -180
  • Maximum: 180

The type has been superseded by TextElementAtPoint.

An element that renders text content and has positional properties.

typestring
REQUIRED

The type of element.

This must be "text".

childrenstring[]
REQUIRED

The text content.

Only the first element in this array is used.

topnumber
REQUIRED

The distance from the top edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
leftnumber
REQUIRED

The distance from the left edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
fontSizenumber
OPTIONAL

The size of the text.

  • Minimum: 1
  • Maximum: 100

Default Value: 16

textAlignstring
OPTIONAL

The alignment of the text.

Default Value: "start"

The available options include:

  • "start"
  • "center"
  • "end"
  • "justify"
colorstring
OPTIONAL

The color of the text as a hex code.

The hex code must include all six characters and be prefixed with a # symbol.

Example

"#ff0099"
TS
fontRefFontRef
OPTIONAL

A unique identifier that points to a font asset in Canva's backend.

fontWeightFontWeight
OPTIONAL

The weight (thickness) of the font.

Default Value: "normal"

The available options include:

  • "normal"
  • "thin"
  • "extralight"
  • "light"
  • "medium"
  • "semibold"
  • "bold"
  • "ultrabold"
  • "heavy"
fontStylestring
OPTIONAL

The style of the font.

Default Value: "normal"

The available options include:

  • "normal"
  • "italic"
decorationstring
OPTIONAL

The decoration of the font.

Default Value: "none"

The available options include:

  • "none"
  • "underline"
rotationnumber
OPTIONAL

A rotation, in degrees.

  • Minimum: -180
  • Maximum: 180
widthnumber
OPTIONAL

The width of the element, in pixels.

  • Minimum: 0
  • Maximum: 32767

The type has been superseded by ShapeElementAtPoint.

An element that renders a vector shape and has positional properties.

typestring
REQUIRED

The type of element.

This must be "shape".

viewBoxShapeViewBox
REQUIRED

Options for configuring the scale and cropping of the shape.

Properties of viewBox
topnumber
REQUIRED

The distance of the shape from the top edge of the element, in pixels.

leftnumber
REQUIRED

The distance of the shape from the left edge of the element, in pixels.

widthnumber
REQUIRED

The width of the view box, in pixels.

heightnumber
REQUIRED

The height of the view box, in pixels.

pathsShapePath[]
REQUIRED

The paths that define the structure of the shape.

  • There must be between 1 and 30 paths (inclusive).
  • The maximum combined size of all paths must not exceed 2kb.
  • The maximum number of unique fill colors across all paths is 6.
Properties of paths
dstring
REQUIRED

The shape of the path.

This is similar to the d attribute of an SVG's path element, with some limitations:

  • The path must start with an M command.
  • The path must not have more than one M command.
  • The path must not use the Q command.
  • The path must be closed, either by:
    • Using a Z command at the end of the path
    • Having the last coordinate match the first coordinate
fillFill
REQUIRED

The appearance of the path's interior.

Properties of fill
dropTargetboolean
OPTIONAL

If true, users can replace a fill by dropping an image or video onto it.

colorstring
OPTIONAL

The color of the fill as a hex code.

The hex code must include all six characters and be prefixed with a # symbol.

Example

" #ff0099"
TS
assetobject
OPTIONAL

An image or video to use as the fill.

An image asset that fills a path's interior.

typestring
REQUIRED

The type of fill.

This must be "image".

refImageRef
REQUIRED

A unique identifier that points to an image asset in Canva's backend.

A video asset that fills a path's interior.

typestring
REQUIRED

The type of fill.

This must be "video".

refVideoRef
REQUIRED

A unique identifier that points to a video asset in Canva's backend.

strokePathStroke
OPTIONAL

The outline of the path.

Properties of stroke
weightnumber
REQUIRED

The weight (thickness) of the stroke.

  • Minimum: 0
  • Maximum: 100
colorstring
REQUIRED

The color of the stroke as a hex code.

The hex code must include all six characters and be prefixed with a # symbol.

Example

"#ff0099"
TS
strokeAlignstring
REQUIRED

The alignment of the stroke.

This must be "inset".

topnumber
REQUIRED

The distance from the top edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
leftnumber
REQUIRED

The distance from the left edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
widthnumber
REQUIRED

A width, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
heightnumber
REQUIRED

A height, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
rotationnumber
OPTIONAL

A rotation, in degrees.

  • Minimum: -180
  • Maximum: 180

The type has been superseded by GroupElementAtPoint.

An element that contains two or more elements and has positional properties.

typestring
REQUIRED

The type of element.

This must be "group".

childrenGroupContentAtPoint[]
REQUIRED

The elements to render within the group.

  • Each element within a group must have dimensions and a position.
  • The dimensions and positions are relative to the dimensions and positions of the group.
topnumber
REQUIRED

The distance from the top edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
leftnumber
REQUIRED

The distance from the left edge of the container, in pixels.

  • The pixels are relative to their container.
  • Minimum: -32768
  • Maximum: 32767
widthnumber
REQUIRED

A width, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
heightnumber
REQUIRED

A height, in pixels.

  • The pixels are relative to their container.
  • Minimum: 0
  • Maximum: 32767
rotationnumber
OPTIONAL

A rotation, in degrees.

  • Minimum: -180
  • Maximum: 180

Returns

Promise<void>