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.

getTemporaryUrl

API reference for the getTemporaryUrl method.
This version of the API is deprecated. This version will soon be unsupported. You should use a stable version of the API in your app.

Gets the URL of an asset, such as an image or video file, from Canva's backend.

To see how this method is used, see Replacing elements.

Usage

import { getTemporaryUrl } from "@canva/asset";
const result = await getTemporaryUrl({
type: "IMAGE",
ref: "<REFERENCE_GOES_HERE>",
});
console.log(result.url);
TS

Permissions

Before an app that uses this method can be submitted for review, the canva:asset:private:read permission must be enabled via the Developer Portal. To learn more, see Configuring permissions.

Rate limit

This method has a rate limit of 20 requests every 10 seconds.

Parameters

optionsobject
REQUIRED

The options for getting the URL of an asset.

options.typestring
REQUIRED

The type of asset.

The available options include:

  • "IMAGE"
  • "VIDEO"
options.refstring
REQUIRED

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

Returns

A Promise that resolves with the following object:

resultobject
REQUIRED

The successful result of getting a temporary URL.

result.typestring
REQUIRED

The type of asset.

The possible values include:

  • "IMAGE"
  • "VIDEO"
result.refstring
REQUIRED

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

result.urlstring
REQUIRED

The URL of the asset.

The URL is temporary and expires after a short duration. Your app should download the asset immediately rather than assuming the URL will continue to exist.