getDesignToken

API reference for the getDesignToken method.
This version of the 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.

Retrieves a signed JWT that contains the Design ID, App ID and User ID.

Usage

Get design token

import { getDesignToken } from "@canva/design";
const { token } = await getDesignToken();
TYPESCRIPT

Verify token with backend service

import { getDesignToken } from "@canva/design";
const { token } = await getDesignToken();
const verifyResponse = await fetch('https://your-backend.com/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ token })
});
const json = await verifyResponse.json();
const { designId, appId, userId } = json;
TYPESCRIPT

Returns

JWT that contains the Design ID and App ID. This is a Promise that resolves with the following object:

tokenstring