Use Canva Connect API for design creation, export, and asset upload workflows.
Create a Canva Integration:
Set environment variables:
export CANVA_CLIENT_ID="your_client_id"
export CANVA_CLIENT_SECRET="your_client_secret"
Authenticate on first use and store tokens in ~/.canva/tokens.json.
https://api.canva.com/rest/v1
Get access token from local token file:
ACCESS_TOKEN=$(cat ~/.canva/tokens.json | jq -r '.access_token')
Refresh tokens automatically when the auth flow supports it.
curl -s "https://api.canva.com/rest/v1/designs" \
-H "Authorization: Bearer $ACCESS_TOKEN" | jq .
curl -s "https://api.canva.com/rest/v1/designs/{designId}" \
-H "Authorization: Bearer $ACCESS_TOKEN" | jq .
curl -X POST "https://api.canva.com/rest/v1/autofills" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"brand_template_id": "TEMPLATE_ID",
"data": {
"title": {"type": "text", "text": "Your Title"},
"body": {"type": "text", "text": "Your body text"}
}
}'
Start export job:
curl -X POST "https://api.canva.com/rest/v1/exports" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"design_id": "DESIGN_ID",
"format": {"type": "png", "width": 1080, "height": 1080}
}'
Check export status:
curl -s "https://api.canva.com/rest/v1/exports/{jobId}" \
-H "Authorization: Bearer $ACCESS_TOKEN" | jq .
curl -X POST "https://api.canva.com/rest/v1/asset-uploads" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
-H 'Asset-Upload-Metadata: {"name": "my-image.png"}' \
--data-binary @image.png
curl -s "https://api.canva.com/rest/v1/brand-templates" \
-H "Authorization: Bearer $ACCESS_TOKEN" | jq .
Handle common errors clearly:
design:content:readdesign:content:writeasset:readasset:writebrandtemplate:content:readThis local skill skeleton is installed in the workspace, but Canva API use is not ready until the integration credentials and first-time OAuth authentication are completed.
共 1 个版本