createDesign

Creates a design in the editor.

The createDesign method accepts different parameters depending on whether or not a design is created via a product catalog.

Create a design via the catalog-to-editor path

The catalog-to-editor path allows an integration to create a design via the product catalog.

Usage

(async () => {
const api = await Canva.Partnership.initialize({
apiKey: "<partner_api_key>",
autoAuthToken: "<auto_auth_token>",
container: document.getElementById("container"),
});
const onBackClick = () => {
// the user has clicked the "Back" button in the editor's header
console.log("You clicked the 'Back' button!");
};
const onArtworkCreate = (opts) => {
// the user has finished proofing their design
console.log(opts);
};
const onProductSelect = (opts) => {
api.createDesign({
...opts,
onBackClick,
onArtworkCreate,
});
};
api.showCatalog({
onProductSelect,
});
})();

Parameters

Parameter

Type

Required

Description

opts

object

Yes

Options for creating a new design in the Canva editor.

opts.onArtworkCreate (deprecated)

function

Yes

See onArtworkCreate. This parameter is superseded by opts.onMultiArtworkCreate.

opts.onBackClick

function

Yes

See onBackClick.

opts.onMultiArtworkCreate

function

Yes

See onMultiArtworkCreate.

opts.designId

string

No

The ID of an existing design. If present, a new design is created as a copy of the existing design.

opts.maxPages

number

No

The maximum number of pages a user can print. The default value is 100.

opts.minPages

number

No

The minimum number of pages a user can print. The default value is 1.

opts.onDesignClose

function

No

See onDesignClose.

opts.onDesignOpen

function

No

See onDesignOpen.

opts.publishLabel

string

No

A label for the editor's Publish button.

opts.title

string

No

The title of the design. The default title is Untitled design. The title is used in the exported design's filename. Users can change the title later in the Canva editor.

Create a design via the direct-to-editor path

The direct-to-editor path allows an integration to avoid a product catalog and create a design directly in the Canva editor.

Usage

(async () => {
const api = await Canva.Partnership.initialize({
apiKey: "<partner_api_key>",
autoAuthToken: "<auto_auth_token>",
});
const onBackClick = () => {
// the user has clicked the "Back" button in the editor's header
console.log("You clicked the 'Back' button!");
};
const onArtworkCreate = (opts) => {
console.log(opts);
};
api.createDesign({
partnerProductId: "ExampleCo45",
type: "Canvas",
width: 40,
height: 60,
units: "cm",
onBackClick,
onArtworkCreate,
});
})();

Parameters

Parameter

Type

Required

Description

opts

object

Yes

Options for creating a new design in the Canva editor.

opts.height

number

Yes

The height of the design. For size-based design types, don't pass this parameter. A size-based design type has the dimensions mentioned in its name, such as Banner24x96in, Banner900x3600mm, etc. The unit of measurement is determined by the opts.units property.

opts.onArtworkCreate (deprecated)

function

Yes

See onArtworkCreate. This parameter is superseded by opts.onMultiArtworkCreate.

opts.onBackClick

function

Yes

See onBackClick.

opts.onMultiArtworkCreate

function

Yes

See onMultiArtworkCreate.

opts.partnerProductId

string

Yes

The ID of a product in the partner's back-end, such as an SKU or internal system identifier.

opts.type

string

Yes

The ID of a type. This ID determines the dimensions, the templates, and the furniture, if applicable, that the Canva editor should open with for a design. Before setting up an integration, a partner defines these characteristics via a product list. Canva then sets them up for an integration.

opts.units

string

Yes

A unit of measurement. The supported values are "px", "cm", "mm", "in". For size-based design types, don't pass this parameter. A size-based design type has the dimensions mentioned in its name, such as Banner24x96in, Banner900x3600mm, etc.

opts.width

number

Yes

The width of the design. The unit of measurement is determined by the units property. For size-based design types, don't pass this parameter. A size-based design type has the dimensions mentioned in its name, such as Banner24x96in, Banner900x3600mm, etc.

opts.designId

string

No

The ID of an existing design. If present, a new design is created as a copy of the existing design.

opts.maxPages

number

No

The maximum number of pages a user can print. The default value is 100.

opts.minPages

number

No

The minimum number of pages a user can print. The default value is 1.

opts.onDesignClose

function

No

See onDesignClose.

opts.onDesignOpen

function

No

See onDesignOpen.

opts.publishLabel

string

No

A label for the editor's Publish button.

opts.title

string

No

The title of the design. The default title is Untitled design. The title is used in the exported design's filename. Users can change the title later in the Canva editor.