After setting up the JavaScript API, the next step is to allow users to create a design with the Canva editor.
To do this, call the createDesign
method:
api.createDesign({design: {type: "Poster",},});
javascript
At a minimum, the createDesign
method expects an opts.design.type
argument. This argument defines the design type of a newly created design. The design type determines:
- The dimensions of the user's design.
- The templates that Canva shows to the user.
For a complete list of design types that Canva supports, refer to Design types.
Example
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Canva Button</title><script src="https://sdk.canva.com/designbutton/v2/api.js"></script></head><body><button>Create a new design</button><script type="text/javascript">(async () => {if (!window.Canva || !window.Canva.DesignButton) {return;}const api = await window.Canva.DesignButton.initialize({apiKey: "API KEY GOES HERE",});const button = document.querySelector("button");button.onclick = () => {api.createDesign({design: {type: "Poster",},});};})();</script></body></html>
markup