Creating designs
Create a new design with the JavaScript API.
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:
1
api.createDesign({
2
design: {
3
type: "Poster",
4
},
5
});
Copied!
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

1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="UTF-8" />
5
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
<title>Canva Button</title>
7
<script src="https://sdk.canva.com/designbutton/v2/api.js"></script>
8
</head>
9
<body>
10
<button>Create a new design</button>
11
<script type="text/javascript">
12
(async () => {
13
if (!window.Canva || !window.Canva.DesignButton) {
14
return;
15
}
16
17
const api = await window.Canva.DesignButton.initialize({
18
apiKey: "API KEY GOES HERE",
19
});
20
21
const button = document.querySelector("button");
22
23
button.onclick = () => {
24
api.createDesign({
25
design: {
26
type: "Poster",
27
},
28
});
29
};
30
})();
31
</script>
32
</body>
33
</html>
Copied!
Last modified 4mo ago
Copy link
Contents
Example