Quick start
The Canva Connect API has resource-oriented URLs, accepts requests with parameters, and returns JSON responses with standard HTTP response codes.
By default, the Canva Connect API endpoint URL paths have the following format:
https://api.canva.com/rest/<version>/<path>/<endpoint>
For example, the URL path for the endpoint used to generate an access token is:
https://api.canva.com/rest/v1/oauth/token
To use Canva Connect API:
Step 1: Install Curl
To check if curl
is installed on your machine, run the following command in your terminal:
curl --version
If you get information about the version, curl
is installed. Otherwise, download and install curl. The installation steps depend on your machine.
Step 2: Authenticate
Canva Connect API authentication is based on OAuth. An OAuth access token authenticates your integration to use the API endpoints on a user's behalf. You need to add the access token as a header to every API request. Follow the steps below to get the access token:
-
Get the authorization code by visiting the
/authorize
endpoint through a browser. -
Use the authorization code and generate an access token using the
/token
endpoint.
Step 3: Make requests
Once you are authenticated to use Canva Connect API, you can make API requests.
The example below shows how you can create a folder, and upload an asset to the folder using the Canva Connect API.
Task 1: Find the HTTP method and path for your operation
Go through the API Reference section and find the HTTP method and the path of the endpoint you wish to use.
HTTP method and path for creating a folder
To create a folder you need the following HTTP method and URL path:
HTTP Method: POST
URL Path: https://api.canva.com/rest/v1/folders
HTTP method and path for uploading an asset
Similarly, to upload an asset you need the following HTTP method and URL path:
HTTP Method: POST
URL Path: https://api.canva.com/rest/v1/assets/upload
Task 2: Find the request parameters for your operation
The API Reference section also specifies the request parameters required for your operation.
Request parameters for creating a folder
To create a folder you need the following header and body parameters:
Header parameters
Authorization: Bearer {token}
Content-Type: application/json
Body parameters
Name of the folder
Create a folder in this folder. Defaults to the root
folder (main
folder) if not provided.
Request parameters for uploading an asset to a folder
Similarly, to upload an asset you need the following header and body parameters:
Header parameters
Authorization: Bearer {token}
Content-Type: application/json
Upload-Metadata: {Upload Metadata}
Upload-Metadata
Name of the asset. This is displayed in the UI.
ID of the folder where the asset will be uploaded.
Body parameter
The binary blob of the uploaded file. Can be attached to curl
using --data-binary "@filepath"
.
Task 3: Create the curl request using the HTTP method, path, and request parameters
Once you know the HTTP method, path, and request parameters, you can create the curl request.
Curl request for creating a folder
For example, let your access token be eyJraWQiOiI3MjUxMzM0ZS1hNTUzL
.
The CURL request for creating a folder named Team (in the root directory) becomes:
curl --request POST 'https://api.canva.com/rest/v1/folders' \--header 'Content-Type: application/json' \--header 'Authorization: Bearer eyJraWQiOiI3MjUxMzM0ZS1hNTUzL' \--data '{"name": "Team","parent_folder_id": "root"}'
The success response looks like the following:
{"folder": {"id": "FvqYUvJO28i","name": "Team","created_at": 1672514508,"updated_at": 1675318908}}
Curl request for uploading an asset to a folder
The CURL request for uploading an asset (an image named John Doe) to the Team folder (with folder id: FvqYUvJO28i
) is:
curl --request POST 'https://api.canva.com/rest/v1/assets/upload' \--header 'content-type: application/octet-stream' \--header 'Upload-Metadata: {"name":"John Doe","tags":"manager","parent_folder_id":"FvqYUvJO28i"}' \--header 'Authorization: Bearer eyJraWQiOiI3MjUxMzM0ZS1hNTUzL' \--data '@/Users/username/folder-location/johndoe.png'
The success response looks like the following:
{"asset": {"id": "QvqYUvJO28i","name": "John Doe","tags": ["manager"],"parent_folder_id": "FvqYUvJO28i","import_status": {"state": "IN_PROGRESS"},"created_at": 1672514508,"updated_at": 1675318908}}